Streaming
Server-sent events, why time to first token is the number that matters, and how streamed calls are metered.
Set stream: true and the response arrives as server-sent events instead of one
JSON object.
curl -N "https://api.webway.example/v1/chat/completions" \
-H "Authorization: Bearer $WEBWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.6-luna",
"messages": [{"role": "user", "content": "Count to five."}],
"stream": true
}'
Each event is a data: line holding a chunk, and the stream ends with
data: [DONE]. Any OpenAI-compatible client handles this already:
stream = client.chat.completions.create(
model="openai/gpt-5.6-luna",
messages=[{"role": "user", "content": "Count to five."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Time to first token
A streamed call has two useful latencies, and total duration is the less interesting one. Time to first token is when the user stops looking at a spinner — it is recorded separately on every streamed request and shown on Usage as its own figure.
A model that takes four seconds total but starts in two hundred milliseconds feels faster than one that takes two seconds and starts in two.
Metering
Identical. Tokens are counted when the stream completes and priced the same way, so streaming costs exactly what the same request would have cost unstreamed.
A stream the client abandons is recorded as cancelled, with whatever tokens
were generated before it dropped — the provider generated them, so they are
charged.