Search the live web and read pages from BigQuery SQL. One Cloud Run function answers BigQuery's remote function calls with SpecStream, and three SQL functions put cited rows next to your tables:
SELECT
company_name,
JSON_VALUE(`my-project.specstream.web_search`(CONCAT(company_name, ' careers page'), 3), '$.sources[0].url') AS careers_url
FROM `my-project.crm.companies`;| SQL function | SpecStream call | Returns (JSON) |
|---|---|---|
web_search(q, num) |
POST /v1/web-search, fast tier |
sources: rank, url, title, site, snippet, published; and price_usd |
web_answer(q) |
POST /v1/web-search, default tier |
value, the page it was read from, sources, price_usd; value is null when no page states one |
read_page(url, query) |
POST /v1/extract |
url, status, title, published, text as Markdown (query keeps only the passages that answer it) |
BigQuery sends up to max_batching_rows calls in one request. remote.py answers them in order and:
- sends each distinct call once, so a value repeated over many rows is paid once;
- runs
SPECSTREAM_CONCURRENCYcalls at a time (4 by default, at most 16); - answers a NULL or empty argument with a NULL and no call;
- waits and sends a call again when SpecStream answers 503 or 429 with
Retry-After, and answers the batch with HTTP 503 if it stays busy, which BigQuery retries; - answers a refused key with HTTP 400 and the reason, which BigQuery shows and does not retry.
The handler is the standard library plus functions-framework, and specstream_client.py is the whole SpecStream client.
# 1. The key, in Secret Manager (get one at https://specstream.ai/workspace; $2 of credit, no card)
printf %s "$SPECSTREAM_API_KEY" | gcloud secrets create specstream-api-key --data-file=-
# 2. The function
gcloud functions deploy specstream --gen2 --runtime=python312 --region=us-central1 \
--source=. --entry-point=specstream --trigger-http --no-allow-unauthenticated \
--set-secrets=SPECSTREAM_API_KEY=specstream-api-key:latest --max-instances=5
# 3. The BigQuery connection, allowed to call the function
bq mk --connection --location=US --project_id=my-project --connection_type=CLOUD_RESOURCE specstream_conn
SA=$(bq show --format=json --connection my-project.us.specstream_conn | python3 -c "import json,sys; print(json.load(sys.stdin)['cloudResource']['serviceAccountId'])")
gcloud functions add-invoker-policy-binding specstream --region=us-central1 --member="serviceAccount:$SA"- Run
sql/01_functions.sqlwith your project, region and function URL, then trysql/02_enrich.sql.
A 1,000 row table through web_search is 1,000 fast searches, $1. read_page uses max_batching_rows = 20, since each page read can take up to 30 seconds.
python -m unittest discover -s tests -v
pip install -r requirements.txt -r requirements-dev.txt # adds the Cloud Run entry point test and the SQL lint
sqlfluff lint sql/The tests send BigQuery shaped batches to remote.handle against a local stand-in for the API (tests/mock_specstream.py): replies kept in call order, repeats sent once, NULL arguments, sources with null title, site, snippet and date, a search with no sources, an answer with no value, a blocked page with no text, a 503 sent again, and a made up key refused with 401 and answered to BigQuery as 400. With functions-framework installed they also post a batch through the deployed entry point. They need no key and spend nothing. The SQL lints with SQLFluff 4.5 in the BigQuery dialect; its grammar has no REMOTE WITH CONNECTION yet, so each CREATE FUNCTION line carries a noqa.
| 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).
- BigQuery remote functions: cloud.google.com/bigquery/docs/remote-functions
- Search API: specstream.ai/search-api
- Extract API: specstream.ai/extract-api
- API reference: specstream.ai/docs/api
- Prices: specstream.ai/pricing
- Get a key: specstream.ai/workspace
MIT