Skip to main content
Agent Spark is a beta Spark API endpoint that streams a chat response as Server-Sent Events (SSE). Instead of waiting for one JSON response, you receive the answer in stages: provisional thinking text, the sources Spark used, cited insights, and a finished Markdown answer. Use Agent Spark when end users or agents ask open-ended questions and you need progress, citations, and a finished Markdown answer in one stream. The v1 /v1/spark-api/generic endpoint is a separate, narrower tool: it returns one JSON payload, but only tends to produce meaningful insights when the prompt is deliberately structured (audience, question, and often dataset or timeframe). See Structuring a Query and the Quickstart for that pattern.
Agent Spark is in beta. The request and event formats can change.

Agent Spark and /v1/spark-api/generic

Both endpoints accept the same core chat payload: a required prompt, plus optional chat_id, dataset_code, dataset_codes, and docked_audiences. They share authentication and the same insight engine, but they solve different product problems. Choose generic for repeatable, backend-driven lookups where you invest in prompt design once. Choose Agent Spark for chat surfaces, copilots, and agents where you cannot enforce that prompt shape on every request.

Send a request

Send a POST request to /beta/spark-api/agents/spark with the same Authorization header you use for other Spark API requests. Keep the connection open to read the stream.

Request body

For more on dataset scoping, see Working with multiple data sets.

Read the stream

A successful request returns 200 with Content-Type: text/event-stream. Each frame has an event name and a JSON data payload that includes the chat_id. Events arrive in this order:
To ask a follow-up question, send a new request with the chat_id from the stream.

Handle errors

Agent Spark reports errors in two ways, depending on whether the stream has started. Before the stream starts, the API returns a JSON error response with an HTTP status code: Agent Spark-specific errors include code, message, and retryable fields, and chat_id when you provided one:
After the stream starts, a terminal failure arrives as an error event with the same code, message, and retryable fields. No end event follows an error event, so treat error as the end of the stream.
If retryable is true, you can retry the request.