Routing and fallbacks
For each model call Meadow builds a route: an ordered list of providers to try. It sends the request to the first one. If that provider fails in a way another provider could fix, Meadow tries the next.
Next step: send one call with provider.order and read x-meadow-attempts in the response.
This is a real fallback. Our OpenRouter account does not allow that model and answered 404, so Meadow moved on and Google served the call. The response does not say which provider failed or why. Only the count is returned.
The default route
With no routing set, Meadow tries, in this order:
- The model’s own provider: Anthropic for Claude, Google for Gemini, OpenAI for GPT, xAI for Grok.
- Cloud hosts: Azure, Bedrock, Vertex.
- OpenRouter.
Fireworks and DeepSeek serve pinned IDs only, such as fireworks/accounts/fireworks/models/kimi-k3 or deepseek/deepseek-flash, so they are never in a default route. It skips providers you have no provider key for and providers that do not accept the request’s format. GET /v1/models lists each model’s providers in this order.
The provider object
Send provider in the request body to change the route for one call. Meadow removes it before forwarding.
order alone does not restrict the route. To restrict it, use only or ignore.
Any other field in provider gets a 400 unknown field in provider routing. A provider name Meadow does not know gets a 400 invalid model provider in routing.models.<field>, where <field> is order, only or ignore, whichever held the name. The message names the project field even when the request sent it.
With the OpenAI and Anthropic SDKs, pass provider and models through extra_body. See Use your existing tools.
With the mdw CLI. mdw is sent to you during the beta. See Clients.
Turn fallbacks off
The status is 502. Google was never tried. With allow_fallbacks: false the models list is ignored too.
That sample is from the hosted beta before 2026-11-28. Since then a 404 from the one provider tried is passed through, so this call returns OpenRouter’s own 404 body with x-meadow-provider: openrouter. A timeout, a 5xx or a rejected key from that provider still returns the 502 above.
Model fallbacks
models is a list of up to three more model IDs. Meadow tries them, in order, after model has failed on every provider in its route.
On /v1/messages only OpenRouter can serve a Gemini model. It rejected, so Meadow moved to the second model and Anthropic served it.
Rules for models:
- The
providerobject applies to every model in the list. - Every ID is checked before any provider is called. One plain ID that cannot be resolved (see Models), in
modelor inmodels, fails the whole request with a 404unknown model(error.codemodel_not_found). A typo inmodelis not rescued by the list. - A fourth entry gets a 400
models may contain at most 3 fallback entries. - It cannot be combined with
previous_response_id.
Project defaults and lock
A project can hold the same four fields as defaults for every call made with its keys, and per-model overrides. Meadow builds the route in layers, and a field set in a later layer replaces the same field from an earlier one:
routing.modelson the project.routing.models.per_model[<model id>]on the project.providerin the request.- A pinned model ID (
<provider>/<model>), which setsonlyto that one provider.
A project with "lock": true rejects layer 3 and layer 4 with a 403. models still works on a locked project, with plain IDs. Projects shows how to set defaults and a lock, and lists the 403 messages.
One case to know: a pinned ID combined with a request only that leaves out the pinned provider leaves no provider at all, and returns a 422 no allowed provider can serve this request.
What triggers a fallback
Meadow moves to the next provider when the current one:
Seen live for this page: the 404 case, on blocking and streamed calls. The rest are read from the server code and covered by its tests.
The Bedrock, Vertex and insufficient_quota rows need provider accounts in those states and were not seen live. When a call ends on insufficient_quota and nothing else serves it, you get a 502 with no retry-after, not a 429, because waiting does not help.
What does not trigger a fallback
- The provider’s 400, 409, 413, 422, or any other 4xx not listed above. Your request is at fault, so another provider would not help. You get the provider’s response as written. That includes a rejected
anthropic-betaflag when the model ID is pinned. - A 404 for a pinned model ID. Same handling.
- A 404 when the route has only one provider, for example with
provider.only,allow_fallbacks: false, or a key for one provider of the model. Nothing is left to fall back to, so you get the provider’s 404 as written, withx-meadow-provider. On the hosted beta since 2026-11-28; before, this was a 502. Read from the server’s code and its tests. - Anything after the first event of a stream has reached you. See Streaming.
- An error Meadow raises before it calls any provider: a bad request, a key limit, a locked project.
A provider 400 comes back at once, even when another provider is next in the route:
A pinned ID that the provider does not know also stops there, and models is not tried:
How a provider error reaches you
Every failed route looks like this:
That sample is from the hosted beta before 2026-11-28, when a 404 from the only provider in the route still ended in this 502. Since then that call returns OpenRouter’s own 404. A route whose providers all fail in other ways, such as a timeout, a 5xx or a rejected key, returns this shape.
Each entry in attempts has provider, outcome, reason and duration_ms, and detail, started_at and finished_at when Meadow has them. detail gives the provider’s HTTP status and, when Meadow recognizes it, a short code such as (not_found_error). It never contains the provider’s message text or any key. To see the provider’s own words, pin that provider and send the call again.
A failed route is not charged against a key’s request or token limit, unless a provider received the request and gave no usable answer. See Token and request limits.
Why a call went where it went
Every route leaves its reason in three places. All of them use stable codes and never provider error text. They were added on 2026-11-24 and are on the hosted beta since 2026-11-27.
-
A model call that was served carries
x-meadow-route.direct: xaimeans the first provider in the route answered.fallback: openai quota_exceeded -> openroutermeans OpenAI’s account was out of quota and OpenRouter answered. -
A Meadow error body, and every sandbox, has
attempts: one entry per provider tried, in order, withprovider,outcome,reason,started_at,finished_atandduration_ms. So a sandbox that went to Modal because Daytona was full reads:That example is written from the server’s tests, not captured on the beta, and the times are left out.
-
reasonis the code to branch on or count:served,no_capacity,quota_exceeded,rate_limited,timeout,auth_failed,invalid_request,refused,unsupported,no_provider_key,image_pull_failed,build_failed,provider_lost,vendor_error. New codes can be added, so treat one you do not know likevendor_error.
A route pinned to one provider shows one attempt and no fallback.
Attempts headers
x-meadow-attempts counts the providers tried, including the one that answered. 1 means no fallback happened. It is not sent on Meadow errors: count error.attempts there. Two more headers name providers that rejected your stored key or that may bill for an unused answer. Models lists every header.
Those two were not seen live for this page. Storing a provider key checks it with the provider first, so we had no rejected key to test with.
How long a route can take
Each attempt has its own time limit, so a route with three providers can take three times as long as one. Streaming lists the limits. To bound the wait, shorten the route with only, or stream.
API reference
Operations on this page: createChatCompletion, createResponse, createMessage, updateProject.