Streaming

Server-sent events on both endpoints, and billing mid-stream.

Set "stream": true. Both endpoints answer with text/event-stream in their native event formats, and both keep the connection alive during long pauses (a : keep-alive comment or an Anthropic ping after 15 s of silence).

OpenAI-compatible

Chunks are chat.completion.chunk objects ending with data: [DONE]. Add "stream_options": {"include_usage": true} to receive a final chunk with choices: [] and usage.

Anthropic-compatible

Events message_start → content_block_start / content_block_delta / content_block_stop → message_delta (with output usage) → message_stop.

Billing while streaming

If you disconnect mid-stream you are charged for the tokens generated up to that point, as reported by the model. If the upstream fails mid-stream you receive an error event and the reservation is released.