# Billing

## Price

Charge = official price × (1 − discount). Official prices match the vendor's; "80% less" means 20% of the official price. Your balance is in US dollars and the cost is deducted after each request.

A model can have several providers at different prices. Requests go to the cheapest one by default, or you can pick with the `provider` object (see [OpenRouter compatibility](https://www.aixapi.io/docs/openrouter)). Each model's page in the [Model hub](https://www.aixapi.io/model-plaza) lists every provider's price.

## Price list API

`GET https://www.aixapi.io/api/v1/public/pricing` returns the [Pricing](https://www.aixapi.io/pricing) page as JSON. No API key is required.

```json
{
  "currency": "USD",
  "unit": "per_1m_tokens",
  "generated_at": "2026-11-03T01:39:16Z",
  "groups": [
    {
      "id": 16,
      "name": "Claude Economy",
      "platform": "anthropic",
      "models": [
        {
          "model": "claude-opus-5",
          "vendor": "Anthropic",
          "billing_mode": "token",
          "input": 1.35,
          "output": 6.75,
          "cache_read": 0.135,
          "official_input": 5,
          "official_output": 25,
          "vs_official": 0.27
        }
      ]
    }
  ]
}
```

| Field | Meaning |
|---|---|
| `input` / `output` / `cache_read` / `cache_write` | USD per million tokens |
| `per_request` | USD per request, for per-request priced models |
| `official_input` / `official_output` | Official USD price per million tokens |
| `vs_official` | Input price as a share of the official price (0.27 = 27%) |
| `long_context_tiers` | Priced by context length; the lowest tier is shown |
| `time_pricing` | Has time-of-day multipliers |

Image and video models are not listed.

## Metering

| Kind | Billed at |
|---|---|
| Input | Input price (excluding cached tokens) |
| Output | Output price, including thinking tokens |
| Cache read | Cache-read price |
| Cache write | Cache-write price (Claude: 5-minute / 1-hour) |
| Image input / output | Image prices |
| Image, video generation | Per image / per second |

## Caching

Cached tokens are billed at the cache-read price.

## Long context

The tier is chosen by input-side tokens (input + cache read/write); above the threshold the whole request is billed at the higher tier. Tiers are listed on each model's page.

## Service tier

`service_tier` (OpenAI models): `priority` costs more, `flex` costs less; standard price by default.

## Failures and interruptions

You are billed only when a request actually gets a result from upstream, using the usage upstream reports. There is no minimum charge.

**Not billed**

- Upstream errors (4xx / 5xx / 429 / 529, etc.), connection failures, timeouts and mid-stream breaks that happen before any output.
- Failed attempts when the gateway retries or switches routes. Only the attempt that finally succeeds is billed.
- Non-streaming Claude requests cancelled before upstream responds.
- The token counting endpoint (`count_tokens`).
- Failed or cancelled images in batch image jobs. The held amount is released.

**Billed**

- Successful requests with empty output: input and cache tokens are still billed.
- A stream that ends early is billed for the part already delivered: input and cache tokens, plus the output already sent to you. Hidden reasoning tokens that upstream reports (such as OpenAI reasoning tokens) count as output; anything upstream does not report is not billed. This covers two cases:
  - The client disconnects, for example by pressing Esc in Claude Code. The gateway stops sending to you right away instead of billing the full usage.
    - Claude endpoints: it also stops reading upstream.
    - OpenAI Responses endpoints: it keeps reading upstream in the background and bills the real input and cache usage upstream reports. Output is still only what was sent to you plus the reasoning tokens upstream reports, and never more than upstream's reported output.
  - Upstream drops or times out.
- If the client disconnects before any output (for example pressing Esc while the model is reasoning), only the input, cache and reasoning tokens upstream has reported are billed, and visible output counts as 0. If upstream reported nothing, nothing is billed and nothing is estimated.
- When upstream input usage is not available, input tokens are estimated from the request. That covers a break before upstream reported it and a background read that times out after a disconnect. Delivered output tokens are always estimated from the text.
- Blocked by an upstream content-safety policy: billed for the usage upstream reported.
- Per-request priced models: each recorded success is charged one unit price.

Every charge is itemized under Usage.
