Skip to main content

Tavily search

Tavily is available as a search provider on the Spanway gateway. It uses Tavily's search API built for agents, with basic and advanced depth. 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 tavily. The integration calls https://api.tavily.com unless you set api_base or TAVILY_API_BASE.

Environment variables​

VariableRequiredPurpose
TAVILY_API_KEYYesCredential sent to Tavily
TAVILY_API_BASENoBase URL of the API

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: tavily-search
spanway_params:
search_provider: tavily
api_key: os.environ/TAVILY_API_KEY

Restart the gateway, or add the tool from the Search tools page in the Admin UI.

curl -X POST http://localhost:4000/v1/search/tavily-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 Tavily once as the tavily-search search tool, grants it to the agent's team, and the agent calls /v1/search/tavily-search with its own virtual key while the Tavily credential stays on the gateway.

Steps​

  1. Open Search Tools under Tools in the left nav and click + Add New Search Tool.

  2. Type tavily-search as Search Tool Name, pick Tavily under Search Provider, set API Key to your Tavily key, and click Test Connection.

  3. 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": "tavily-search", "spanway_params": {"search_provider": "tavily"}}}'
  4. 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 entryCost per query (USD)
tavily/search$0.008
tavily/search-advanced$0.016

Errors​

What you seeWhat it meansFix
403 with key_search_tool_access_denied or team_search_tool_access_deniedSearch tools are denied by default and the key or team has no grant for tavily-search.Grant the tool on the key or team.
500 naming the search toolThe 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 errorThe Tavily credential is wrong or expired.Fix the key and test again.
Only proxy admins can create search toolsA non admin tried to add the tool.Use a proxy admin account.

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.