Streaming
Receive output as it is generated to reduce the wait for the first token.
Send stream: true to /v1/chat/completions, /v1/responses, or /v1/messages to receive Server-Sent Events (text/event-stream). Each endpoint uses its protocol's event format, so streaming works with the official SDKs. Image generation returns a single response.
Example request
curl -N https://api.outerlane.app/v1/chat/completions \
-H "Authorization: Bearer $OUTERLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-6.1-sol",
"stream": true,
"messages": [{ "role": "user", "content": "Say hello in one sentence." }]
}'A Chat Completions stream looks like this. Its final chunk includes x_outerlane billing metadata, followed by data: [DONE].
data: {"id":"req_a1b2…","object":"chat.completion.chunk","model":"openai/gpt-6.1-sol","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"req_a1b2…","object":"chat.completion.chunk","model":"openai/gpt-6.1-sol","choices":[{"index":0,"delta":{"content":"Hello!"},"finish_reason":null}]}
data: {"id":"req_a1b2…","object":"chat.completion.chunk","model":"openai/gpt-6.1-sol","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"x_outerlane":{"input":14,"cached":0,"output":6,"costUsd":0.000044,…}}
data: [DONE]Events by protocol
| Endpoint | Events | Billing metadata |
|---|---|---|
| Chat Completions | chat.completion.chunk, ends with data: [DONE] | x_outerlane in the final chunk |
| Responses | response.* events from response.created through response.completed | response.x_outerlane in response.completed |
| Anthropic Messages | message_start through message_stop | message_delta.usage (token counts only) |
To receive OpenAI-format usage in Chat Completions, send stream_options: { "include_usage": true }. A separate usage chunk arrives just before [DONE].
Streaming behavior
- Tool calling: Chat Completions sends function arguments in fragments. Responses and Anthropic Messages buffer them and send the complete arguments together.
- Errors: After a stream starts, errors arrive as events within the stream. See Streaming errors.
- Disconnects: If you disconnect mid-response, you are billed for output already generated. See Billing rules.
- Timeout: Responses must finish within 5 minutes. Streaming helps you receive the first token sooner on long requests.