Skip to navigation

Run Agent

Chat with the unified Coda AI agent to write, debug, and optimise quantum circuits or explain quantum computing concepts. Responses are streamed as server-sent events (SSE). Optional team_id bills an Enterprise team wallet. Personal tokens bill the personal wallet unless team_id is set. Team service-account keys always bill their team. A mismatched team_id returns 400. There is no fallback to the personal wallet. Response headers include X-Run-Id, X-Thread-Id, and X-Team-Id (when a team is billed). Settled cost is not in the SSE payload; look it up with the usage API.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Headers

x-api-pathstring or nullOptional

Request

This endpoint expects an object.
messageslist of objectsRequired
Conversation messages
thread_idstring or nullOptional
Thread ID for conversation continuity
team_idstring or nullOptional

Optional Enterprise team wallet to bill. Personal tokens bill the personal wallet unless team_id is set. Team service-account keys always bill their team (omitting team_id does not switch to personal billing). A mismatched team_id returns 400. A short team wallet returns 402 with no fallback to the personal wallet.

code_modeenumOptionalDefaults to inline

‘inline’ (default): the agent streams final code as fenced markdown tokens with the canonical framework language tag. ‘file’: the agent writes code to a virtual filesystem instead; written files are streamed back in a terminal ‘files’ SSE event.

Allowed values:
budgetenumOptionalDefaults to high

Agent effort budget. ‘low’, ‘medium’, and ‘high’ (default) scale the model’s thinking effort, max output tokens, step limit, and parallel research-subagent pool.

Allowed values:
fastbooleanOptionalDefaults to falseDeprecated

Deprecated compatibility flag; ignored by the unified agent

modeenumOptionalDefaults to agentDeprecated
'agent' is the unified Coda agent. 'build' and 'learn' are deprecated aliases.
Allowed values:

Response

Server-sent event stream. Each event is a JSON object with a type field. With code_mode: "inline" (default), final code is streamed in token events as a complete fenced markdown block with the canonical framework language tag, followed by completed. With code_mode: "file" the agent writes code to a virtual filesystem instead, and a terminal files event carries data.files mapping each file path to its contents.

Errors

422
Unprocessable Entity Error