HTTP Status Codes
| Code | Meaning | What to Do |
|---|---|---|
200 |
Success | — |
400 |
Bad request | Fix request body or model name |
401 |
Unauthorized | Check your API key |
402 |
Insufficient balance | Top up the client token |
403 |
Forbidden / token context missing | Check token scope |
429 |
Rate limited | Retry after 30–60 seconds |
500 |
Server error | Retry request |
503 |
No keys available | Wait for key cooldown (1–10 min) |
Error Response Format
{
"error": {
"code": "http_error",
"message": "Human-readable error description"
}
}
Provider content filtering
A chat request blocked by the content filter returns HTTP 400 with error.code: "content_filter", rather than an empty successful completion. The message includes the provider reason, such as PROHIBITED_CONTENT, without exposing withheld text. It is not charged to the client and is not automatically replayed. A legitimate empty answer with STOP remains successful.
For streaming, a block before the first emitted chunk returns the same HTTP error. If the stream already started, its HTTP status stays 200; an SSE error frame carries code: "content_filter" and status: 400 before [DONE]. Treat that response as incomplete.
Common Errors
| Error Message | Cause | Fix |
|---|---|---|
Missing Authorization header |
No Bearer token | Add Authorization: Bearer KEY header |
Capacity exhausted, please retry shortly |
All capacity for the requested model is temporarily saturated | Back off and retry (see strategy below) |
Model not found |
Invalid model name | Check model tables above |
Content blocked by safety filters |
Prompt flagged | Modify your prompt |
Retry Strategy
import time
from openai import OpenAI, APIError
client = OpenAI(
base_url="https://gateway.api429.com/v1",
api_key="YOUR_API_KEY"
)
for attempt in range(3):
try:
response = client.chat.completions.create(
model="gemini-3-flash",
messages=[{"role": "user", "content": "Hello"}]
)
break
except APIError as e:
if e.status_code in (429, 503):
time.sleep(30)
continue
raise
Quickstart: the first request · Models and prices · Get an API key