In this section: Errors

Errors

See every Chat API status, along with its cause and fix.

The envelope

Every error uses the OpenAI JSON shape, including 413 errors raised before body parsing and errors raised mid-stream. The exception is an OAuth bearer that fails its check, which gets the RFC 6750 shape, {"error": "invalid_token", "error_description": "access token expired"}.

{"error": {"message": "api key revoked or unknown", "type": "invalid_request_error", "code": "invalid_api_key"}}

A 401 includes WWW-Authenticate: Bearer realm="askmiles", error="invalid_token" with an error_description; a 401 for a missing bearer carries Bearer realm="askmiles" alone. This lets OAuth-aware SDKs apply the same retry logic for either bearer type. A 429 carries Retry-After. Every error response is no-store except one raised before the request reaches the endpoint, such as the 413.

One more error skips both shapes: a plain-text 403 from Cloudflare, returned before Miles sees the request when the User-Agent is a stock Python-urllib. Use a client library.

The table

Statustypecode or messageCauseFix
400invalid_request_errorrequest body must be a JSON objectThe body was not an objectSend {"model": "miles", "messages": [...]}
400invalid_request_errornames the fieldA role other than system/user/assistant, an image or audio part, a malformed messages entry, a last message that is not user, a message over 5,000 characters, or a conversation over 130,000 characters in totalRemove the part or trim the messages; only text content is read
401invalid_request_errorinvalid_api_keyThe personal API key was revoked or never existed, or its account was deletedMint a new key
401none (RFC 6750 body)invalid_tokenThe OAuth access token expired, was revoked, or is not a Miles credentialRefresh the token, or authorize again
401none (RFC 6750 body)invalid_requestNo bearer token was sentSend a personal key or a miles:chat token
403none (RFC 6750 body)insufficient_scopeThe OAuth token lacks miles:chatAuthorize again with miles:chat
403invalid_request_errorconnections_pausedThe account paused its AI app connections. An OAuth token gets the same code in the RFC 6750 bodyThe user turns them back on at Settings → Connected AI Apps; nothing to re-mint
413invalid_request_errorThe data value transmitted exceeds the capacity limit.The body exceeded the 2 MB size capTrim history; Miles reads only the new question and the last 26 earlier messages anyway
429rate_limit_exceededrate limited, retry after NsThe per-minute window is full. GET /v1/models has its own such window, separate from the one completions useWait Retry-After; safe to retry
429rate_limit_exceededconcurrency limited, retry after 2sAnother turn is running on this grant or on another grant of the same account, or the service is at its shared ceilingReduce parallelism, then retry
429rate_limit_exceededYou've reached today's usage limit. Please try again later.The account's daily spend allowance is full. This is not the per-minute window and does not clear in a minuteWait Retry-After, which is an hour here; the allowance is a rolling 24 hours, so capacity returns as earlier spend ages out
429insufficient_quotaYou've used this month's budget. It resets on …, or a trial-budget message during a Membership trialThe account's monthly budget is spentWait Retry-After, which is the seconds until the reset date and can be days, so do not retry on the usual 429 schedule. Members get a much larger monthly budget
500server_errorthe pipeline failed to answerMiles could not produce an answerRetry once; if it repeats, the outage is on Miles' side
504timeout_errorthe request took too long to answerA non-streaming turn passed 90 secondsRetry with stream: true, which has no turn timeout

The endpoint holds no state, so retrying a 429 or 504 cannot leave a partial write. A 400, 401, or 403 returns the same answer until its cause changes.

Mid-stream

After a stream opens, an error arrives in one final data: event with the envelope above, and the stream closes with no data: [DONE]. The stream's HTTP status is already 200, so read the event.

Catalog and MCP errors

See Catalog errors for the keyless catalog API's {"error": "message"} shape. MCP tool refusals arrive as isError results with a structured code. The Quotas and refusals page documents them. The Error codes reference has an anchor for every type and code in this endpoint's envelope and every MCP and tool refusal code. invalid_token, invalid_request and insufficient_scope are RFC 6750 bearer errors, and WWW-Authenticate carries invalid_token and insufficient_scope. They have no Miles refusal-code entry. This page is their only documentation.