API guides

Errors & limits

On this page

Check the HTTP status and X-Straitly-Error-Code header first before retrying. Retry temporary 429 rate limits and 5xx or 529 upstream overloads with Retry-After or backoff; stop retrying 401 invalid keys, 402 insufficient_credits, 402 quota_exceeded and 429 budget_exhausted.

Identify the error

Read the response body and headers. For gateway denials, X-Straitly-Error-Code carries the named reason, such as quota_exceeded or budget_exhausted. Do not assume error.code in the JSON body always contains that string.

The body shape depends on the endpoint dialect and where the error originated. Anthropic-format errors differ from OpenAI-format errors; upstream errors can vary too.

HTTP example
HTTP/1.1 402 Payment Required
X-Straitly-Error-Code: quota_exceeded
X-Straitly-Action: raise_cap

{
  "error": {
    "message": "This key has reached its daily spend cap.",
    "type": "invalid_request_error",
    "code": 402
  }
}

Illustrative gateway denial. Keep the error message and request context for diagnosis, but never log your Authorization header or raw API key.

Error reference

401

invalid_api_key

The key is missing or invalid.

Check the bearer header and the key supplied by your server environment.

Fix credentials first
401

key_revoked

The key was revoked.

Replace it with an active key and update the application environment.

Replace the key
402

insufficient_credits

Your prepaid balance is exhausted.

Add credits. Do not keep retrying the same rejected request in a tight loop.

Add credits first
402

quota_exceeded

This key reached its daily spend cap.

Review the key's cap or wait for the UTC day to reset. Other keys have their own caps.

Review cap / wait for reset
404

model_not_found

The requested model is not enabled.

Check the model ID against GET /models. For other 404s, check the endpoint and base URL too.

Fix the request
429

rate_limit_exceeded

The request-rate limit was exceeded.

Wait for Retry-After, then retry with a bounded retry policy. Reduce request bursts.

Wait, then retry
429

concurrency_limit_exceeded

Too many requests are in flight.

Let active requests finish and reduce parallelism. Respect Retry-After.

Reduce concurrency
429

budget_exhausted

A child key used its lifetime budget.

Review the child key's budget. It does not reset like a per-minute rate limit.

Budget change required
5xx, such as 529

upstream_overloaded

The last source Straitly tried was at capacity, for example after Claude returned 529 overloaded_error. If no output has been sent yet, Straitly tries the model's other sources first. Message: "The model is at capacity right now. Please retry shortly."

Retry with backoff. A source's 5xx status comes back as is; a source's 429 comes back as 502.

Retry with backoff
5xx

upstream error

The gateway or provider could not complete the request.

Use bounded backoff for transient failures. If it persists, inspect Activity and contact support.

Bounded retry

What does Claude 529 overloaded mean?

Anthropic's errors page (read Nov 23, 2026): "529 - overloaded_error: The API is temporarily overloaded." and "A 529 error can occur when the API experiences high traffic across all users."

Through Straitly, a 529 before any output moves the request to the next source for that model. If the last source tried is also at capacity, or the 529 comes mid-stream, you get upstream_overloaded (above). Retry with backoff; Anthropic's SDK already retries 5xx errors twice by default.

Retry safely

  • For request-rate or concurrency limits, respect Retry-After when it is present. If no usable retry hint is returned, use exponential backoff with jitter and a maximum attempt count.
  • Stop automatic retries for invalid credentials, exhausted credits, spending caps, and lifetime budgets. Waiting a few seconds does not fix these conditions.
  • Check whether your SDK already retries. Adding an outer retry loop can multiply attempts unexpectedly.
  • A timeout can leave the outcome uncertain. Inspect request history and avoid blindly repeating external tool actions or other side effects.
  • After a partial stream, treat a retry as a new generation. Do not silently append the new answer to the old one.

Not every 429 is temporary: budget_exhausted needs a budget change. An HTTP retry hint is not permission to bypass a spending limit.

Error messages, word for word

Search this list for the exact message you got. Each one names its cause and the fix.

402

"Your credit balance is exhausted. Add credits at https://straitly.ai/app/wallet to keep going."

The account or team that owns this key has no credit left. If your balance shows money, the key usually belongs to another account or team organization, which has its own balance.

Top up the account that owns the key, or use a key from the account that has the balance.

Add credits first
429

"Your remaining credit is already committed to requests in progress."

Requests that are still running hold the little credit that is left (concurrency_limit_exceeded).

Wait for those requests to finish, or add credits.

Retry after they finish
404

"Model '...' is not configured on this gateway. Call GET /v1/models for the list this key can use."

The model id is misspelled, retired, or not available to this key.

Copy the id from GET /v1/models. Use the id, not the display name.

Fix the request
403

model_not_allowed_for_key

This model is turned off on this key, for example after repeated content-filter blocks. Other models on the key still work.

Use another model, or reply to the email we sent about it.

Do not retry
401

key_revoked

The key was revoked, or paused after content-filter blocks on several models.

Use an active key. For a paused key, reply to the email we sent.

Replace the key
200

finish_reason "content_filter"

The model's safety filter stopped the answer. The reply can be empty or cut short.

Rephrase the request or choose another model. Repeated blocks on one key can turn that model off for the key.

Do not resend unchanged
400

"The model declined to respond to this request."

The model refused the prompt (content_refused).

Change the prompt. Sending it again unchanged gets the same answer.

Do not resend unchanged
400

"This request exceeds the model's context window. Reduce the input and retry."

Input plus requested output is larger than the model's context window.

Trim history or files, lower max_tokens, or pick a model with a larger window.

Fix the request
400

"Inline attachment is larger than the 10 MB (10485760 bytes) per-attachment limit."

One image or file is over the per-attachment limit.

Resize or compress it. All inline attachments together can be up to 32 MB.

Fix the request
400

"This attachment is declared as image/jpeg but the file is a PDF."

A PDF was sent as an image.

Send PNG, JPEG, GIF or WebP images, or send the PDF's text.

Fix the request
400

"Image data is empty or unreadable (3 bytes)."

The base64 data is not a real image, often a broken upload or a placeholder.

Check the file you encode and the data URL prefix.

Fix the request
400

"This model does not accept audio input. Send audio to a Gemini model, or send a transcript instead."

input_audio was sent to a model without audio input.

Use a Gemini model with audio, or send text.

Fix the request
400

"Unsupported input_audio format 'flac'. Use one of: wav, mp3."

Only wav and mp3 audio are accepted.

Convert the audio to wav or mp3.

Fix the request
400

"This model does not support tool calling."

tools were sent to a model without tool support.

Remove tools, or pick a model that supports them.

Fix the request

Rate and concurrency

Account limits are shared across your keys. Requests per minute counts how often you send requests; concurrency counts how many are still running. A long streaming response occupies an in-flight slot until it ends.

Your account can have custom limits. Use the Limits page for your current values and higher-limit requests instead of relying only on this default table.

Rate-limit denials carry Retry-After and may include X-RateLimit-Limit and X-RateLimit-Remaining. Do not assume every error or successful response has the same headers.

Starter
300 / minute64 requests in flight. Default account limits.
Growth
1,000 / minute200 requests in flight.
Scale
3,000 / minute500 requests in flight.

Spending controls

Daily caps track billed spend, including charges still settling. The displayed tally can lag by about a minute, so treat the cap as a spend control rather than an exact, instantaneous cutoff.

Review limits intentionally before raising them. A capped key stopping does not mean that every other key on the account has stopped.

Account balance
Prepaid creditsShared by requests billed to the account. Exhaustion blocks new paid requests.
Daily key cap
UTC dayEach key has its own optional cap. The daily window resets at the UTC day boundary.
Child-key budget
LifetimeA fixed budget does not reset daily or each minute. Review it before allowing more spend.

Diagnose a failure

  • Record the time, model ID, endpoint, HTTP status, and X-Straitly-Error-Code when present.
  • Inspect Activity for a recorded request and its upstream error. Not every rejected or network-failed attempt is guaranteed to have an individual history row.
  • Failed requests are not billed. For an interrupted stream, inspect the final recorded status and charge instead of assuming the client-side error defines the bill.
  • When contacting support, include a request identifier if available and a redacted error message. Never include a raw key or a setup command containing one.

Common questions

How do I tell which Straitly error happened?

Check the HTTP status code and the X-Straitly-Error-Code response header first. Gateway denials put the exact reason in X-Straitly-Error-Code, such as insufficient_credits, quota_exceeded, rate_limit_exceeded or budget_exhausted, even when OpenAI and Anthropic error body shapes differ.

Which errors should my code retry and which should it stop?

Retry 429 rate_limit_exceeded, 429 concurrency_limit_exceeded and transient 5xx or 529 upstream_overloaded responses with Retry-After or bounded backoff. Stop automatic retries on 401 invalid credentials, 402 insufficient_credits, 402 quota_exceeded and 429 budget_exhausted.

What does a Claude 529 overloaded error mean on Straitly?

Anthropic 529 overloaded_error means the upstream provider is temporarily at capacity. Before any output has streamed, Straitly tries the model's other sources first; if the last source is also at capacity or 529 happens mid-stream, Straitly returns upstream_overloaded so you can retry with backoff.

Are failed API requests billed?

No. Failed requests are not billed and appear in Activity at zero cost with the recorded status and error reason. For an interrupted mid-stream disconnect, inspect Activity for the final recorded usage and charge.

Why did a 429 return budget_exhausted instead of resetting?

429 budget_exhausted means a child key reached its lifetime total_cap_usd budget, which does not reset every minute or day. Raise the child key's total_cap_usd via PATCH /v1/admin/keys/{key_hash} or mint a new key.