search2ai · 1,000+ GitHub StarsOpenRouterfor web search.
One gateway for every search provider,with unified routing and automatic fallback.
npx -y search2ai serve
Your providers. Your routing rules.
Connect the providers you choose with your own keys. Set the order for search, news, and page extraction, then route every request through search2ai.
.env · provider keys and routing orderSEARCH1API_KEY=your_provider_keyTAVILY_KEY=your_backup_provider_keySEARCH_SERVICE=search1api,tavilyNEWS_SERVICE=tavily,search1apiCRAWL_SERVICE=search1api,jina
Add your own providers
Configure built-in providers, or implement and register a provider adapter to connect another service.
Automatic fallback
On rate limits, timeouts, or failures, try the next provider in your chain. See which provider answered and why others failed.
Optional caching
Enable in-memory caching, or use Cloudflare KV on Workers. You control the TTL.
Already using another search API? Change only the base URL and key.
Point supported API and SDK calls at search2ai. Your existing calls and response parsing stay the same while the gateway routes to your configured providers.
Exa/compat/exa
Tavily/compat/tavily
Search1API/compat/search1apiSearXNG/compat/searxng
Firecrawl/compat/firecrawl
Compatibility covers the documented methods and options. Native-only features need the matching provider.
Prefer not to run a gateway? Search1API serves the same /compat paths for Tavily, Exa, Firecrawl and SearXNG at api.search1api.com, plus Jina, Bing Web Search v7 and Brave Search, with a Search1API key.
Tavily SDK · configuration changes onlyconst client = tavily({- apiKey: process.env.TAVILY_API_KEY,+ apiKey: process.env.GATEWAY_KEY,+ apiBaseURL: 'http://localhost:3014/compat/tavily',});const results = await client.search('AI agent frameworks');
Your stack. One integration.
Connect an AI client, call the HTTP API, or embed the gateway in your application.
Save your provider key in .env, start the service, then run the search request in a second terminal.
HTTP API# .envSEARCH1API_KEY=your_provider_key# Terminal 1npx -y search2ai serve --host 127.0.0.1# Terminal 2curl http://localhost:3014/v1/search \-H 'Content-Type: application/json' \-d '{"query":"hono cloudflare workers","max_results":3}'
Requires Node.js ≥ 22.18 and at least one configured provider.
Read the full documentationDeploy where you already run things.
Run it locally, in a container, or on Cloudflare Workers.
Node.js
Start with npx, or build and run from source.
npx -y search2ai serve
Docker
Prepare .env and pass it with --env-file.
docker build -t search2ai .docker run --rm -p 3014:3014 \--env-file .env search2ai
Cloudflare Workers
Store keys as Workers secrets. KV caching is optional.
npx wrangler secret put SEARCH1API_KEYnpm run deploy
Add web search to chat clients.
Clients with a custom OpenAI-compatible API base, such as NextChat, Cherry Studio, and Chatbox, can use search2ai as their model endpoint. The gateway gives the model search, news, and crawl tools; the model decides when to call them and composes the answer from the results.
- Set the API base URL to http://localhost:3014/v1
- Use a gateway key from AUTH_KEYS as the API key
- Choose a model that supports tool calling
Responses can stream. This path uses both search and model services, which may incur separate costs.
.env · chat proxySEARCH1API_KEY=your_provider_keyAPIBASE=https://api.openai.com/v1OPENAI_API_KEY=your_model_keyAUTH_KEYS=your_gateway_key
Common questions
Prefer hosted search?
Use Search1API directly, or connect it as a search2ai provider. Get search, news, and page extraction without running your own gateway.
Try Search1APIMIT licensed. Built in the open.