> SpecStream is the live web data engine for teams and agents. This is the Markdown copy of https://specstream.ai/docs/integrations/chat-nio. Every page, with what SpecStream does and costs: https://specstream.ai/llms.txt

# Chat Nio (CoAI)

Point Chat Nio's web search at SpecStream with one setting, the search endpoint. Chat Nio (now CoAI) keeps its own SearXNG code, and every chat with web search on runs on SpecStream's Search API at $1 per 1,000 searches, with no SearXNG server to run.

[SpecStream for Chat Nio (CoAI)AI assistants](https://specstream.ai/integrations/chat-nio.md)

## What you need

-   A self-hosted Chat Nio (CoAI) install and its admin account. This guide follows the source of the `main` branch of coaidev/coai.
-   A SpecStream key. [Get your key](https://specstream.ai/workspace/search?route=searxng&utm_source=chat-nio&utm_medium=howto) on the Search API screen of your SpecStream workspace. New accounts start with $10 of credit, no card.

1.  1

    ## 1. Set the search endpoint

    Sign in as an admin, open **System** in the admin menu, and find **Web Search**. In **Search Endpoint**, put SpecStream's SearXNG address with your key in it, in place of `YOUR_SPECSTREAM_KEY`. Leave **Search Engine Settings** empty and select **Save**.

    Search Endpoint

    ```text
    https://api.specstream.ai/searxng/YOUR_SPECSTREAM_KEY/search
    ```

2.  2

    ## 2. Or set it in config.yaml

    The same setting lives in `config/config.yaml`, under `system`, `search`, `endpoint`. With the Docker installs it is the file in the folder mounted as `/config` (`~/config` in Chat Nio's README).

    config/config.yaml

    ```yaml
    system:
      search:
        endpoint: https://api.specstream.ai/searxng/YOUR_SPECSTREAM_KEY/search
    ```

3.  3

    ## 3. Restart Chat Nio

    Chat Nio loads the search settings when it starts, and **Save** writes them to `config/config.yaml`. Restart the service so searches use the new endpoint: `docker-compose restart` for the Docker Compose install, or `docker restart chatnio` for the `docker run` install.

4.  4

    ## 4. Test the search

    Back in **System**, under **Web Search**, open **Search Quizzes**, type a query and select **Confirm**. The box fills with one line per result: the title, the URL in brackets and the text.

5.  5

    ## 5. Ask with web search on

    In a chat, turn on **Web search** in the message box. Chat Nio shows "Web search is enabled". Then ask about something recent:

    In a Chat Nio chat

    ```text
    What changed in the latest PostgreSQL release?
    ```

## What Chat Nio sends, and what comes back

-   Chat Nio sends `GET` to the endpoint with `q` (the user's last message), `format=json`, `safesearch` (0, 1 or 2, from **SafeSearch Mode**), and `engines` and `image_proxy` when those settings are on.
-   SpecStream answers in SearXNG's JSON: `results[]` with `url`, `title`, `content`, `score` and `publishedDate`, with `answers`, `suggestions` and `unresponsive_engines` beside them.
-   Chat Nio keeps each result that has a title, a URL and text, writes it as `title (url): content`, and adds the lines to the chat's system message with the current time.
-   Each search returns 10 results. To cap the text the model reads, turn on **Turn on results truncation** and set **Maximum Result Characters**.
-   SpecStream picks the engines for each query, so the **Search Engine Settings** list and **Turn on image proxy** change nothing here.

## Why the key goes in the address

Chat Nio's search setting has no key field: it calls the endpoint as written, with no header. SpecStream reads the key from the address. Anyone who can read the admin settings or `config.yaml` can read it, so give Chat Nio a key of its own with a spending limit, made in [Agents & API](https://specstream.ai/workspace/agents?tab=keys&utm_source=chat-nio).

## What each search costs

Each chat message with web search on is one search on the Search API's fast tier: $1 per 1,000 searches of up to 10 results. It comes out of your SpecStream balance, with no quote and no approval. A search that returns nothing costs nothing, and every call, charged or not, is in your account's request log.

What your users pay stays as you set it in Chat Nio. Its own tip says web search may consume more tokens, since the results go to the model as input.

The Search API scores 97.9 F-score on all 1,000 SimpleQA Verified questions; scores and method are on the [benchmarks page](https://specstream.ai/benchmarks.md).

## Limits and errors

-   Chat Nio sends the whole last message as the query. A message over 2,000 characters is refused with `422`, and Chat Nio sends the chat with "search failed" in place of results.
-   `401` means the key in the address was refused. Check the endpoint, save, and restart.
-   When the account has used its calls for the minute or search is busy, the route answers `429` with `Retry-After`, and nothing is charged.
-   **Search Quizzes** works but chats get no results: check that **Web search** is on in that chat.

## The same address in other apps

Any app that takes a SearXNG instance takes this address. See [SearXNG on SpecStream](https://specstream.ai/migrate/searxng.md) for the parameters and fields, and the [Search API docs](https://specstream.ai/docs/search-api.md) for the API itself, at $5 per 1,000 searches with an answer, or $1 per 1,000 on the fast tier.

## Go back

Set **Search Endpoint** back to your SearXNG instance, or to `https://duckduckgo-api.vercel.app`, the value in Chat Nio's `config.example.yaml`, then save and restart. Questions: [support@specstream.ai](mailto:support@specstream.ai).

## More

[SpecStream for Chat Nio (CoAI)](https://specstream.ai/integrations/chat-nio.md) covers what it does in Chat Nio (CoAI) on one page. Every other tool has its guide in [Connect your tools](https://specstream.ai/docs/integrations.md). You see the most a request can cost before it starts, and the matches are paid from your balance. [Billing](https://specstream.ai/docs/billing.md) has the details. For help, email [support@specstream.ai](mailto:support@specstream.ai).
