Skip to documentation
deepthroat
DocsAPI reference
DEEPTHROAT DEVELOPER GUIDE

Streaming

Receive text as it is generated using server-sent events.

On this pageEnable streamingRead eventsHandle interruptions

Enable streaming

bash
curl -N "https://api.cheapai.gay/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.1-sol","messages":[{"role":"user","content":"Hello."}],"stream":true,"stream_options":{"include_usage":true}}'

Read events

Parse server-sent events incrementally. For OpenAI-format text, append choices[0].delta.content; reasoning uses delta.reasoning_content. The final marker is [DONE].

json
{
  "choices": [
    {
      "index": 0,
      "delta": {
        "content": "Hello"
      },
      "finish_reason": null
    }
  ]
}

Chunks may contain only usage, finish information, or a partial tool call. Anthropic Messages uses named events such as content_block_delta and message_stop.

Handle interruptions

Keep track of whether the stream completed or disconnected. Cancel an unneeded request through your client’s abort mechanism. An interrupted response is partial output; a fresh request is a new generation.

Check what your harness already changed before retrying a partially executed tool task.