SearXNG search
SearXNG is available as a search provider on the Spanway gateway. It uses a SearXNG metasearch instance that you host. Like every search provider, it is exposed through the gateway's unified search endpoint, which follows the Perplexity Search API request shape, so applications and agents can switch search backends without code changes. The gateway keeps the provider credential, authenticates callers with virtual keys, applies access control to the search tool, and logs and costs each query.
The search provider id is searxng. There is no default endpoint, so api_base must point at your own instance.
Environment variables
| Variable | Required | Purpose |
|---|---|---|
SEARXNG_API_BASE | Yes | Base URL of the API |
SEARXNG_API_KEY | No | Optional key for a protected instance |
Register the search tool
Search tools are declared in the search_tools section of config.yaml, separate from model_list. The search_tool_name is the public name callers use.
search_tools:
- search_tool_name: searxng-search
spanway_params:
search_provider: searxng
api_base: os.environ/SEARXNG_API_BASE
Restart the gateway, or add the tool from the Search tools page in the Admin UI.
Run a search
curl -X POST http://localhost:4000/v1/search/searxng-search \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI gateway release notes", "max_results": 5, "search_domain_filter": ["arxiv.org"]}'
The response contains a results list in which each item has a title, url and snippet, whatever the backend returned natively. Supported request fields are query (a string or a list of strings), max_results (1 to 20), search_domain_filter, max_tokens_per_page and country.
A real-world scenario
A support agent built on the gateway needs fresh web results for questions about public product pages. The admin registers SearXNG once as the searxng-search search tool, grants it to the agent's team, and the agent calls /v1/search/searxng-search with its own virtual key while the SearXNG credential stays on the gateway.
Steps
-
Open Search Tools under Tools in the left nav and click + Add New Search Tool.
-
Type
searxng-searchas Search Tool Name, pick SearXNG under Search Provider, leave API Key empty unless your instance needs one, and set the instance URL withSEARXNG_API_BASE, and click Test Connection. -
Click Add Search Tool. The same tool from the API:
curl -X POST http://localhost:4000/search_tools \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"search_tool": {"search_tool_name": "searxng-search", "spanway_params": {"search_provider": "searxng"}}}' -
Run a search with a virtual key, as in Run a search.
Expected result
Connection Test Results reports a successful connection, the tool is listed with Source DB, and a search returns a results list with title, url and snippet for each hit. The query and its cost show on the Logs page.
Pricing
The gateway records a cost for each search query from its bundled price map, so search spend shows up next to model spend for every key and team. The values below are the prices bundled with this build. Override them with custom pricing if your contract differs.
| Price map entry | Cost per query (USD) |
|---|---|
searxng/search | $0.0 |
Errors
| What you see | What it means | Fix |
|---|---|---|
403 with key_search_tool_access_denied or team_search_tool_access_denied | Search tools are denied by default and the key or team has no grant for searxng-search. | Grant the tool on the key or team. |
500 naming the search tool | The tool is not registered, or the provider refused the call. | Check the name in GET /v1/search/tools and the provider credential. |
| The connection test fails with an authentication error | The SearXNG credential is wrong or expired. | Fix the key and test again. |
Only proxy admins can create search tools | A non admin tried to add the tool. | Use a proxy admin account. |
Related
See the search overview for access control on search tools and how agents use them, and the provider's own API documentation for limits and plans.