DevKits

LLM API Errors — Meaning & Fix

A quick reference for the errors you actually hit calling OpenAI, Anthropic, and Gemini APIs — what each one means and the fastest way to fix it.

400context_length_exceeded· OpenAI, Azure

What it means: Your prompt plus the requested max_tokens exceeds the model's context window. The request is rejected before any tokens are generated.

How to fix: Shorten the prompt, lower max_tokens, or switch to a larger-context model. Check the prompt against the window first with a context-window checker.

Context Window Checker
400invalid_request_error (Anthropic) / INVALID_ARGUMENT (Gemini)· Anthropic, Google

What it means: Malformed request — usually a bad messages array, an unknown parameter, or a schema that doesn't match the provider's tool format.

How to fix: Validate your messages array roles/content and confirm your tool definitions match the provider's exact envelope.

Schema → Tool Definition
401invalid_api_key / authentication_error· All

What it means: The API key is missing, revoked, or wrong. Common when the key isn't loaded from the environment or a trailing space sneaks in.

How to fix: Confirm the key is set in your environment (never hard-coded), has no whitespace, and belongs to the right org/project.

403permission_denied / model_not_found· OpenAI, Anthropic, Google

What it means: Your key is valid but not allowed to use this model — often a model you haven't been granted access to, or a region restriction.

How to fix: Request access to the model, use a model your tier supports, or check regional availability.

404model_not_found· All

What it means: The model name is misspelled or has been deprecated and removed.

How to fix: Use the exact current model id. Deprecated models are removed on a schedule — check the provider's model list.

Current model list & pricing
429rate_limit_exceeded / too_many_requests· All

What it means: You've exceeded requests-per-minute (RPM) or tokens-per-minute (TPM) for your tier. The most common production error.

How to fix: Add exponential backoff with jitter, batch requests, or raise limits by upgrading tier. Respect the Retry-After header when present.

429insufficient_quota· OpenAI

What it means: Different from a rate limit — your account has no remaining credit or billing isn't set up. The wording is misleading; it's a billing issue, not throughput.

How to fix: Add a payment method or top up credits. This won't resolve with backoff.

500server_error / api_error· All

What it means: An unexpected error on the provider's side. Usually transient.

How to fix: Retry with exponential backoff. If it persists, check the provider's status page.

503overloaded_error· Anthropic

What it means: Anthropic's API is temporarily overloaded. Spikes during peak hours.

How to fix: Retry with backoff and jitter. Consider a fallback model or provider for high-availability paths.