Skip to content

Streaming

pokkit supports server-sent events (SSE) streaming via the standard OpenAI "stream": true parameter.

Enabling streaming

Add "stream": true to your request body:

1
2
3
4
5
6
7
8
curl https://api.pokkit.dev/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Tell me a short story."}],
    "stream": true
  }'

pokkit forwards the stream directly from the upstream provider, so the response arrives as a series of data: SSE events in the OpenAI format:

1
2
3
4
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Once"},...}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":" upon"},...}]}
...
data: [DONE]

Using with the OpenAI SDK

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from openai import OpenAI

client = OpenAI(
    api_key="<YOUR_API_KEY>",
    base_url="https://api.pokkit.dev/v1",
)

with client.chat.completions.stream(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Tell me a short story."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Current limitations

Pass-through only

Streaming responses are passed through from the upstream provider without modification. pokkit does not buffer, transform, or normalize SSE events across providers. The event format you receive depends on the upstream — in practice, all three supported providers emit OpenAI-compatible chunks for streaming, but edge-case differences may exist.

Future releases will add normalized streaming so the event format is consistent regardless of provider.