Skip to content

About

Cloudflare Workers TypeScript starter for live web search, Markdown extraction and drop-in Google Custom Search, Bing v7, Tavily and Exa routes at the edge, with edge caching. $1 per 1,000 searches.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

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.

Run

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.

Keys

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-Key or x-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.

Moving Google CSE or Bing code you already have

- 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/search

Google 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.

Prices

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

Links

License

MIT

About

Cloudflare Workers TypeScript starter for live web search, Markdown extraction and drop-in Google Custom Search, Bing v7, Tavily and Exa routes at the edge, with edge caching. $1 per 1,000 searches.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages