Goal: after a successful non-streaming call, enable SSE streaming in about five minutes.

Prerequisites

You completed First request and have API_KEY and MODEL_ID.

curl example

curl -sSN "https://51kik.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "model": "'"$MODEL_ID"'",
    "stream": true,
    "messages": [{ "role": "user", "content": "Explain streaming in three sentences" }]
  }'
ItemValue
streamtrue
Accepttext/event-stream
curl -NDisable buffering for live output

Reading SSE

Each line looks like:

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

Termination:

data: [DONE]

A chunk with usage may appear near the end (gateway forces include_usage on streams). Details: Streaming.

Client pitfalls

IssueMitigation
Proxy buffers entire responseproxy_buffering off on nginx
Idle timeout mid-generationIncrease proxy read timeout
Chunk JSON contains errorTreat as failure

Official SDK

const stream = await client.chat.send({
  chatRequest: {
    model: "YOUR_MODEL_ID",
    stream: true,
    messages: [{ role: "user", content: "Hello" }],
  },
});
for await (const chunk of stream) {
  // OpenAI-shaped chat.completion.chunk
}

See Chat and streaming.

Anthropic surface

Streaming Messages: POST https://51kik.com/anthropic/v1/messages with stream: true. See Create message.