Streaming
Send "stream": true and Meadow relays the provider’s server-sent events to you as they arrive, unchanged. Each format keeps its own event shapes, so your existing stream parser works.
Next step: run one streamed call and check that it ends with the format’s final event.
The response has content-type: text/event-stream and the same x-meadow-provider, x-meadow-model, and x-meadow-attempts headers as a blocking call. The headers arrive before the first event.
Each format’s stream
Meadow does not check that a stream reached its final event. Your client must.
Chat Completions
Usage arrives in a stream only if you ask for it, as at OpenAI: send "stream_options": {"include_usage": true}. Meadow asks the provider for the count on every stream and removes the usage-only chunk when you did not ask.
Responses
Providers differ in detail. OpenRouter sends the same events as bare data: lines with no event: line. Read the type field inside the data.
Messages
The output is trimmed. With the mdw CLI (Clients), mdw models call --stream prints the text as it arrives:
Before the first event
Meadow holds a stream until the provider’s first complete event has arrived (up to 64 KiB). Until then the call can still fall back to the next provider, and a failure is a normal JSON error with a 4xx or 5xx status, not a stream.
Three things follow:
- You see no bytes until the first event is complete. The first event arrives in one piece.
- A provider that opens a 200 stream with its own error event counts as failed, and Meadow tries the next provider.
- On a Responses stream the opening
response.created,response.queued, andresponse.in_progressevents are held too, until the event after them arrives, because a provider reports its error there.
A streamed call that fails before the first event:
So check the status before you parse events. A fallback before the first event is invisible apart from x-meadow-attempts: the same request with "provider": {"order": ["openrouter", "google"]} streamed from Google with x-meadow-attempts: 2.
After the first event
Once the first event has been sent to you there is no fallback. If the provider’s connection breaks, goes quiet for 5 minutes, or ends in the middle of an event, Meadow writes one last event in your request’s format and ends the response. The status is still 200. A provider event that arrived only in part is dropped, so every event you receive is whole.
A Chat Completions example:
The OpenAI and Anthropic SDKs raise an API error when they read these events. The example comes from the server’s tests. No provider broke a stream midway on the hosted beta, so this event has not been seen there.
Do: treat the error event, or a stream that ends without its final event, as a failed call, and send the whole call again if you want the response. Meadow cannot resume a stream. A provider’s own error event in the middle of a stream is relayed like any other event, and Meadow adds nothing after it. If the event names the key or token Meadow sent to that provider, Meadow replaces each copy with [REDACTED] first. To catch a copy split across two reads, Meadow holds back bytes that could be the start of that credential until the next read or the end of the stream. It holds at most one byte fewer than the credential, and holds nothing when the bytes cannot start it.
What a dropped stream costs
If you close the connection before the stream ends, Meadow closes its connection to the provider. Two costs remain.
The provider may bill you for what it generated before it noticed. That is between you and the provider.
On a key with a token limit, Meadow charges the key the tokens it reserved for the call, not the smaller number generated so far. The reservation is the output token limit you sent plus about a third of the request’s size in bytes. This run used two keys with max_tokens: 1000 each. Both sent the same streamed request with an output token limit of 800, which reserves 848 tokens. The first client stopped after 2 seconds:
The provider had sent only part of the response by then. GET /v1/key showed tokens_used: 848 on that key. The next request on it reserved 343 tokens and was rejected, because 848 + 343 is more than 1000:
The second client read its stream to the end. The provider reported 466 tokens, Meadow charged 466, and the same follow-up request was served.
Do: read streams to the end on limited keys, and keep output token limits close to what you need. A key with no limit is not charged anything by Meadow. Token and request limits has the full rule.
Time limits
These are the values on the hosted beta. You cannot change them.
Three more things affect long calls:
- A blocking call sends nothing until the whole answer is ready, so a slow model can sit for the full 10 minutes on one provider before Meadow tries the next. A route of three providers can take 30 minutes. Stream long answers.
- When Meadow is updated, a stream that is still open after a few seconds is ended with one last error event in the format of the stream: a chunk with a top-level
errorandfinish_reason: "error"on Chat Completions, anerrorevent on Responses and on Messages. The event’s message says the server is restarting. Nothing follows it, so there is no[DONE]. The call may have been billed by the provider. - A stream counts as an open request of your account until it ends. See Token and request limits.
None of the time limits was reached while testing this page, and no provider broke a stream midway: those rows and the section on what happens after the first event are read from the server’s code and settings. The dropped stream and the fallback before the first event were run for real.
More in Known limits.
API reference
Operations on this page: createChatCompletion, createResponse, createMessage.