Docs
Capabilities

Streaming

Stream responses token by token over Server-Sent Events

Set stream: true to receive the reply as Server-Sent Events instead of one final JSON body.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.ablatic.ai/v1",
    api_key="sk-ablatic-...",
)

stream = client.chat.completions.create(
    model="talos",
    messages=[{"role": "user", "content": "Write a haiku about Linz."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Both API surfaces stream over SSE, but the event format differs. SSE responses set Cache-Control: no-cache.

OpenAI surface

On /v1/chat/completions each event is a chat.completion.chunk. The incremental text rides in choices[0].delta. The stream terminates with a data: [DONE] line.

data: {"object":"chat.completion.chunk","choices":[{"delta":{"content":"Lin"}}]}

data: {"object":"chat.completion.chunk","choices":[{"delta":{"content":"z"}}]}

data: [DONE]

Anthropic surface

On /v1/messages the stream is a sequence of named events, the same graph the Anthropic SDK expects: message_start, then content_block_start, then one or more content_block_delta, then content_block_stop, then message_delta, then message_stop. There is no [DONE] terminator.

event: message_start
data: {"type":"message_start","message":{"id":"msg_..."}}

event: content_block_start
data: {"type":"content_block_start","index":0}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Linz"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"}}

event: message_stop
data: {"type":"message_stop"}

The OpenAI stream ends with data: [DONE]. The Anthropic stream ends with a message_stop event and never sends [DONE].

Next