Models → Pricing → Docs → Blog → Changelog → Contact → Status →
Get started freeLog in

Errors and status codes

Every error the API sends, what causes it and what to do about it.

⏱ 6 min read

Error format

On the OpenAI-format endpoints (/v1/chat/completions, /v1/responses, /v1/models) an error is a JSON body with an HTTP status code that is not 2xx:

{
  "error": {
    "message": "The model 'gpt-4o' does not exist on FreeModel. Only models listed on https://freemodel.in/models are supported.",
    "type": "invalid_request_error",
    "code": "model_not_found",
    "param": "model"
  }
}

Use code in your program and show message to people. param is only present when one field caused the error.

Anthropic format

Requests to /v1/messages, and requests that carry an anthropic-version, x-api-key or anthropic-api-key header, get the Anthropic error shape instead. It has no code field; the type follows the HTTP status:

{
  "type": "error",
  "error": {
    "type": "billing_error",
    "message": "Your plan tokens are used up. Renew or upgrade your plan at freemodel.in/dashboard/plan to continue. Your wallet balance is never charged automatically."
  }
}
HTTP statusAnthropic error.type
401authentication_error
402billing_error
403permission_error
404not_found_error
429rate_limit_error
503 (sent as 529)overloaded_error
500, 502, 504api_error
anything elseinvalid_request_error

In this format a 503 is sent as HTTP 529, and 429 and 529 responses carry Retry-After: 3 and retry-after-ms: 3000, which Anthropic SDKs and Claude Code use for their automatic retry.

The Gemini endpoints use Google's error shape for errors from the model call; see Gemini API format.

Error reference

401 — authentication

CodeCauseFix
invalid_api_keyNo key was sent, the key is wrong, or it was revoked.Send Authorization: Bearer fm_… or x-api-key: fm_…. Check the key at Dashboard → API keys; a rotated or revoked key stops working at once.
key_expiredThe key has an expiry date and it has passed.Extend the date on the key or create a new key.
user_not_foundThe account that owned the key no longer exists.Create a new account and key.

402 — tokens or limits used up

A 402 means the request was refused before it reached a model. Nothing was charged. Retrying will not help until the limit changes, so do not retry in a loop.

CodeCauseFix
tokens_exhaustedThe plan tokens of the account are used up. On the free plan: the free tokens are used up.Renew or upgrade at Pricing; on the free plan, buy a plan for more usage or invite a friend. The wallet balance is never charged automatically.
prompt_exceeds_quotaThe estimated prompt size, times the model's multiplier, is more than the tokens you have left.Shorten the prompt, use a model with a lower multiplier, or add tokens.
key_token_limit_reachedThis API key reached the token limit you set on it.Raise or remove the limit on the key in the dashboard.
key_spend_limit_reachedThis API key reached the spend limit you set on it.Raise or remove the spend limit on the key.

403 — not allowed

CodeCauseFix
upgrade_requiredA free account asked for a model that needs a paid plan. The message lists the models your free tokens work with.Use one of the free models (GPT-6.2 Astra, GPT-6 Luna, Grok 4.6, Grok 4.7, Claude Haiku 5.5, GLM-5.3 Flash, Qwen 3.8 Omni Flash and DeepSeek V4.1 Flash 1017) or buy a plan.
telegram_verification_requiredA free account has not done the one-time Telegram verification yet.Verify Telegram in the dashboard. See Free plan.
insufficient_scopeThe key does not have the scope this endpoint needs (inference, models:read or embeddings).Create a key with that scope. See API keys.
key_pausedYou paused this key in the dashboard.Resume the key.
account_bannedThe account was suspended.Contact support.

400, 404, 413, 422 — the request itself

StatusCodeCauseFix
404model_not_foundThe model id is not on our list. We only serve listed models: a name such as gpt-4o or claude-3-5-sonnet is not mapped to another model.Use an id from Models or GET /v1/models. See Model IDs.
404model_not_availableThe model exists but is not available on this account.Pick another model from the list.
400 / 422invalid_jsonThe body is not valid JSON (422 on chat completions, 400 on messages and responses).Send a JSON body with Content-Type: application/json.
400 / 422validation_errormodel or a non-empty messages array is missing.Add the required fields.
400missing_input, bad_request/v1/responses got an empty body or no usable input.Send input as a string or an array of items.
400 / 413context_length_exceededThe conversation is longer than the model's context, or a free account sent a request of more than 128,000 tokens.Shorten or compact the conversation.

429 — too many requests

CodeCauseFix
rate_limit_exceededThis key sent more requests in the last 60 seconds than its requests-per-minute limit.Wait the number of seconds in Retry-After.
account_rate_limit_exceededAll keys of the account together passed the plan's requests per minute.Wait for Retry-After, or upgrade. More keys do not add more requests.
too_many_concurrentToo many requests are running at the same moment for this account (10 normally, 3 on the free plan, fewer when tokens are nearly used up).Retry when a running request finishes.
free_tpm_limitA free account sent more than 400K tokens in a minute (all keys and models together).Wait the number of seconds in Retry-After.

Details are on Rate limits.

502, 503 — temporary problems

StatusCodeCauseFix
503model_temporarily_unavailableThe model you asked for has no working route right now. We do not answer it with a different model.Retry after a short wait, or pick another model.
503model_under_maintenanceThe model is in scheduled maintenance.Use another model or try again later.
503service_under_maintenanceThe API is in maintenance. Sent with Retry-After: 1800.Try again later; see Status.
503free_tokens_pausedFree usage is paused for a while because of load. Paid plans are not affected. Sent with Retry-After: 300.Retry later.
503no_upstream_capacity, upstream_node_overloaded, engine_capacity_exceededThe model provider failed or is overloaded.Retry with backoff.
429upstream_capacity_exhaustedThe model provider is rate limiting. Sent with Retry-After: 5.Retry with backoff.
502upstream_malformedThe provider's answer could not be read.Retry.

Errors during a stream

If a streamed chat completion fails after the first bytes were sent, the HTTP status is already 200. The error then arrives as a server-sent event:

event: error
data: {"error":{"message":"…","type":"api_error","code":"upstream_node_overloaded"}}

On /v1/responses a failure after the stream started is sent as a response.failed event whose response.error holds a code and message.

Billing and retries

  • A request that ends with an error status (400 or higher), or that produced no output, is not charged. It still appears in your usage log with its status and error, so you can see what happened.
  • Retry 429, 502, 503 and 529 with exponential backoff, and respect Retry-After.
  • Do not retry 401, 402, 403 or 404 without changing something first: the same request will fail the same way.
import time
from openai import OpenAI, APIStatusError

client = OpenAI(api_key="fm_your_key_here", base_url="https://freemodel.in/v1")

def ask(prompt, tries=4):
    for attempt in range(tries):
        try:
            r = client.chat.completions.create(
                model="gpt-6-luna",
                messages=[{"role": "user", "content": prompt}],
            )
            return r.choices[0].message.content
        except APIStatusError as e:
            if e.status_code in (429, 502, 503, 529) and attempt < tries - 1:
                wait = int(e.response.headers.get("retry-after", 2 ** attempt))
                time.sleep(wait)
                continue
            raise

The OpenAI and Anthropic SDKs already retry some of these statuses themselves; check their max_retries setting before adding your own loop.

Was this page helpful?
Still stuck?
Open a support ticket from your dashboard or message our support bot on Telegram.
Telegram supportGet help