> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Errors

Every error Meadow makes outside the model routes has the same JSON body. Read the HTTP status first, then `error.type`, then `error.message`. The model routes answer in OpenAI's or Anthropic's own error format, with the same status and the same `error.code`: see [Errors on model routes](#errors-on-model-routes).

```bash
curl -sS -i "$MEADOW_BASE_URL/v1/key"
```

```text
HTTP/2 401
content-type: application/json
x-request-id: req_0000205a

{"error":{"code":"api_key_missing","message":"missing api key","type":"unauthorized"},"request_id":"req_0000205a"}
```

The `x-request-id` header and the `request_id` field carry the same id: see [Request IDs](#request-ids).

## The error body

| Field | Always present | Meaning |
| --- | --- | --- |
| `request_id` | yes | Meadow's id for the request, the same value as the `x-request-id` response header. It sits beside `error`, not inside it. |
| `error.type` | yes | The class of error. One of the twelve values below. |
| `error.message` | yes | A sentence for a person. It names the rule that was broken, and for most value errors the field. Do not match on its exact text: it can change. |
| `error.code` | yes | A stable name for the specific failure. See [Codes](#codes). |
| `error.param` | no | The field, query parameter or header the error is about. Set on most validation errors. |
| `error.attempts` | no | On routed calls, one entry per provider tried: `provider`, `outcome`, `detail`, `duration_ms`. |
| `error.retry` | on sandbox routes | Whether to send the same request again: `safe`, `after_fix`, `check_outcome` or `never`. See [Retry and outcome on sandbox routes](#retry-and-outcome-on-sandbox-routes). |
| `error.outcome` | on sandbox routes | What happened to the work: `not_started` or `unknown`. `completed` and `partial` are reserved. |

Meadow's messages never contain a provider's error text or any key.

Two things differ on the model routes. Meadow's own errors use the provider's envelope there: see [Errors on model routes](#errors-on-model-routes). And some provider errors are passed through as the provider wrote them: see [Provider errors on model routes](#provider-errors-on-model-routes).

## Types

| Status | `type` | Meaning | What to do | Retry |
| --- | --- | --- | --- | --- |
| 400 | `invalid_request` | The request is malformed: bad JSON, an unknown field, a missing field, a value out of range, an unknown model. | Fix the request. The message names the problem. | No |
| 409 | `conflict` | The request is valid and the current state refuses it: a sandbox that is not running, a project that still has sandboxes, an idempotency key reused with a different body, the last admin key, an update to a revoked key. | Read the message, clear the cause, send again. | After the cause is cleared |
| 413 | `invalid_request` | The body is too large: over 1 MiB on control and sandbox JSON routes, over 16 MiB on model routes, over 100 MiB on uploads. | Send less. | No |
| 401 | `unauthorized` | The key is missing, wrong, revoked, or expired. | See [Authentication](/set-up-your-account/authentication#what-a-bad-key-looks-like). | No |
| 402 | `insufficient_quota` | A dollar `limit` on the key, or on a key above it, is spent, or this request's held amount does not fit in what is left. | Raise the `limit`, wait for `limit_reset_at`, or lower the request's output cap. See [Spend limits](/call-models/spend-limits). | No |
| 403 | `forbidden` | The key is valid but may not do this: missing scope, model not on `allowed_models`, a spent `max_requests` or `max_tokens` (with a `code`), a locked project, a child key wider than its parent. | Use a key that allows it, or change the request. | No |
| 404 | `not_found` | The route or the object does not exist in your account or, for sandboxes and images, in the key's project. | Check the id and which project the key belongs to. | No |
| 405 | `invalid_request` | The path exists and does not accept this method. `error.code` is `method_not_allowed`, and the `Allow` response header lists the methods the path accepts. Before 2026-11-28 this was a 404. | Use a method from `Allow`. | No |
| 422 | `no_provider_key` | No stored provider key can serve the request, after routing rules are applied. | Store a key for a provider that serves the model or sandbox, or loosen `only`. See [Provider keys](/set-up-your-account/provider-keys). | After you store a key |
| 429 | `rate_limited` | A full server on which no slot came free for your account within 3 seconds, a provider rate limit, too many failed authentications from your address, a key limit check that waited too long, or a server that is holding too many model request bodies of 1 MiB or more. | Wait for `retry-after`, then retry. | Yes |
| 502 | `all_providers_failed` | Every provider in the route was tried and failed. `attempts` lists each one. | Read `attempts`. If one provider's key was rejected or its account has no credit, fix that. | Not for model calls. See [Retrying](#retrying). |
| 502 | `provider_error` | A provider failed and there was no fallback: fallbacks were off, there was one provider, or the call was a sandbox or credential check call. | On a sandbox or credential check call, retry with backoff. | Not for model calls |
| 503 | `unavailable` | Meadow lacks something it needs to serve this route. | Retry later. Contact support if it lasts. | Yes |
| 500 | `internal` | A fault in Meadow. | Retry once. Contact support if it repeats. | Yes, for calls that are safe to repeat |
| 501 | `internal` | A feature this route needs is not set up on the server. Not seen on the hosted beta. | Contact support. | No |

Every 409 carries the type `conflict`. Before 2026-11-24 a 409 carried `invalid_request`, the same as a 400. If your code matched on that, match on the status or on `conflict` now.

### Codes

Every Meadow error carries `error.code`, a stable name for the specific failure. Several codes share one `type`. Branch on `type` first and on `code` when you need to tell two failures apart, for example `api_key_expired` from `api_key_revoked`. Meadow can add a code at any time, so treat a code you do not know as its `type`.

Validation errors also carry `error.param`: the body field, query parameter or header at fault. A nested field is written with dots, such as `credentials.api_key`.

```json
{"error":{"code":"parameter_unknown","message":"unknown field in project","param":"colour","type":"invalid_request"},"request_id":"req_00008e54"}
```

A field of the wrong JSON type is named too, on every route that takes a JSON body: `{"name": 123}` returns `parameter_invalid` with `"param": "name"` and the message `name must be a string`. So are the validation errors of `POST /v1/sandboxes`, such as `resources.memory_mb` or `provider.options.daytona.spot`.

The sandbox, image and model routes do not name every failure yet. Where they have no narrower code, `code` repeats the `type` (`internal` becomes `internal_error`), and `param` is absent.

| `code` | Status | Meaning |
| --- | --- | --- |
| `route_not_found` | 404 | The path does not exist. |
| `method_not_allowed` | 405 | The path exists and does not accept this method. The `Allow` response header lists the methods it accepts. |
| `request_too_large` | 413 | The body is larger than the route allows. |
| `content_type_invalid` | 400 | A JSON route was called without `Content-Type: application/json`. |
| `body_invalid` | 400 | The body is not one valid JSON object: broken JSON, a repeated key, nesting past 64 levels, invalid UTF-8 or a NUL character. |
| `request_target_invalid` | 400 | The path or a query parameter holds invalid UTF-8 or a NUL character. |
| `header_invalid` | 400 | A request header Meadow reads is malformed. `param` names the header. |
| `parameter_missing` | 400 | A required field is absent. `param` names it. |
| `parameter_invalid` | 400 | A field has a value Meadow does not accept. `param` names it. |
| `parameter_unknown` | 400 | The body holds a field the route does not know, or a known field in the wrong letter case. `param` names it. |
| `provider_credentials_rejected` | 400 | The vendor refused the credentials when Meadow checked them. `param` is `credentials`. |
| `invalid_request` | 400 | Any other malformed request. Sent when no narrower code applies. |
| `api_key_missing` | 401 | No key was sent. |
| `api_key_header_invalid` | 401 | The key header is malformed, sent twice, or the two key headers disagree. |
| `api_key_invalid` | 401 | The key is not one Meadow issued. |
| `api_key_revoked` | 401, 409 | The key was revoked. 409 when you try to update a revoked key. |
| `api_key_expired` | 401 | The key is past its `expires_at`. |
| `api_key_disabled` | 401 | The key, or a key above it, is disabled. |
| `api_key_parent_missing` | 401 | The key counts against a parent key that no longer exists. |
| `account_disabled` | 401 | The account is disabled. Every key of the account gets this until the Meadow team enables it again. |
| `session_token_invalid` | 401 | A signed-in person's session token failed a check: the signature, the signing key, the issuer, the audience, the subject or the email. Only the Meadow dashboard sends one. |
| `session_token_expired` | 401 | A signed-in person's session token is past its expiry. The dashboard refreshes the session and sends the new token. It does not count toward the limit on failed authentications. |
| `unauthorized` | 401 | Any other authentication failure. |
| `key_spend_limit_exceeded` | 402 | The key, or a key above it, has spent its dollar `limit`, or this request's reserved estimate would pass it. No vendor was called. It is a 402 and not a 429, so a client that retries a 429 does not resend it. |
| `budget_exceeded` | 402 | A budget with `hard_limit` on the project or on the account has reached its `limit_usd` for the window, or this request's reserved estimate would pass it. No vendor was called and nothing was created. Raise `limit_usd`, switch `hard_limit` off, or wait for `resets_at`. |
| `scope_missing` | 403 | The key lacks the scope the route needs. |
| `key_grant_exceeds_parent` | 403 | A key create or update asked for more than the calling key or the keys above the changed key hold: a scope, a model, a provider, a later expiry or a higher limit, or it removed a list they have. `param` names the field when there is one. |
| `key_model_access_denied` | 403 | The model the request names, or a model in its `models` fallback list, is not in the `allowed_models` of the key or of a key above it, or that list allows it only on providers that do not serve this format. `param` is `model` or `models`. No vendor was called. |
| `key_provider_access_denied` | 403 | No provider in the route of this call is in the `allowed_providers` (model calls) or `allowed_sandbox_providers` (sandboxes and image builds) of the key or of a key above it. The message names the providers the key may use. No vendor was called and nothing was created. |
| `key_request_limit_exceeded` | 403 | The key, or a key above it, has used its `max_requests`. |
| `key_token_limit_exceeded` | 403 | The key, or a key above it, has used its `max_tokens`, or this request's reservation would pass it. |
| `key_spend_price_unknown` | 403 | The key, or a key above it, has a dollar `limit`, or a budget with `hard_limit` covers the call, and Meadow holds no price for a model and provider in the route of this call. No vendor was called. Route the call to providers with a listed price. |
| `key_sandbox_limit_exceeded` | 403 | The key, or a key above it, has `max_sandboxes` sandboxes alive. Nothing was created. Retry after one ends. |
| `project_sandbox_limit_exceeded` | 403 | The project has `max_sandboxes` sandboxes alive. Nothing was created. Retry after one ends. |
| `user_token_not_allowed` | 403 | A signed-in person's session token was sent to a route that needs an API key. Model calls, sandbox creates and work inside a sandbox always need a key, so their spend is charged to it. |
| `no_account_access` | 403 | The signed-in person is a member of no account, or of a different one than `x-meadow-account` names. Access to the private beta is granted by the Meadow team or by an invite. `GET /v1/me` still answers a person in no account, with the invites they can accept. |
| `email_not_verified` | 403 | The signed-in person's email is not verified, so an invite cannot match it. Sign in with a provider that verifies the address, or confirm it from the sign-in email. |
| `role_not_allowed` | 403 | The signed-in person's role in the account does not allow this. Roles are `owner`, `admin`, `member` and `viewer`. |
| `forbidden` | 403 | Any other refusal of a valid key. |
| `api_key_not_found` | 404 | No key with that id in the account. |
| `project_not_found` | 404 | No project with that id in the account. |
| `provider_key_not_found` | 404 | No stored key for that provider. |
| `sandbox_not_found` | 404 | No sandbox with that id in the project. |
| `exec_not_found` | 404 | No background command with that id in the sandbox. |
| `image_not_found` | 404 | No image with that id in the project. |
| `model_not_found` | 404 | A model route was called with a plain model id Meadow cannot resolve: it is not in `GET /v1/models`, and it is not an id of the `claude-`, `gpt-`, `gemini-` or `grok-` family on a project with that vendor's key. `param` is `model`. The message names the id, lists up to three close ids, and shows how to pin a provider. OpenAI uses the same code. |
| `budget_not_found` | 404 | No budget is set on the account or the project. |
| `ssh_not_enabled` | 404 | The sandbox was created without `ssh: true`. |
| `member_not_found` | 404 | No person with that user id in the account. |
| `invite_not_found` | 404 | No open invite with that id in the account, or none sent to your address: it was accepted, revoked, expired, or never existed. |
| `not_found` | 404 | Any other missing resource. |
| `last_admin_key` | 409 | The change would leave the account without a usable admin key. |
| `project_has_dependent_keys` | 409 | Live keys in other projects count against a limited key in the project you are deleting. |
| `idempotency_key_reused` | 409 | The `Idempotency-Key` was already used with a different body or on a different route. |
| `idempotency_request_in_progress` | 409 | The first request with this `Idempotency-Key` is still running. Retry after a short wait. |
| `exec_start_failed` | 409 | A background command sent with this `Idempotency-Key` failed to start earlier, and the key is bound to that failed start. Nothing is running. Send the start again with a new `Idempotency-Key`. |
| `exec_start_in_progress` | 409 | A background command sent with this `Idempotency-Key` is being started by another request right now. Send the same request again after `retry-after` seconds to get the command. |
| `last_owner` | 409 | The change would leave the account with no owner: the last owner cannot be removed, leave, or take a lower role. |
| `invite_exists` | 409 | An open invite for that address exists in the account. Revoke it to send a new one. |
| `already_member` | 409 | That address already belongs to a person in the account, or the person accepting an invite already belongs to an account: one account per person. |
| `conflict` | 409 | Any other refusal because of the current state. |
| `no_provider_key` | 422 | No stored provider key can serve the request. |
| `auth_attempts_exceeded` | 429 | Too many failed authentication attempts from your address. |
| `in_flight_limit_exceeded` | 429 | Too many model calls in flight on this key. Only a deployment that sets a cap per key returns it. The hosted service sets none. |
| `account_in_flight_limit_exceeded` | 429 | The server that got the request was full and no slot came free for the account within 3 seconds. Freed slots go first to the account with the fewest requests open. A server with a free slot never returns it. Retry after `retry-after` seconds. |
| `key_limit_check_busy` | 429 | The limit check of a key with `max_requests` or `max_tokens` (its own or a parent's) waited more than 3 seconds for one limited key, or more than 4 seconds in all, behind other calls on the same keys. No vendor was called and nothing was charged. Retry after `retry-after` seconds, and spread calls over more keys if it repeats. |
| `large_request_limit_exceeded` | 429 | The server is holding too many model request bodies of 1 MiB or more. Retry after `retry-after`. |
| `invite_rate_limited` | 429 | The account sent 20 invites in the last hour. |
| `access_request_rate_limited` | 429 | `POST /v1/access-requests` had too many requests from this sender, or in total, in the last hour. Retry after `retry-after`. |
| `rate_limited` | 429 | Any other rate limit, a vendor's included. |
| `internal_error` | 500 | A fault in Meadow. |
| `not_implemented` | 501 | The feature is not set up on this server. |
| `all_providers_failed` | 502 | Every vendor in the route was tried and failed. |
| `provider_error` | 502 | A vendor failed and there was no fallback. |
| `sandbox_unreachable` | 502 | The sandbox vendor could not find or run in a sandbox that it still reports as running, or Meadow could not confirm which. Nothing was changed. Retry after `Retry-After` seconds. |
| `server_restarting` | 503 | The server was shutting down for a deploy and did not finish the request. The message says whether a retry is safe. |
| `database_unavailable` | 503 | Meadow could not reach its database, or waited too long for a connection to it. Retry after `retry-after` seconds when the `x-should-retry` header is `true`. When it is `false` the change may have been applied: read the resource before you send it again. |
| `session_keys_unavailable` | 503 | Meadow could not fetch the public keys it checks session tokens with. Retry after a few seconds. |
| `unavailable` | 503 | Meadow lacks something it needs to serve the route. |

A spent limit is a 403 and not a 429 on purpose. A client that retries a 429 would otherwise resend a call that a spent key can never make. A spent dollar `limit` is a 402 for the same reason.

### Attempt outcomes

Each entry in `attempts` has one of these outcomes: `served`, `unsupported` (the provider cannot meet the request), `refused`, `no_capacity`, `timeout`, `rate_limited`, `error`.

## Common messages

These were all returned by the hosted beta on 2026-11-24. Each body also had a `request_id` field, left out here to keep the table short. The bodies are shown in Meadow's envelope, as they were captured. Since 2026-11-28 a model route writes the same status, code and message in the provider's envelope: see [Errors on model routes](#errors-on-model-routes).

| Request | Status | Body |
| --- | --- | --- |
| Unknown path | 404 | `{"error":{"code":"route_not_found","message":"route not found","type":"not_found"}}` |
| An OpenAI or Anthropic route Meadow does not serve | 404 | `{"error":{"code":"route_not_found","message":"Meadow does not serve embeddings (/v1/embeddings). Call the vendor's own API for it, ...","type":"not_found"}}` |
| Truncated JSON | 400 | `{"error":{"code":"body_invalid","message":"invalid json request body","type":"invalid_request"}}` |
| No `Content-Type: application/json` | 400 | `{"error":{"code":"content_type_invalid","message":"content-type must be application/json","type":"invalid_request"}}` |
| The same field twice | 400 | `{"error":{"code":"body_invalid","message":"duplicate field in json object","type":"invalid_request"}}` |
| `Name` instead of `name` | 400 | `{"error":{"code":"parameter_unknown","message":"invalid field casing","param":"Name","type":"invalid_request"}}` |
| A field Meadow does not know | 400 | `{"error":{"code":"parameter_unknown","message":"unknown field in key create request","param":"colour","type":"invalid_request"}}` |
| A model Meadow does not know | 400 | `{"error":{"code":"parameter_invalid","message":"unknown model \"llama-typo-9\": it is not in GET /v1/models. Pin the provider ...","param":"model","type":"invalid_request"}}` |
| `?limit=500` | 400 | `{"error":{"code":"parameter_invalid","message":"limit must be between 1 and 200","param":"limit","type":"invalid_request"}}` |
| Model call, no usable provider key | 422 | `{"error":{"code":"no_provider_key","message":"no stored provider key can serve this request","type":"no_provider_key"}}` |
| Model outside `allowed_models` | 403 | `{"error":{"code":"key_model_access_denied","message":"model \"gpt-4.1\" is not in this api key's allowed_models","param":"model","type":"forbidden"}}` |
| No provider in the route on `allowed_providers` | 403 | `{"error":{"code":"key_provider_access_denied","message":"model \"gpt-4o-mini\" has no provider in this route that this api key may use in the Chat Completions format: its allowed_providers allow anthropic","type":"forbidden"}}` |
| Request limit spent | 403 | `{"error":{"code":"key_request_limit_exceeded","message":"api key max_requests limit reached: 2 of 2 requests used on this key","type":"forbidden"}}` |
| Exec on an ended sandbox | 409 | `{"error":{"code":"conflict","message":"sandbox is not running","type":"conflict"}}` |
| Another project's sandbox id | 404 | `{"error":{"code":"not_found","message":"sandbox not found","type":"not_found"}}` |

Meadow is strict about request bodies on its own routes. Unknown fields, duplicate fields, and wrong letter case are rejected, never ignored. On model routes the body is the provider's format and extra fields pass through to the provider.

Query strings are not strict. A query parameter Meadow does not know is ignored without an error. `GET /v1/keys?project_id=...` returns the keys of every project, and `PUT .../files?path=...&mode=755` writes the file with mode 0644. Check the parameter names in the API reference before you rely on a filter.

Three messages can mislead:

- An unknown-field message does not name the field, but `error.param` does. `unknown field in sandbox create request` came back for a body that sent `command`, with `"param": "command"`. The usual causes are a field from another API (`cmd`, `workdir`, `command` on create) and a field in the wrong object.

- `unknown model` also appears when you misspell a real model. `GET /v1/models` lists the IDs your key can call. The message carries the id and a pinning example. Meadow passes an unlisted `claude-`, `gpt-`, `gemini-` or `grok-` id to its own provider when you have that provider's key, so a misspelt id of those families comes back as the provider's 404. To call any other model Meadow has not listed, pin the provider: `<provider>/<model>`.
- A format mismatch has two messages. When no provider Meadow knows for the model accepts the format (for a pinned id, the pinned provider), you get a 400 `no provider accepts this format for the requested model`. When other providers accept it but the ones you allowed with `only` do not, you get a 422 `no allowed provider can serve this request`, even though a key for the allowed provider is stored. For example, a Messages request limited to a provider that only takes Chat Completions. [Models](/call-models/models#the-formats) shows which provider accepts which format.

## Errors on model routes

`POST /v1/chat/completions`, `POST /v1/responses`, `POST /v1/messages` and `GET /v1/models` are the routes you call with the OpenAI and Anthropic SDKs. An error Meadow makes on those paths is written in that format's own envelope, so the SDK raises its usual typed error and its fields are filled.

This covers every Meadow error on those paths: a missing key, a wrong method, a spent limit, a failed route. It also covers the provider paths Meadow does not serve, such as `/v1/embeddings` and `/v1/messages/count_tokens`. Every other route (keys, projects, provider keys, sandboxes, images, build contexts, usage) uses [the error body](#the-error-body) above. Before 2026-11-28 the model routes used it too: see the [changelog](/reference/changelog).

On `/v1/chat/completions`, `/v1/responses`, `/v1/models` and the unserved OpenAI paths, the body is OpenAI's:

```json
{"error":{"message":"model is required","type":"invalid_request_error","param":"model","code":"parameter_missing"},"request_id":"req_0000252a"}
```

On `/v1/messages` and the paths under it, the body is Anthropic's:

```json
{"type":"error","error":{"type":"invalid_request_error","message":"model is required","details":{"error_code":"parameter_missing"},"code":"parameter_missing","param":"model"},"request_id":"req_0000252a"}
```

On the Gemini route (`/v1beta/models/...` and `POST /v1/models/{model}:generateContent`), the body is Google's. `error.code` there is the HTTP status, `error.status` its Google name, and Meadow's code is the `reason` of an `ErrorInfo` detail and its `metadata.code`. The list of attempts is left out. See [Gemini clients](/call-models/gemini-clients#errors). Not on the hosted beta yet.

```json
{"error":{"code":400,"message":"model is required","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"PARAMETER_MISSING","domain":"api.usemeadow.ai","metadata":{"code":"parameter_missing","param":"model","request_id":"req_0000252a","type":"invalid_request"}}]}}
```

What stays the same as on every other route, in OpenAI's and Anthropic's envelopes:

- The HTTP status.
- `error.code`, with the values in [Codes](#codes). In Anthropic's envelope the same value is also at `error.details.error_code`, where Anthropic's format carries a code and the Anthropic SDKs read it.
- `error.message`, `error.param` and `error.attempts`. In OpenAI's envelope `param` is `null` when there is none.
- `request_id`, `x-request-id`, `retry-after` and `x-should-retry`.

What differs is `error.type`, which follows the provider:

| Status | Type on other routes | OpenAI `error.type` | Anthropic `error.type` |
| --- | --- | --- | --- |
| 400 | `invalid_request` | `invalid_request_error` | `invalid_request_error` |
| 401 | `unauthorized` | `invalid_request_error` | `authentication_error` |
| 402 | `insufficient_quota` | `insufficient_quota` | `billing_error` |
| 403 | `forbidden` | `invalid_request_error` | `permission_error` |
| 404 | `not_found` | `invalid_request_error` | `not_found_error` |
| 405 | `invalid_request` | `invalid_request_error` | `invalid_request_error` |
| 409 | `conflict` | `invalid_request_error` | `conflict_error` |
| 413 | `invalid_request` | `invalid_request_error` | `request_too_large` |
| 422 | `no_provider_key` | `invalid_request_error` | `invalid_request_error` |
| 429 | `rate_limited` | `rate_limit_error` | `rate_limit_error` |
| 500, 501 | `internal` | `server_error` | `api_error` |
| 502 | `all_providers_failed`, `provider_error` | `server_error` | `api_error` |
| 503 | `unavailable` | `service_unavailable_error` | `api_error` |

OpenAI itself answers a bad key with status 401 and the type `invalid_request_error`, and its SDKs choose the error class from the status alone. So in OpenAI's envelope every 4xx except 402 and 429 has that one type. Branch on the status and on `error.code`.

The 402 row is for a key that has spent a dollar limit. It uses the type each provider gives a billing or quota rejection: `insufficient_quota` for OpenAI and `billing_error` for Anthropic. A 405 on a model route carries the `Allow` header, as on every other route.

With the OpenAI Python SDK:

```python
import openai
from openai import OpenAI

try:
    OpenAI(max_retries=0).chat.completions.create(model="gpt-5", messages=[])
except openai.RateLimitError as e:
    print(e.status_code, e.type, e.code, e.request_id)
except openai.APIStatusError as e:
    print(e.status_code, e.type, e.code, e.param, e.request_id)
    print(e.body.get("attempts"))
```

With the Anthropic Python SDK:

```python
import anthropic
from anthropic import Anthropic

try:
    Anthropic(max_retries=0).messages.create(model="claude-haiku-5-5", max_tokens=8, messages=[])
except anthropic.APIStatusError as e:
    print(e.status_code, e.type, e.error_code, e.request_id)
    print(e.body["error"].get("attempts"))
```

Both SDKs were run against these bodies in Meadow's tests, with a mock transport and no network. They were not run against the hosted beta.

<a id="vendor-errors-on-model-routes"></a>

## Provider errors on model routes

Meadow sorts a provider's error into one of two groups.

A request error (the provider's 400, 409, 413, or 422, or a 404 for a model id you pinned to that provider or from the only provider in the route) is your request's fault, and another provider would not help. Meadow returns the provider's status, body, and content type as written. That body is the provider's own. An OpenAI or Anthropic body has the same envelope as a Meadow error on that route, without Meadow's `code`, `attempts` and request id. A Google or xAI body has its own shape. A Bedrock body is rewritten into Anthropic's envelope, `{"type":"error","error":{"type":...,"message":...}}`, with AWS's message and a type from the status (`invalid_request_error` for 400, `not_found_error` for 404), because Bedrock's own body (`{"message":...}`) is not an Anthropic error. A Vertex body in Google's shape is rewritten into the route's envelope: `{"type":"error","error":{"type":...,"message":...}}` on `/v1/messages`, and `{"error":{"message":...,"type":...,"param":null,"code":...}}` on Chat Completions, where `code` is Google's `status` (such as `RESOURCE_EXHAUSTED`). Google's message is kept, the error type follows the HTTP status, and the content type is `application/json`.

A vendor error body never carries the key or token Meadow sent to that vendor. Meadow replaces each copy with `[REDACTED]`, and does the same for an error event inside a stream (see [Streaming](/call-models/streaming#after-the-first-event)). Only the exact text Meadow sent is matched.

```bash
curl -sS -i "$MEADOW_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $MEADOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-3.1-flash-lite-preview", "provider": {"only": ["google"]}, "messages": [{"role": "user", "content": "hi"}], "max_tokens": 8, "temperature": 99}'
```

```text
HTTP/2 400
content-type: application/json; charset=UTF-8
x-content-type-options: nosniff
x-meadow-attempts: 1
x-meadow-model: gemini-3.1-flash-lite-preview
x-meadow-provider: google
x-request-id: req_000006cc

[{
  "error": {
    "code": 400,
    "message": "temperature must be in the range [0.0, 2.0] but was 99",
    "status": "INVALID_ARGUMENT"
  }
}
]
```

Everything else (a connection error, a timeout, a 5xx, a 408, a 429, or the provider refusing your stored key with 401, 402, or 403) makes Meadow try the next provider. If every provider fails, you get a Meadow error with `attempts`.

To tell the two apart in code: a response with the header `x-meadow-provider` and a 4xx status came from that provider. Parse it in that provider's format. A response without it is a Meadow error, in the envelope of the route.

[Models](/call-models/models#response-headers) lists the `x-meadow-*` headers, and [Routing and fallbacks](/call-models/routing-and-fallbacks#what-triggers-a-fallback) lists every provider result and whether it falls back.

## Retrying

Safe to repeat as often as you like: every `GET`, every `DELETE`, and every `PUT`.

Safe to repeat only with an `Idempotency-Key` header: `POST /v1/sandboxes` and `POST /v1/sandboxes/{sandbox_id}/exec` with `background: true`. A repeat with the same key and body returns the first result. Without the header, each send creates a new sandbox or starts the command again.

Not safe to repeat blindly:

- `POST /v1/projects`, `POST /v1/keys` and `POST /v1/images` are safe to repeat with an `Idempotency-Key` header. A repeat within 24 hours returns the saved first response with `Idempotent-Replayed: true`. Only a 2xx is saved: after a 4xx or a 5xx the same key runs the request again. The value belongs to the API key that sent it. A replay carries no one-time secret: no `secret` on a key, no `webhook_secret` on a project. Without the header, list before you create again.
- A blocking or streamed command runs again.
- A model call. Retry it on a 429 only, after the seconds in `retry-after`. A 429 means no provider took the call, so a second send is safe. Do not resend it after a 5xx or a timeout: Meadow has already tried every provider in the route before it answers 5xx, so a retry repeats work the server already did. A provider may also have received and billed the failed call, and each send counts against the key's limits, so a blind retry can charge you twice. Meadow's own clients (the Python client, the Go SDK, and the `mdw` CLI) follow this rule and send any call at most 3 times. The OpenAI and Anthropic SDKs resend twice by default, also after a 5xx. See [Use your existing tools](/call-models/use-your-existing-tools#retries-and-errors).

A stream that Meadow ends during a restart carries a last error event (see [Streaming](/call-models/streaming)). A call that had no response yet gets 503 with `error.code` `server_restarting`, `retry-after`, and the header `x-should-retry`: `true` when the call is safe to send again (a GET, PUT or DELETE, a route dry run, or a sandbox create or background command start sent with `Idempotency-Key`) and `false` when the work may already have happened (a model call, a blocking command, any other POST, which includes a key, project or image create). OpenAI's SDKs obey that header.

When Meadow cannot reach its database, every route returns 503 with `error.code` `database_unavailable`, `retry-after`, and the same `x-should-retry` header. Wait for the seconds in `retry-after` and retry when `x-should-retry` is `true`. When it is `false`, the change may have been written before the connection was lost: read the resource first.

A background command start sent with `Idempotency-Key` can return two 409s of its own. `exec_start_in_progress` means another request is starting it right now: send the same request again after `retry-after`. `exec_start_failed` means the earlier start failed and nothing is running: that key can never succeed, so send the start again with a new `Idempotency-Key`.

A broken stream is a failed call. When a model stream breaks after its first event, Meadow ends it with one error event in the request's format (see [Streaming](/call-models/streaming#after-the-first-event)). Check for that event and for the format's final event, and retry the whole call if the final event is missing.

### Retry and outcome on sandbox routes

An error from a route under `/v1/sandboxes` carries two more fields in `error`. They use BoxRouter's names and values ([boxrouter.ai/docs/error-codes](https://boxrouter.ai/docs/error-codes)). They say in the body what the rules above say in prose.

| `error.retry` | Do | When |
| --- | --- | --- |
| `safe` | Send the same request again, after `retry-after` seconds when the response has that header. | A 429; a 409 `exec_start_in_progress` or `idempotency_request_in_progress`; a 502 `sandbox_unreachable`; a 5xx on a `GET`, `PUT` or `DELETE`, on `POST /v1/sandboxes/route`, or on a create or background start sent with `Idempotency-Key`. |
| `after_fix` | Change the request, the key or the account first. | Any other 4xx. |
| `check_outcome` | Read the sandbox or the command before you send it again. | A 5xx on any other `POST`, which includes a blocking or streamed command. |
| `never` | Do not send it again. | A 501. |

| `error.outcome` | Meaning | When |
| --- | --- | --- |
| `not_started` | Nothing was changed. | Every 4xx, a 501, a 502 `sandbox_unreachable`, and a 503 `database_unavailable` that came before the key check. |
| `unknown` | The work may have happened. | Any other 5xx. |

`completed` and `partial` are BoxRouter values that Meadow does not send today. Treat them as `unknown`.

When the response has `x-should-retry`, `retry` is `safe` when the header is `true` and `check_outcome` when it is `false`. The two never disagree.

A create that fails after Meadow accepted it is not an error response. `POST /v1/sandboxes` returns 202, and the sandbox later has `status` `failed` and a `failure_reason`. Read it before you create again.

The `error` event that ends a broken streamed command (`POST /v1/sandboxes/{sandbox_id}/exec` with `stream: true`) carries the same two fields, always `check_outcome` and `unknown`: the command started before the stream began. That holds when Meadow ends the stream for a restart too.

Other routes, the model routes included, do not carry these fields.

### retry-after

Every 429 carries a `retry-after` header in whole seconds.

```bash
for i in $(seq 1 120); do
  curl -sS -o /dev/null -w '%{http_code}\n' "$MEADOW_BASE_URL/v1/models" -H "Authorization: Bearer mdw_wrong"
done | sort | uniq -c
curl -sS -i "$MEADOW_BASE_URL/v1/models" -H "Authorization: Bearer mdw_wrong"
```

```text
  80 401
  40 429
HTTP/2 429
content-type: application/json
retry-after: 36
x-request-id: req_0000a8fb

{"error":{"message":"too many failed authentication attempts from this address","type":"rate_limit_error","param":null,"code":"auth_attempts_exceeded"},"request_id":"req_0000a8fb"}
```

Each server counts failed authentications on its own. Four servers answered in this run, so 80 attempts got a 401 before every server had counted its 20. With one server the 21st attempt gets the 429.

| Cause of the 429 | `retry-after` value |
| --- | --- |
| More than 20 failed authentications in a minute from one address, counted by each server | Seconds left in that minute. A request with a valid key is not affected. |
| A full server on which no slot came free in time (`account_in_flight_limit_exceeded`) | 1. Treat it as a floor. The request already waited up to 3 seconds for a slot. |
| A key limit check that waited too long (`key_limit_check_busy`), or a server holding too many large model request bodies (`large_request_limit_exceeded`) | 1. Read from the server's code, not seen on the hosted beta. |
| A provider's rate limit, when no other provider could serve the call | The provider's own value when it sent one, else 1. Not seen on the hosted beta yet. |

Back off from the header value and add jitter. A sample that does this for a read call:

```python
import os
import random
import time
import requests

BASE = os.environ["MEADOW_BASE_URL"]
HEADERS = {"Authorization": f"Bearer {os.environ['MEADOW_API_KEY']}"}


def get_with_retry(path, attempts=5):
    for attempt in range(attempts):
        resp = requests.get(f"{BASE}{path}", headers=HEADERS, timeout=30)
        if resp.status_code == 429 or resp.status_code in (500, 503):
            wait = float(resp.headers.get("retry-after", 2**attempt))
            time.sleep(wait + random.uniform(0, 1))
            continue
        return resp
    return resp


resp = get_with_retry("/v1/projects")
if resp.ok:
    print(resp.status_code, [p["name"] for p in resp.json()["data"]])
else:
    err = resp.json()["error"]
    print(resp.status_code, err["type"], err["message"])
```

With a valid key, then with a wrong one (project list trimmed):

```text
200 ['default', 'docs-rerun']
401 unauthorized invalid api key
```

## Request IDs

Every response carries an `x-request-id` header with Meadow's id for the request: `req_` and 24 hex characters. That covers served calls, errors, streams, and unknown routes. A response Meadow did not write has no id. The hosted beta's load balancer answers a request that is still open after 60 minutes with a 504 whose body is the text `stream timeout`, with no JSON and no `x-request-id`. The name is the one OpenAI uses, so the OpenAI SDKs read it into `_request_id` without changes. Every response of `/v1/messages` also carries the same id in a `request-id` header, the name the Anthropic API uses, so the Anthropic SDKs fill `message._request_id` and `error.request_id`. Every error body Meadow writes, in any of the three envelopes, repeats the id as `request_id`:

```json
{"error":{"code":"parameter_missing","message":"name is required","param":"name","type":"invalid_request"},"request_id":"req_0000252a"}
```

- A provider error that is passed through on a model route keeps the provider's body, so there Meadow's id is in the headers only. An Anthropic body passed through carries Anthropic's own `request_id`, which is not Meadow's.
- You can send your own id in an `X-Client-Request-Id` header, as on OpenAI: 1 to 512 printable ASCII characters, sent once. Anything else returns 400 `X-Client-Request-Id must be sent once and be 1 to 512 printable ASCII characters`. Meadow writes it to its log beside its own id and does not send it back.
- On model routes `x-meadow-provider-request-id` carries the request id of the provider that answered, for use with that provider's support.

## Report a problem

Send the `x-request-id` of the failed call. It finds the request in Meadow's logs. If you do not have it, send:

- The time of the request in UTC, to the second. The `date` response header has it.
- The method and path, such as `POST /v1/sandboxes`.
- The HTTP status and the full error body.
- The id of the key you used (`key_...`) and its project id. Never send the key's secret.
- The IDs involved: sandbox, exec, image, or project.
- For model calls: the `x-meadow-*` response headers and the model id you sent.

Leave out prompts, file contents, and provider keys. Support does not need them and Meadow does not log them.

Send reports to the support contact you were given when you joined the beta.

## API reference

Operation with its own error code: [`createSshAccess`](/reference/api-reference#createsshaccess).