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

# AI Proxy

Give every model behind AI Proxy live web search from SpecStream's Search API. AI Proxy's Web Search plugin takes a SearchXNG engine with a Base URL, and SpecStream answers at that address in SearXNG's own format, so there is no search server to run.

[SpecStream for AI ProxyAPI & cloud platforms](https://specstream.ai/integrations/aiproxy.md)

## What you need

-   An AI Proxy deployment, and its `ADMIN_KEY` to sign in to the admin.
-   A SpecStream API key that can search. [Create an account](https://specstream.ai/signup?utm_source=aiproxy) if you have none.

1.  1

    ## 1. Copy a SpecStream key

    Open the [Search API screen](https://specstream.ai/workspace/search?route=searxng&utm_source=aiproxy&utm_medium=howto) of your SpecStream workspace and copy a key. A key that searches has the `finds:spend` scope and a spending limit above 0.

2.  2

    ## 2. Turn on the Web Search plugin

    Sign in to the AI Proxy admin with your `ADMIN_KEY`. Open **Model** in the sidebar and select **Edit** on the model that should search. Under **Plugin Configuration**, turn on **Web Search Plugin**.

3.  3

    ## 3. Add SpecStream as a SearchXNG engine

    Select **Add Search Engine** and set **Engine Type** to **SearchXNG**. In **Base URL**, enter the address below, with your key in place of `YOUR_SPECSTREAM_KEY`.

    AI Proxy adds `/search?q=...&format=json` to the Base URL and sends no key header, so the key goes in the address. Treat the Base URL as a secret.

    AI Proxy asks every engine in the list for every query, so remove the Bing or Google engine you are replacing once SpecStream answers.

    Base URL

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

4.  4

    ## 4. Save and send a request

    Select **Update** to save the model. With **Force search on every request** off, a request searches only when it carries `web_search_options`. Send one through AI Proxy to check it:

    POST /v1/chat/completions

    ```json
    {
      "model": "YOUR_MODEL",
      "messages": [
        { "role": "user", "content": "What changed in the EU AI Act this month?" }
      ],
      "web_search_options": {
        "enable": true,
        "search_context_size": "low"
      }
    }
    ```

## The same setting in the model config

The form saves the engine in the model's config under `plugin`, `web-search`, `search_from`, as `{"type": "searchxng", "spec": {"base_url": "https://api.specstream.ai/searxng/YOUR_SPECSTREAM_KEY"}}`.

The admin API saves a model's config at `POST /api/model_config/{model}`, with the admin key as a Bearer token. The call saves the object it is sent, so send the model's whole config with the engine added.

## How many searches an answer makes

AI Proxy asks each engine once for each search query, for 10 results each time. With SpecStream as the only engine:

-   Without query rewriting, a request makes one search.
-   With `search_rewrite` on, `max_count` sets the number of queries, 3 by default.
-   `search_context_size` in the request overrides it: `low` makes 1 search, `medium` 3 and `high` 5.

## References in the answer

Set `need_reference` to `true` and the answer numbers the pages it used as \[1\], \[2\] and so on. `reference_location` and `reference_format` set where the list goes and how it prints. SpecStream returns each result's `title`, `url` and `content`, which AI Proxy reads as the page's title, link and text.

## Moving off the Google or Bing engine

AI Proxy's Google engine calls Google's Custom Search JSON API at `www.googleapis.com`, which Google ends for existing customers on January 1, 2027. Its Bing engine calls `api.bing.microsoft.com`. Neither engine takes another address, so the move is the SearchXNG engine above: add it, send a test request, then remove the old engine.

## The web-search MCP server

AI Proxy's built-in web-search MCP server takes the same address in its `searchxng_base_url` setting (**SearchXNG Base URL**). Set its `default_engine` to `searchxng` to send its searches to SpecStream.

## Cost

Each search is one Search API call. A SearXNG search runs the fast search, which costs less than the default search at $5 per 1,000 searches of up to 10 results. [Search API](https://specstream.ai/docs/search-api.md) lists both prices. A search that returns no results costs nothing. It comes out of your balance, with no quote and no approval. New accounts start with $10 of credit, no card.

## If search fails

AI Proxy logs `searchxng search failed:` with the status and the reply, and the model answers without search results. AI Proxy waits up to 15 seconds for a SearchXNG reply.

-   `401` with `invalid_token`: the key in the Base URL is wrong, expired or revoked.
-   `402`: the balance is empty.
-   `403`: the key has no `finds:spend`, or the call would pass the key's spending limit.
-   `429` with `Retry-After`: search is busy. Nothing is charged.

## Remove SpecStream

Remove the SearchXNG engine in the model's **Web Search Plugin** settings, then revoke the key under **Agents & API** in your SpecStream workspace. Questions: [support@specstream.ai](mailto:support@specstream.ai).

## More

[SpecStream for AI Proxy](https://specstream.ai/integrations/aiproxy.md) covers what it does in AI Proxy 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).
