A durable counterpart to POST /v1/chat/completions. Use it when a single chat turn
may run long, call multiple tools, hit a safety gate, or require human cost approval before
spending Spark. The server persists the run, streams typed events over SSE, and exposes
cancel + cost-approval primitives. Status values:
queued, running, completed, partial_failure,
waiting_for_user, failed, cancelled.
POST/v1/chat/runsAuth required
Start a durable chat run. Returns 202 Accepted on first submission, 200 OK with idempotent: true when an idempotency key matches an existing run.
Optional durable media references. All durable URLs must be externally addressable.
media_context
object
body
Optional initial media context: images[], videos[], audio[], plus uploadedImages[] / uploadedVideos[] / uploadedAudio[] for caller-supplied uploads.
max_estimated_capacity_units
number
body
Recorded on the request snapshot so callers can surface the ceiling alongside the run. Not currently enforced server-side on chat runs.
confirm_cost
boolean
body
Recorded on the request snapshot. To actually pause chat runs for cost approval, set runtime_config.requireJobConfirmation: true (see below) — paid media tool calls will then emit run_awaiting_cost_confirmation SSE events and wait for confirm-cost.
session_id
string
body
Optional caller session identifier.
client_message_id
string
body
Optional caller message identifier — useful for client-side correlation.
token_type
string
body
spark, sogni, or auto.
app_source
string
body
Optional caller label.
runtime_config
object
body
Run-time tuning. Fields: qualityTier (fast|hq|pro), safeContentFilter (bool), personaNames (string[]), requireJobConfirmation (bool — set true to pause before each paid media tool dispatch), jobConfirmationThresholdUsd (number — skip pause when estimate is below this).
Server-Sent Events stream. Replays persisted events, then polls for new ones until the run reaches a terminal status (completed, failed, partial_failure, cancelled). Supports Last-Event-ID for resume and ?after=<sequence>.
Cooperative cancel. Flips the run to cancelled, halts any in-flight tool calls owned by the run, and appends a run_cancelled event so any SSE listeners see the transition.
Resume a run that paused with waiting_for_user + cost_approval_required. Records the caller's decision, flips the run back to running, and dispatches the held tool calls.
ID of the paused tool call (from the run_awaiting_cost_confirmation event).
decision*
string
body
"confirm" or "cancel".
acceptedCostPreview*
object
body
Required for decision: "confirm" (alias accepted_cost_preview). Echo the preview from the run_awaiting_cost_confirmation / billing_preview_updated event — { totalEstimatedCapacityUnits, tokenType, validityUntil }. totalEstimatedCapacityUnits is compared against the persisted snapshot; a stale or expired preview returns 409 (a missing or malformed object returns 400).
overrides
object
body
Optional allowlisted edits applied to the held tool call on resume — qualityTier (fast/hq/pro), safeContentFilter, and prompt/prompts. Prompt edits are cost-neutral; cost-inflating keys are silently dropped.
reason
string
body
Optional caller-supplied reason recorded with the decision.
idempotency_key
string
body
Optional. Idempotency-Key / X-Idempotency-Key headers also accepted.
Insufficient-credits and safety-review pauses cannot be resumed via confirm-cost. Insufficient-credits requires topping up + a fresh run; safety-review requires POST /cancel to release the run. The API returns 409 with a routing message in either case.