Keys, models, and common failures
Start with the exact response, then check key visibility, model availability, and task state.
401 / invalid key
Check the full Bearer token, that the key still exists in API Keys, and the gateway base URL.
Model not found during inference
HTTP 404 with error.code model_not_found (on /v1/messages, error.type not_found_error). Do not retry unchanged: call GET /v1/models with the same key and copy the public id exactly.
Model lookup returns HTTP 200 with an error
GET /v1/models/{id} can return HTTP 200 with error.code: model_not_found, even for a valid id. Check the response body and use GET /v1/models/{id}?expand=parameters. If that still returns the error, check GET /v1/models with the same key.
Slow media task
Poll instead of resubmitting. Stop when the status is completed or failed.
Balance is enough but request fails
Read error.message and keep the request id that most messages end with. Check the model id with GET /v1/models and the fields on the model page; if it still fails, send us the request id in live chat.
- Never expose a key in frontend code or commit it to a repository.
- Use model-specific pages for parameter names; do not send every provider field “just in case”.
- When a result URL is returned, treat it as opaque and download it within 24 hours, before it expires.