
Common API Errors and How to Fix Them
Almost every problem starts with the HTTP status code. The body usually explains the detail, but the code tells you which class of fix to reach for before you read a single line.

The usual suspects 🕵️
| Status | Meaning | Fastest fix |
|---|---|---|
| 401 | Missing or invalid key | Check the Authorization header and the token value |
| 400 | Malformed request | Validate JSON and required fields before sending |
| 404 | Unknown model or path | Check the model name and the endpoint URL |
| 429 | Too many requests | Back off and retry with growing delays |
| 5xx | Server side error | Retry once, then check the status page |
Copy-paste mistakes that cause 401 🔐
- The header must be Authorization: Bearer <token>
- Trailing spaces or newlines in the token break it
- A token from another environment will not work here
- Rotated or deleted tokens stop working immediately
Retry only what is safe 🔁
Retry network errors and 5xx responses with exponential backoff and a cap. Do not blindly retry a 400 or 404, because the request will fail the same way every time and you will only waste time and tokens.
When the error is yours to fix 🛠️
Validate input locally before the call, log the status code and body together, and include a request identifier in your logs. That single habit turns a mystery into a two-minute fix.
Frequently asked questions ❓
Why do I get 401 with a token that used to work?
The token may have been rotated, deleted or copied with extra whitespace. Create a fresh token and check the header format.
Should I retry a 429 right away?
No. Wait, then retry with growing delays, and reduce your request rate so the limit is not hit again.
What does model_not_found mean?
The model name in your request is not available on your account. Check the spelling against the list of models you can use.
A request timed out but I was still charged?
Output produced before a timeout can still be billed. Keep timeouts sensible and avoid firing repeated duplicate requests.
Comments (0)