Skip to navigation

Agents

Use natural language to write quantum algorithms and learn quantum computing.

The agents endpoint connects you to Coda’s unified AI agent, which writes quantum circuits in the framework you request (defaulting to Qiskit), simulates and formally verifies them when useful, explains quantum computing concepts, and assists with quantum computing workflows. Responses are streamed back as server-sent events (SSE).

Example

from conductorquantum import ConductorQuantum
client = ConductorQuantum(token="<your-api-key>")
for event in client.coda.agents.run(
messages=[{"role": "user", "content": "Create a 3-qubit GHZ state circuit in Qiskit"}],
):
print(event)

The response is streamed. Each event contains a type field (for example token, thinking_token, tool_call, tool_result, files, completed, or error) and associated data. The stream always ends with a terminal completed, error, or cancelled event.

Effort budget

The budget field controls how much effort the agent spends on a request: low, medium, or high (default). Lower budgets scale down the model’s thinking effort, max output tokens, step limit, and parallel research-subagent pool, trading some response quality for speed and cost.

for event in client.coda.agents.run(
messages=[{"role": "user", "content": "Explain the quantum Fourier transform"}],
budget="low",
):
print(event)

Code delivery

The code_mode field controls how the agent delivers final code:

code_modeBehaviour
inline (default)Final code is streamed in token events as a fenced markdown code block with the canonical framework language tag, followed by the completed event.
fileThe agent writes code to a virtual filesystem instead. Written files are streamed back in a files event just before the terminal completed event. Its data.files maps each file path to its contents.

Conversation threads

Pass a thread_id to continue a previous conversation:

{
"messages": [
{"role": "user", "content": "Now add a measurement to all qubits"}
],
"thread_id": "<thread-id-from-previous-response>"
}

The X-Thread-Id response header contains the thread ID for new conversations.

Team billing

Pass team_id to bill an Enterprise team wallet. Wallet selection, 400 / 402 behaviour, and service-account keys are on Teams and team wallets.

for event in client.coda.agents.run(
messages=[{"role": "user", "content": "Write a Bell circuit in Qiskit"}],
team_id="<team-id>",
):
print(event)

Response headers

The SSE response includes:

X-Run-Id: <new run UUID>
X-Thread-Id: <new or supplied thread ID>
X-Team-Id: <supplied team ID, if any>

Store X-Run-Id and X-Thread-Id to look up settled cost after the stream ends.

Post-hoc cost

Internal checkpoint, tracing, and cost-accounting data are not included in terminal SSE payloads. After the run finishes, look up the settled credit charge with the usage API using X-Run-Id or X-Thread-Id.

thread_id is attached best-effort after authorisation. A charge can settle with thread_id null. Do not treat a thread rollup as the complete ledger.

Deprecated fields

The mode and fast request fields are deprecated. They are still accepted for now, but new integrations should omit them.

  • mode: previously selected between separate build and learn agents. These have been replaced by the unified agent, and all values (agent, build, learn) now route to the same agent. Omit the field.
  • fast: previously requested a faster model for lower latency. The unified agent ignores this flag; use budget to trade quality for speed instead.
  • POST /agents: chat with the Coda AI agent
  • GET /agents: list available agents
  • GET /usage/runs/{run_id}: settled cost for X-Run-Id

See the Coda API Reference for full request and response schemas.