Dispatch a Retrieval Agent run
Dispatch a Retrieval Agent run — agentic data retrieval returning structured outputs and cards
structured_output) plus visualization cards and a cited answer. Use it for questions that need real retrieval work — resolving a cohort, ranking or filtering a set, multi-hop aggregation.
See the Retrieval Agent guide for examples, structured outputs, streaming, threads, and sources.
Notes
- To authenticate, send your Tako API key in the
X-API-Keyheader. Store it as an environment variable rather than hardcoding it. - The agent is asynchronous: this endpoint returns
202with aRetrievalAgentRunwhosestatusisqueued. Poll Poll a Retrieval Agent run untilstatusiscompletedorfailed. - To stream progress live instead of polling, send
Accept: text/event-stream. The response is then a Server-Sent Events stream ofRetrievalAgentStreamEnvelopeevents. See the coding-agent reference.
Structured output
Pass anoutput_schema (JSON Schema) to get machine-usable JSON in result.structured_output. Mark a property with "x-tako-dataset": true to request a dataset slot, filled with exact retrieved rows. Supported subset: object/array/string/number/integer/boolean, enum, required, description. Caps: 16 KB, depth 5, 64 properties, 4 dataset slots — violations return 400 output_schema_invalid.
Choosing sources
source_indexes is optional and defaults to ["data", "web"] — both. Pass it only to restrict: ["data"] (curated knowledge graph only) or ["web"] (open web only). The legacy value "tako" is a synonym for "data".
Continuing a thread
Pass thethread_id from a prior run to ask a follow-up in the same conversation. Omit it to start a new thread. A thread is pinned to the Retrieval Agent and to one set of source_indexes.Authorizations
Body
Request body for POST /v1/agent/retrieval/runs.
Natural-language data-retrieval request for the retrieval agent.
"S&P 500 semiconductor companies' 2024 revenue and YoY growth"
Existing thread to continue (follow-up). Omit to start a new thread.
Retrieval-agent effort. Only 'medium' is currently supported.
medium Which sources the agent may use: 'data' (curated knowledge), 'web' (open-web search), or both. Defaults to ['data', 'web']. Tako accepts the legacy value 'tako' as a synonym for 'data'.
data, web Whether the agent may build visualization cards. The default is true and permissive: the agent may build cards, but it does not have to (a completed run with no cards is legitimate). Set false to suppress card building entirely.
JSON Schema for structured output. The agent writes the synthesized fields. Dataset slots (marked with x-tako-dataset: true) receive exact retrieved rows as a TakoDataset. Supported subset: the object, array, string, number, integer, and boolean types, plus enum, required, and description. Caps: 16KB, depth 5, 64 properties, 4 dataset slots. Violations return 400 output_schema_invalid.
BCP-47 locale. Drives the language of the agent's answer and the locale used when rendering card preview images. Defaults to en-US.
IANA timezone (for example, 'America/New_York'). The agent uses it to render dates and times in card preview images. It does not affect the returned data.
Settings that control the response and rendering.
Response
Run dispatched. With Accept: application/json, poll GET /v1/agent/retrieval/runs/{run_id} for the run status. With Accept: text/event-stream, the response is an SSE stream of RetrievalAgentStreamEnvelope events. The stream ends at stream_done. If the stream ends without an agent_result event, poll GET /v1/agent/retrieval/runs/{run_id} for the terminal status.
The retrieval-agent run resource returned by dispatch (202) and poll (GET).
queued, running, completed, failed "agent.retrieval.run"Final retrieval-agent output. answer is markdown prose with [n] citation markers. cards reuse the sibling TakoCard. citations is the unified top-level registry for data and web sources — there is no web_results field. metadata carries definitions, assumptions, and methodology. The structured_output_* fields carry the caller-shaped output_schema result; they are present only if the request supplied output_schema. See each field's description for the exact presence rules.
Usage for one metered request. total_cost_usd is always present (the
total quoted charge). compute and data are the additive breakdown;
each appears only where it applies. total_cost_usd always equals the sum
of the components that appear.
Request body for POST /v1/agent/retrieval/runs.