Error codes
Error codes
fremai returns errors in the OpenAI-compatible error envelope, so existing OpenAI error-handling works unchanged.
Envelope
{
"error": {
"message": "Human-readable description of what went wrong.",
"type": "invalid_request_error",
"param": null,
"code": null
}
}message— a human-readable explanation.type— the error category.param— the offending request field, when applicable (elsenull).code— a machine-readable code, when applicable (elsenull).
HTTP status codes
| Status | Meaning | What to do |
|---|---|---|
400 | Bad request — malformed body or invalid parameters. | Fix the request. Check param for the offending field. |
401 | Unauthorized — missing or invalid API key. | Check the Authorization: Bearer sk-fremai-… header; rotate the key if needed. |
402 | Payment required — prepaid credit exhausted or a budget cap reached. | Top up or raise the budget in the console. |
404 | Model not found — the requested model is not in your catalog. | Use an id from GET /models or the catalog. |
429 | Rate limited — a rate, token, or concurrency limit was exceeded. | Back off for the Retry-After interval, then retry. See rate limits. |
Handling 429
A 429 includes a Retry-After header (seconds). Respect it before retrying:
HTTP/1.1 429 Too Many Requests
Retry-After: 5The official OpenAI SDKs implement Retry-After-aware backoff automatically. If you build your own client, add exponential backoff that honours the header.
Handling 402
A 402 means you have run out of prepaid credit or hit a budget cap. It is not a transient error — retrying will keep failing until you top up or raise the budget in the console. Wire threshold alerts (see rate limits & budgets) so you are warned before this happens.