# Routing, Billing, and Errors

> Learn how LLMoxy selects providers, settles usage, and what error responses mean.

LLMoxy routes your request to an available upstream provider and automatically retries when the upstream temporarily fails. As a user you only need to specify the model; the gateway handles the rest.

## Routing

When submitting a request, specify the `model` you want to call, and LLMoxy will:

1. Pick a healthy provider from those that support the model and send the request.
2. Automatically switch to another provider and retry on temporary errors (e.g., 5xx, some 429s, or timeouts).
3. If all providers fail, return the last error to you in OpenAI style.

You do not need to configure any routing rules, nor do you need to know which provider the current request lands on.

## Request Formats

The same key can call models through different format endpoints. Choose the one your application already uses:

| Format | Route |
| --- | --- |
| OpenAI Chat | `POST /v1/chat/completions` |
| OpenAI Responses | `POST /v1/responses` |
| Anthropic Messages | `POST /v1/messages` |
| Gemini | `POST /v1beta/models/{model}:generateContent` |
| Embeddings | `POST /v1/embeddings` |
| Rerank | `POST /v1/rerank` |
| OpenAI Video | `POST /v1/videos` |

## Billing

After the request completes, LLMoxy charges based on the token usage returned by the upstream, covering prompt, completion, cache, audio, image, and reasoning tokens. Billing is per-request; there is no monthly subscription minimum.

Real-time balance and unit prices are based on the console:

- **Wallet**: remaining balance and recharge history.
- **Pricing**: current unit price for each model.
- **Logs**: actual charge and token count for each request.

## Error Responses

All errors use a unified OpenAI-style structure:

```json
{
  "error": {
    "message": "error message",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_request"
  }
}
```

Common status codes:

| Status Code | Common Cause |
| --- | --- |
| `400` | Invalid request body or unsupported parameters. |
| `401` | Key missing, misspelled, or disabled. |
| `403` | Account disabled, IP not on allowlist, balance exhausted, or subscription unavailable. |
| `404` | Model or route unavailable. |
| `429` | Your key rate limit triggered, or all upstream providers hit capacity at the same time. |
| `5xx` | All upstream providers returned errors, or a gateway internal failure. |

For any display involving amounts or usage, read the console or the most recent request response directly. Do not use cached values.

This is the markdown version of https://en.llmoxy.com/docs/api-reference/routing-billing-errors.
