Skip to content

About

Serverless parallel web research on Modal: SpecStream searches ($1 per 1,000) and page reads as Markdown ($0.80 per 1,000) fanned out across containers, rate safe, every answer with its source URLs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Serverless parallel web research on Modal with SpecStream

Research hundreds of questions at once: Modal fans the calls out across containers, SpecStream searches the live web and reads the best pages as Markdown, and every answer line keeps its source URLs.

pip install -r requirements.txt
modal secret create specstream SPECSTREAM_API_KEY=...     # https://specstream.ai/workspace, $2 of credit with no card
modal run app.py --questions-file questions.txt --pages 3

It ends with a line like this one, for 3 questions with 3 pages read each:

3 questions, 9 pages read, $0.0102 -> answers.jsonl

For each question, app.py runs one search in its own container (search_one.map), then reads that question's top pages in one Extract call (read_batch.map), at most 16 containers at once. Each line of answers.jsonl holds the question, its ranked sources (url, title, site, snippet, published), the pages read (url, title, published, text), the unread URLs (blocked or missing pages) and its cost_usd.

Step SpecStream call Price
search_one POST /v1/web-search, fast tier, 10 results $1 per 1,000 questions
read_batch POST /v1/extract, the top pages with the question as the query, so each page keeps the passages that answer it $0.80 per 1,000 pages read

1,000 questions with 3 pages each cost $1 for the searches and $2.40 for the pages.

Rate safe fan out

  • When the account has used its calls for the minute, SpecStream answers 503 with Retry-After; the call waits that long and sends again, inside its container.
  • A call that still fails is retried by Modal (modal.Retries, twice, with backoff). A search that failed was never paid, and an extract retry carries the same Idempotency-Key, so a page is paid once.
  • MAX_CONTAINERS in app.py caps how many calls run at once.

Without Modal

research.py is the same pipeline on a local thread pool, with only the standard library:

export SPECSTREAM_API_KEY=...
python research.py questions.txt --pages 3 --workers 8 > answers.jsonl

Test

python -m unittest discover -s tests -v

The tests run the pipeline against a local stand-in for the SpecStream API (tests/mock_specstream.py): in order and on a pool shaped like Modal's .map, with repeated and blank questions, sources with null title and date, a question with no sources (and so no read), a blocked page listed as unread, a 503 sent again, a made up key refused with 401, and the command line writing JSON lines. With modal installed they also load app.py and check its two functions and entrypoint. They need no key, no Modal account, and spend nothing. Tested with modal 1.7.0 on Python 3.12.

Prices

Price
Fast search (speed: "fast"), up to 10 results $1 per 1,000 searches, 937 ms median over 6,548 live calls in the 7 days to December 1, 2026
Default search, with a cited answer when the question has one $5 per 1,000 searches
Extract, a page read as Markdown $0.80 per 1,000 pages read
Free credit on sign up $2, which is 2,000 fast searches or 2,500 pages read, no card
Monthly Pro Pass $49 a month: 5,000 ready list rows a month and $49 of API credit

SpecStream is the live web data engine: first on WideSearch and 99 on SimpleQA Verified (benchmarks).

Links

License

MIT

About

Serverless parallel web research on Modal: SpecStream searches ($1 per 1,000) and page reads as Markdown ($0.80 per 1,000) fanned out across containers, rate safe, every answer with its source URLs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages