search2ai · 1,000+ GitHub Stars · MIT licensed · Self-hostedsearch2ai · 1,000+ GitHub Stars

OpenRouterfor web search.

One gateway for every search provider,with unified routing and automatic fallback.

Start with one command, then connect viaMCPHTTP APITypeScript
npx -y search2ai serve
See every way to connect
search2ai
Search1APISearch · News · Page extraction
TavilySearch · News · Page extraction
ExaSearch · News · Page extraction
BraveSearch · News
GoogleSearch · News
SearXNGSearch · News
SSerperSearch · News
SSerpAPISearch · News
JinaPage extraction
FirecrawlPage extraction

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 order
SEARCH1API_KEY=your_provider_key
TAVILY_KEY=your_backup_provider_key
​
SEARCH_SERVICE=search1api,tavily
NEWS_SERVICE=tavily,search1api
CRAWL_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/search1api
  • SearXNG/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 only
const 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
# .env
SEARCH1API_KEY=your_provider_key
​
# Terminal 1
npx -y search2ai serve --host 127.0.0.1
​
# Terminal 2
curl 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 documentation

Deploy 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_KEY
npm 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.

  1. Set the API base URL to http://localhost:3014/v1
  2. Use a gateway key from AUTH_KEYS as the API key
  3. 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 proxy
SEARCH1API_KEY=your_provider_key
APIBASE=https://api.openai.com/v1
OPENAI_API_KEY=your_model_key
AUTH_KEYS=your_gateway_key

Common questions

Both are built by the same team. search2ai came first as an open-source project; the team then launched Search1API as a cloud search API. Use Search1API directly, or connect it as a search2ai provider.
search2ai is MIT licensed and free to self-host. Provider credentials, quotas, and usage charges are managed separately by each provider.
Each attempt is a separate request to that provider. Whether it is billed follows that provider’s own rules.
Yes. search2ai runs on Node.js, Docker, or Cloudflare Workers. If you’d rather not run a gateway, use the hosted Search1API.
MCP, the HTTP API, and the JavaScript / TypeScript library; compatible APIs for Exa, Tavily, Search1API, SearXNG, and Firecrawl; and an OpenAI-compatible proxy for chat clients.

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.