Documentation menu and search

API reference

SSE streaming

Handle text deltas, completion and usage events correctly.

Enable streaming

Send stream true in a Chat request. The gateway sets the necessary stream_options to include usage information.

Python

stream = client.chat.completions.create(
    model="siber-v3",
    messages=[{"role": "user", "content": "Kısa bir test planı yaz."}],
    max_tokens=1024,
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Parse boundaries correctly

A network chunk may contain part of a UTF-8 character or several SSE events. Accumulate data lines until an event boundary; handle completion markers and errors. Tool arguments may also arrive in pieces.

Cancellation and interruption

Client cancellation is passed to the internal request. Partial content may already have been generated; do not assume an interrupted request was free or never ran. Missing usage may require reservation reconciliation.

Telegram support@cyberdef_tr