Skip to Content
REST APILong-running requests

Long-running requests

Most answers take 10 to 30 seconds, but some take over a minute. A plain request waits up to 90 seconds and then fails with 503 upstream_timeout and a Retry-After header. For longer questions, stream the answer.

Streaming an answer

Add "stream": true to POST /v1/questions. The response is a server-sent event stream  that waits up to 150 seconds:

curl -N https://platform.teroatlas.ai/v1/questions \ -H "Authorization: Bearer $TERO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"question": "Compare median household income and education across all Texas districts", "stream": true}'
  • A comment line (starting with :) arrives at once and every 15 seconds while the answer is prepared. It keeps the connection open through proxies; ignore it, or use it to show progress.
  • The stream ends with one event: result, whose data is the same body a plain request returns, or error, whose data is the error body.
: keep-alive : keep-alive event: result data: {"message_id":"m7b2c4d6-1a3e-4f5a-8b9c-0d1e2f3a4b5c","conversation_id":"c3a1f0d2-6c55-4b8e-9d0a-1f2e3d4c5b6a","answer":"…"}

The stream opens only when the question reaches the analysis service. A request turned away before that, for example an invalid body (400), an unknown conversation (404), a full conversation (409) or a rate or quota limit (429), gets a plain JSON error with that status instead. Closing the connection cancels the question.

The TypeScript SDK does this with stream: true, and still returns the whole answer.

Derived outputs (charts, maps, reports, SQL explanations) are not streamed and wait up to 90 seconds.

When an answer takes too long

upstream_timeout means no answer arrived in time. When the analysis service stopped a slow query itself, message says so and suggests what to change, for example “Query timed out after 60 seconds. Narrow the filters (e.g. a specific year or geography)…”. Asking the same question again unchanged is likely to time out again: narrow it first. A streamed answer reports the same error as its final error event.

Timeouts in your client

Allow at least 100 seconds for a plain request and 180 seconds for a stream before your HTTP client gives up.

MCP

The MCP server streams every tool call that uses the analysis service, so assistants don’t need to do anything.

Last updated on