Fixing API errors: 401, 403, 404, 429, 5xx

The status code tells you whose side the problem is on. Here is what each one means on 666 AI and the fix.

Replace YOUR-ENDPOINT with the endpoint shown on your API Key page after you sign up, and YOUR-KEY with your key. One key works for every model on 666 AI — Claude, GPT, Gemini, DeepSeek, Qwen and 200+ more.

Error table

StatusWhat it meansWhat to do
401 Invalid tokenThe API key is wrong, incomplete, deleted or disabled.Copy the key again from the API Key page (no spaces). Check the header is Authorization: Bearer YOUR-KEY (or x-api-key for /v1/messages).
403 insufficient quotaYour balance is not enough for this request.Top up, or lower max_tokens — the gateway reserves the maximum possible cost before the call.
404 model not found / Invalid URLWrong model ID, or the path is missing /v1.Copy the exact model ID from its model page. OpenAI SDKs need …/v1 in base_url; Anthropic SDKs need the base without /v1.
429Too many requests in a short time.Retry with exponential backoff (1s, 2s, 4s…).
500 / 502 / 503The upstream provider is temporarily failing.Retry; we automatically fail over to another supply route when one is available. If it persists, try another model.
200 but empty textA reasoning model spent all of max_tokens on thinking.Raise max_tokens (e.g. 2,000+) for reasoning models.

Retry safely

import time
from openai import OpenAI, APIStatusError

client = OpenAI(base_url="https://YOUR-ENDPOINT/v1", api_key="YOUR-KEY")

def ask(prompt, tries=4):
    for i in range(tries):
        try:
            return client.chat.completions.create(
                model="anthropic/claude-haiku-5.5",
                messages=[{"role": "user", "content": prompt}],
                max_tokens=500,
            ).choices[0].message.content
        except APIStatusError as e:
            if e.status_code in (429, 500, 502, 503) and i < tries - 1:
                time.sleep(2 ** i)
                continue
            raise

FAQ

Am I charged for failed requests?

No. Requests that fail are not charged.

Why 403 when I still have balance?

The gateway reserves the maximum cost of the request first. A huge max_tokens on an expensive model can exceed your balance — lower max_tokens or top up.

Create a free accountAll modelsDeveloper guides