Tether
DocsPricingContactGet started

API reference

Streaming

The same turn as /v1/chat, delivered as server-sent events. Same tools, same prompts, same staged actions on the completion frame.

POST /v1/chat/stream

The request body and headers are identical to /v1/chat, including X-Tether-Customer-Token for a verified customer; a token that does not verify is refused with 401 invalid_customer_token and its reason before any frame is sent, and X-Tether-Upstream-Token for the signed-in person's own API token, refused as malformed with 400 invalid_upstream_token before any frame is sent. The response is text/event-stream with Cache-Control: no-cache and X-Accel-Buffering: no.

Frames

Every frame is a single data: line containing JSON, terminated by a blank line. There are no named SSE event types — branch on the type field.

data: {"type":"agent_start","agent":"coordinator","label":"Understanding request"}

data: {"type":"message","task":"synthesis","label":"Preparing answer"}

data: {"type":"chunk","text":"Seven tickets are"}

data: {"type":"chunk","text":" still open."}

data: {"type":"complete","raw":"{…}","sessionId":"0f2c…","requestId":"7d1e…","response_id":"resp_9f1c…","pendingActions":[]}
typeFieldsMeaning
chunktextA fragment of the answer as it generates. Concatenate in order.
completeraw, sessionId, requestId, response_id, pendingActionsThe terminal frame. raw is the full block document as a JSON string, including handoff when the turn was handed to a person. response_id is null when the turn made no model call, and when its last model call ended with tool calls that were not run.
cardsblockSent right after a catalogue search that found items, before the model has written its answer. block is a cards block built from the search result, with its links, photos and prices checked the same way as the final answer's. A turn that searches more than once sends one per search; show the latest. It is a preview: the complete frame is authoritative, so replace it with the final blocks rather than adding them below it. Safe to ignore.
errormessage, optional code, optional retryAfterSecondsTerminal. No complete follows.
agent_start / agent_completeagent, label, latencyMsProgress. Safe to ignore.
task_start / task_completetask, label, latencyMsProgress. Safe to ignore. One pair per tool call: task is the tool's name, the label Running <tool>, and task_complete carries how long the call took.
messagetask, labelProgress. Safe to ignore.

The completion frame

raw is the string form of the same document /v1/chat returns, so it needs a second parse:

const es = new EventSource('/api/assistant/stream')   // your backend proxies to Tether

let text = ''
es.onmessage = (e) => {
  const frame = JSON.parse(e.data)

  switch (frame.type) {
    case 'chunk':
      text += frame.text
      renderPartial(text)          // optimistic prose while the turn runs
      break

    case 'cards':
      renderEarlyCards(frame.block)       // optional: items while the answer is written
      break

    case 'complete': {
      const doc = JSON.parse(frame.raw)   // the block document
      renderBlocks(doc.blocks)            // authoritative — replaces the partial text and early cards
      setSession(frame.sessionId)
      renderPendingActions(frame.pendingActions)
      es.close()
      break
    }

    case 'error':
      renderError(frame)
      es.close()
      break
  }
}

Note the field naming: the streaming frame uses sessionId and pendingActions (camelCase), where the buffered response uses session_id and pending_actions. This is an inconsistency, not a subtlety — the buffered document inside raw keeps its snake_case fields.

Chunks are prose, blocks are the answer

The chunk stream is the model's raw output on its way to becoming the block document. Render it if you want the typing effect, but treat the complete frame as authoritative: validation, repair and fallback all happen at the end, and the final blocks may not match the streamed text verbatim.

If you only need the answer, ignore chunk entirely and render on complete.

A turn that calls tools streams too. Each model call in its tool loop is read as it is written, and chunk frames carry the text of the call that writes the answer as it arrives, after the task_* frames and any cards frame. A call that only asks for a tool sends no chunk, and neither does one that opens with prose instead of the block document, so the chunks of a tool turn add up to the block document as the model wrote it. When nothing was streamed, because the provider answered in one piece or the answer was not a block document, the whole answer arrives as one chunk just before complete.

The chunks of a block document are JSON, not prose. To show text while it arrives, read the markdown of each text block out of the partial JSON: a reader that tolerates a cut-off string and a cut-off escape (\u10d, a lone \) is enough, and it is what the installed widget and the preview console do, showing that text under the early cards until complete replaces both.

Error frames

{ "type": "error", "code": "RATE_LIMITED", "message": "The AI service is handling too many requests right now. Please try again in a few seconds.", "retryAfterSeconds": 3 }
codeRetryableMeaning
RATE_LIMITEDyes, after retryAfterSecondsThe upstream provider throttled the turn. retryAfterSeconds is the wait the provider asked for, 1 to 300, and null when it named none
PLAN_QUOTA_EXCEEDEDyes, after retryAfterSeconds (3600)A free tenant used its daily request quota, Quota:FreePlanRequestsPerDay. No model was called. The buffered path answers the same refusal with 429 plan_quota_exceeded
ORG_DAILY_BUDGET_EXCEEDEDat the next UTC dayThis tenant's daily spend cap
ORG_MONTHLY_BUDGET_EXCEEDEDat the next UTC monthThis tenant's monthly spend cap
GLOBAL_DAILY_BUDGET_EXCEEDEDoperator decisionPlatform-wide daily cap
GLOBAL_MONTHLY_BUDGET_EXCEEDEDoperator decisionPlatform-wide monthly cap
AI_UNIFIED_PROVIDER_QUOTA_EXHAUSTEDoperator decisionThe deployment's provider account has no quota left
(no code)noOut of scope, an unclassified provider failure, or a provider that sent nothing for AI:Unified:TimeoutSeconds (60s) mid-answer

An error frame is terminal. The HTTP status is already 200 — the stream opened before the failure was known — so a client that only inspects status codes will report success on a failed turn. It can follow chunk frames: when the provider fails a round after some of the answer was already sent, the stream ends with the error frame and no complete, so discard the text shown so far.

A sessionId this guest may not continue is refused before the stream opens: 403 with a JSON body, { "error": { "code": "session_not_yours", "reason": … } }, exactly as on /v1/chat.

Parity with the buffered path

Same routing, same ceilings, same tool loop, same validation, same ledger rows: one per model call, sharing the complete frame's requestId. A turn that stages a write on /v1/chat stages it identically here and returns it in pendingActions on the completion frame.

The differences are the frame shapes above and the fact that an error arrives inside a 200 response. When a model call fails partway through the tool loop, neither door calls the model again: /v1/chat answers with its provider-error document, still carrying any write the turn staged, and the stream ends with an error frame. A provider rate limit, an authentication failure or an exhausted provider quota ends the turn the same way: /v1/chat answers at once, still carrying any staged write, and the stream sends its error frame. An error frame carries no pendingActions: a write the turn staged before it is still pending, and your backend finds it with GET /v1/actions. A stream the provider itself fails ends the same way, with RATE_LIMITED when the provider reported a rate limit and no code otherwise, and no complete frame follows. Both doors retry a transient provider failure once, the stream only before its first byte.

Proxying

Terminate the stream on your own backend and forward frames to the browser. Two reasons: the API key must never reach a browser, and buffering proxies between you and the client will otherwise defeat the streaming entirely. X-Accel-Buffering: no is set on Tether's response — set the equivalent on yours.