LiteRouter Docs

Errors

LiteRouter uses standard HTTP status codes and returns a JSON error body.

Status codes

CodeMeaningWhat to do
400Invalid requestCheck the error message, request fields, and endpoint compatibility. If a model is unavailable on /v1/responses, use /v1/chat/completions or a compatible model.
401UnauthorizedMissing or invalid API key.
403Access or usage deniedRead the error message. Check your key, the model's required plan, and your credit balances. Daily credits reset at 00:00 GMT+7.
404Unknown endpointCheck the URL against the endpoint reference.
429Too Many RequestsSlow down; you hit a rate limit.
500Internal errorTry again shortly, or contact support if the problem persists.
502Upstream request failedCheck 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.