Cloudflare Workers starter for live web search, Markdown extraction and Google CSE drop-in routes at the edge
A Cloudflare Worker in TypeScript that puts SpecStream, the live web data engine, one hop from your users: ranked live search, the main text of any page as Markdown, and drop-in routes that answer Google Custom Search, Bing Web Search v7, Tavily and Exa requests in their own shapes. Point the code you already have at your worker and change nothing else.
| Worker route | Calls on https://api.specstream.ai |
Price |
|---|---|---|
GET / |
GET /v1/search-dialects, a live check |
free, no key |
GET /search?q= |
GET /v1/web-search on the fast tier |
$1 per 1,000 |
GET /extract?url= or POST /extract |
POST /v1/extract, Markdown |
$0.80 per 1,000 pages |
GET /customsearch/v1 |
Google Custom Search JSON API shape | $1 per 1,000 |
GET /v7.0/search |
Bing Web Search API v7 shape | $1 per 1,000 |
POST /tavily/search |
Tavily shape | $1 per 1,000 |
POST /exa/search |
Exa shape | $1 per 1,000 |
The fast tier answers in 937 ms median over 6,548 live calls in the 7 days to December 1, 2026. SpecStream is first on WideSearch and scores 99 on SimpleQA Verified.
git clone https://github.com/specstream/cloudflare-workers-specstream
cd cloudflare-workers-specstream
npm install
npm run check # tsc, strict
npx wrangler dev # http://localhost:8787
curl http://localhost:8787/ # live, no key, nothing charged{"ok":true,"drop_in_apis":70,"routes":78,"on_this_worker":[{"name":"Google Custom Search JSON API","replaces":"https://www.googleapis.com"},{"name":"Tavily","replaces":"https://api.tavily.com"},{"name":"Exa","replaces":"https://api.exa.ai"},{"name":"Bing Web Search API v7","replaces":"https://api.bing.microsoft.com/v7.0/search"}]}Get a key under Agents & API at specstream.ai/workspace. A new account gets $2 of credit with no card, which is 2,000 fast searches.
curl -H "Authorization: Bearer $SPECSTREAM_API_KEY" "http://localhost:8787/search?q=cloudflare+workers+ai+pricing"
curl -H "Authorization: Bearer $SPECSTREAM_API_KEY" "http://localhost:8787/extract?url=https://developers.cloudflare.com/workers/"
curl "http://localhost:8787/customsearch/v1?key=$SPECSTREAM_API_KEY&q=best+crm+for+startups"Then npx wrangler deploy.
The worker runs in one of two ways, and the key never sits in wrangler.toml.
- Pass through (no secret set): each caller sends their own SpecStream key exactly as the API they speak expects it,
Authorization: Bearer,key=,Ocp-Apim-Subscription-Keyorx-api-key, and the worker forwards it unchanged. - Your key (for your own apps and agents): set two secrets. The worker then calls SpecStream with its key, only for callers that send the token.
npx wrangler secret put SPECSTREAM_API_KEY
npx wrangler secret put PROXY_TOKEN
curl -H "x-proxy-token: $PROXY_TOKEN" "https://specstream-edge.<you>.workers.dev/search?q=..."With your key set and the worker on a custom domain (Cloudflare gives Workers on custom domains a working Cache API), /search replies are kept in the edge cache for SEARCH_CACHE_SECONDS (300 by default), so a repeated query in that window answers from the nearest Cloudflare location with x-edge-cache: HIT and is not charged again. Pass through mode never caches, so one caller's paid reply never reaches another.
- https://www.googleapis.com/customsearch/v1?key=GOOGLE_KEY&cx=CX&q=...
+ https://specstream-edge.<you>.workers.dev/customsearch/v1?key=SPECSTREAM_KEY&q=...
- https://api.bing.microsoft.com/v7.0/search
+ https://specstream-edge.<you>.workers.dev/v7.0/searchGoogle ends the Custom Search JSON API on January 1, 2027, and Microsoft retired the Bing Search APIs in August 2025. Errors come back in each API's own shape, so a Bing client still reads InvalidAuthorization and a Google client still reads error.code.
| Price | |
|---|---|
| Free credit on sign-up | $2, which is 2,000 fast searches, no card |
| Fast search, every drop-in route | $1 per 1,000 |
| Extract API, page text as Markdown | $0.80 per 1,000 pages |
| Monthly Pro Pass | $49 a month: 5,000 ready list rows a month and $49 of API credit |
- Search API: specstream.ai/search-api
- Extract API: specstream.ai/extract-api
- Moving from Google Custom Search: specstream.ai/migrate/google-cse
- Moving from Bing Web Search v7: specstream.ai/migrate/bing-web-search-v7
- Every drop-in API: specstream.ai/migrate
- Prices: specstream.ai/pricing
MIT