Errors
LiteRouter uses standard HTTP status codes and returns a JSON error body.
Status codes
| Code | Meaning | What to do |
|---|---|---|
400 | Invalid request | Check the error message, request fields, and endpoint compatibility. If a model is unavailable on /v1/responses, use /v1/chat/completions or a compatible model. |
401 | Unauthorized | Missing or invalid API key. |
403 | Access or usage denied | Read the error message. Check your key, the model's required plan, and your credit balances. Daily credits reset at 00:00 GMT+7. |
404 | Unknown endpoint | Check the URL against the endpoint reference. |
429 | Too Many Requests | Slow down; you hit a rate limit. |
500 | Internal error | Try again shortly, or contact support if the problem persists. |
502 | Upstream request failed | Check that the model supports the endpoint. For a temporary failure, retry shortly. If the message says the conversation must end with a user message (for example Requests ending with a model turn are not supported), turn on User Role Injection. |
Timeouts and disconnects
- If your app stops waiting before a reply arrives, the request stops and costs nothing.
- With streaming, the request is billed once the reply has started, even if you stop it early.
- If the provider breaks off a reply, it costs nothing.
- For long replies, turn streaming on so text starts arriving right away and your app does not give up waiting.
Error body
The shape varies by endpoint: error may be a string or an object containing message. Read either form; do not rely on every error having a code field.
json
{
"error": {
"code": "invalid_api_key",
"message": "The provided API key is invalid.",
"type": "authentication_error"
}
}
💡
On 429 and 502, retry with exponential backoff. Wait a bit longer after each failed attempt.