Streaming
Set stream to true and CrossModel returns incremental results as Server-Sent Events. The event format differs by protocol, but the client approach is the same: read chunk by chunk, append the text, and handle the end and error events.
Chat Completions
curl https://api.crossmodel.ai/v1/chat/completions \
-H "Authorization: Bearer $CROSSMODEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4-pro",
"messages": [{ "role": "user", "content": "Tell me a short story" }],
"stream": true
}'Chat Completions returns chat.completion.chunk events. Concatenate choices[0].delta.content from each chunk to rebuild the full reply.
Responses
The Responses streaming endpoint uses event objects with a type field, for example:
| Event | Notes |
|---|---|
response.created | The response begins. |
response.output_text.delta | A text increment. |
response.function_call_arguments.delta | A function-arguments increment. |
response.completed | The response ends. |
Messages
The Anthropic Messages streaming endpoint uses the Anthropic event format, such as message_start, content_block_delta, message_delta, and message_stop.
Error handling
A streaming response can still error after the connection is open. The client must handle error events — don't just wait for [DONE] or the end event:
- Chat Completions: you may receive a
data:chunk with anerrorfield. - Responses: you may receive
event: error. - Messages: you may receive an Anthropic
errorevent.
When a stream fails partway through, don't append the result of an automatic retry onto the output you already have. The safer move is to mark the generation as failed and start a fresh, complete request.