Skip to content
← Changelog
2.2.152
Feature

Stop empty streams from reaching your users

A streamed request whose first route answered empty used to hand your caller an empty stream; now it is retried on another route before any output reaches you, and only the attempt that answers is billed.

We built a retry for a streamed request whose first route answers 200, then has nothing to say. Until now your caller read an empty stream. Now an empty or broken first answer is retried on another route before any output reaches your caller, and your caller reads the stream of the route that answers. Apertis does this on Chat Completions, Messages and Responses, and only the attempt that answers is billed.

A streamed chat completion whose first route answered 200 with an empty stream, answered in full by the next route

Nothing to change in your request

Send the same streamed request as before. The retry happens before any of the first route's stream reaches you, so the stream you read is the answering route's:

curl -N https://api.apertis.ai/v1/chat/completions \
  -H "Authorization: Bearer $APERTIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5.5","stream":true,"messages":[{"role":"user","content":"Say hello."}]}'
data: {"id":"<id>","object":"chat.completion.chunk","created":<ts>,"model":"claude-sonnet-5.5","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"}}]}
data: {"id":"<id>","object":"chat.completion.chunk","created":<ts>,"model":"claude-sonnet-5.5","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":"stop"}]}
data: [DONE]

/v1/messages and /v1/responses behave the same way with their own stream events.

A streamed Messages request whose first route answered 200 with an empty stream, answered in full by the next route

What counts as empty or broken

A route's first answer is retried when, before any output reaches you, it does one of these:

  • The stream ends with no output.
  • It sends an event that cannot be parsed.
  • It closes without a terminal event.
  • It sends an error event that is not about your request itself.

When it applies

Your requestWhat you get
A stream on /v1/chat/completions, /v1/messages or /v1/responses whose first answer is empty or broken before any outputThe request is retried on another route, and you get that route's answer
A stream whose first answer carries outputDelivered byte for byte, as before
A stream that has already sent you any outputNever retried and never spliced: it reaches you as it is
A request that no other route can serveDelivered as before, with no retry
A stream from a route the retry does not cover yetDelivered as before, with no retry
A first answer that runs long before its first outputDelivered as before, with no retry
A request that names a stop sequenceDelivered as before, with no retry
A request that ends with a tool resultDelivered as before, with no retry
A web-search stream that has already shown that it is searchingDelivered as before, with no retry

Only the attempt that answers is billed. Non-streaming Chat Completions requests got the same treatment earlier.