# How billing works

URL: https://docs.router.ezat.io/billing

> Prepaid credit per organization, top-ups through Stripe, automatic top-up, tax and invoices with tax IDs, how each request is charged (cache tokens, long context, interrupted streams), negative balances, the 402 error, and refunds.

## When to use this page

You want to add credit, understand what a request was charged, or find out why requests fail with 402. Prices are on [Pricing](https://docs.router.ezat.io/pricing.md).

## How it works

- EZAT Router is prepaid. Each organization has one balance in USD, shared by all of its API keys and members.
- You add credit with a card payment through Stripe, or let **Automatic top-up** charge a saved card when the balance runs low. Paid credit doesn't expire while your account is open.
- Where tax applies, it is added on top of the credit you buy. Every top-up has an invoice with your company name, address and tax IDs.
- Each request is charged after it finishes, for the tokens it used, and the amount comes off the balance straight away.
- When the balance is zero or below, requests are refused with 402 until you add credit.

## Add credit

Owners, admins and billing members can add credit. Other members see the balance but not this form; they can ask one of them.

<Steps>
<Step>

### Open Billing

Go to https://router.ezat.io/billing (**Billing** in the sidebar), or select **Add credits**.

</Step>
<Step>

### Choose an amount

Pick 10, 25, 50 or 100 USD, or **Custom** for any amount from 5 to 5,000 USD (up to two decimal places). Tick **Save this card for automatic top-ups** if you want to use the card for [automatic top-ups](#automatic-top-up).

</Step>
<Step>

### Pay with Stripe

Select **Continue to payment**. Stripe Checkout opens; it asks only for the address details tax needs. Then pay. When you come back, the credit appears within a few seconds, once Stripe confirms the payment.

</Step>
</Steps>

- The credit is the amount you chose. Tax, where it applies, is added at checkout on top of that amount and doesn't go on the balance.
- Stripe emails a receipt to your billing email.
- The payment is listed under **Payment history** on the Billing page, with its **Tax** and an **Invoice** link, and the credit under **Credit activity** as a **Top-up**.
- If you cancel on the Stripe page, nothing is charged.

New organizations start with a zero balance. Promotional credit appears under **Credit activity** as **Promotional credit**. A sign-up offer, when there is one, goes to a new user's first organization, once per user.

## Automatic top-up

**Automatic top-up** charges a saved card when the balance falls below an amount you choose, so your keys don't stop at zero. Owners, admins and billing members set it up on the Billing page.

<Steps>
<Step>

### Save a card

Under **Automatic top-up**, select **Add a card** and enter the card in Stripe Checkout (nothing is charged), or tick **Save this card for automatic top-ups** on your next top-up. **Replace card** swaps it; one card is kept per organization.

</Step>
<Step>

### Set the amounts

Turn on **Top up automatically** and fill in:

| Field | Range |
| --- | --- |
| **When the balance falls below (USD)** | 1 to 10,000 |
| **Add this much credit (USD)** | 5 to 5,000, before tax |

Select **Save**. If the balance is already below the amount, the first top-up runs straight away.

</Step>
</Steps>

- The balance is checked after each request and whenever a request is refused for a low balance. Only one automatic top-up runs at a time.
- Each one is charged to the saved card and listed in **Payment history** as **Automatic**, with its tax and invoice. Stripe emails the receipt.
- If a charge fails (the card is declined or expired, or there is no saved card), automatic top-up turns itself off. Owners and billing members get an email, and the Billing page shows **Automatic top-up is off** with the reason. Fix the card, then turn it back on.
- After 10 automatic top-ups in 24 hours it also turns itself off, so set the credit amount well above the usage you expect between top-ups.
- **Remove card** deletes the saved card and turns automatic top-up off.

If your bank asks you to confirm each payment, an automatic charge (made while you're away) can fail. Add credit by hand in that case.

## Tax, invoices and billing details

- **Tax.** Where tax applies, Stripe calculates it from your billing address and adds it to the price of the credit. The tax is shown at checkout, on the invoice and in the **Tax** column of **Payment history**. It is never added to your balance.
- **Invoices.** Every top-up, by hand or automatic, has an invoice. Select **Invoice** in **Payment history** to open the PDF. It shows your company name, address and tax IDs.
- **Billing details.** On the Billing page, **Billing details** holds what goes on invoices: **Company or full name**, **Billing email** (where receipts and invoices are sent), **Address (optional)** and **Country or region**. Only the country or region is required. Stripe Checkout also saves the address details you enter there.
- **Tax IDs.** Business customers add them here, not at checkout. Under **Tax IDs**, choose the type (for example European Union · VAT) and enter the number, then select **Add**. Stripe checks the number, and the list shows whether Stripe verified it.

Changes apply to the next invoice; invoices already issued don't change.

## How a request is charged

Before a request reaches a model, the gateway checks that the organization's balance is above zero and that the key is under its spend limit (see [Rate limits](https://docs.router.ezat.io/reference/rate-limits.md)). It doesn't hold or reserve credit.

When the response is complete, the request is priced from the token counts the model reported, at the prices in force when it started, and the amount is deducted from the balance in the same step that records the request. If the gateway had to retry on another provider before the response started, you are still charged once.

| What happened | Status in Usage | Charged |
| --- | --- | --- |
| The response finished | Succeeded | Every token, at its price |
| You disconnected during a streamed response | Cancelled | Input and cache tokens, and the output generated so far (see below) |
| Refused before reaching a model: key, model, limit or balance | Rejected | Nothing |
| The provider or the gateway failed, before or during the response | Failed | Nothing |

`POST /v1/messages/count_tokens` and the model lists are free and don't appear in Usage.

### Cache tokens

Prompt caching bills tokens written to the cache at the cache write price (5-minute or 1-hour) and tokens read from it at the cache read price, instead of the input price. On the OpenAI-compatible API caching is automatic. See [Pricing](https://docs.router.ezat.io/pricing.md) for the columns and [Prompt caching](https://docs.router.ezat.io/guides/prompt-caching.md) for how to use it.

### Long context

A model with a long-context tier bills the whole request at the tier's prices when its input (including cached tokens) is above the threshold. See [Pricing](https://docs.router.ezat.io/pricing.md).

### Interrupted streams

If your client disconnects while a response is streaming, the gateway stops the model and charges for what was used:

- **Input and cache tokens** exactly, from the counts the model reports when the stream starts.
- **Output tokens** generated up to that point. When the stream stopped before the model's final count arrived, output is estimated from the text that was streamed (about four characters per token).

These requests show as **Cancelled** in Usage. An estimated output count has an info icon: "Estimated: the stream ended before the final count".

## Balance below zero

A request that starts while the balance is positive always finishes, even if it costs more than what is left. So the balance can go slightly below zero. The next top-up covers the difference: after paying 25 USD with a balance of −0.40 USD, the balance is 24.60 USD.

## When the balance runs out

When the balance is zero or below, every request is refused with HTTP 402 and isn't charged. The dashboard's Overview says "Your balance is used up. Requests are being refused until you add credits."

```json tab="Anthropic format"
{
  "type": "error",
  "error": {
    "type": "billing_error",
    "message": "Your credit balance is too low. Add credits in the EZAT Router dashboard."
  },
  "request_id": "…"
}
```

```json tab="OpenAI format"
{
  "error": {
    "message": "Your credit balance is too low. Add credits in the EZAT Router dashboard.",
    "type": "insufficient_quota",
    "param": null,
    "code": "insufficient_quota"
  }
}
```

A key that has reached its own spend limit gets the same 402, with a message naming the limit. Retrying doesn't help: add credit, or raise the limit. See [Errors](https://docs.router.ezat.io/reference/errors.md).

### Low balance alert

On the Billing page, **Low balance alert** emails the organization's owners and billing members when the balance drops below an amount you set (**Alert below (USD)**). It sends once per dip, and re-arms after the next top-up.

## Usage, payments and receipts

| Where | What it shows |
| --- | --- |
| **Overview** | Balance, and spend, requests and tokens over 30 days |
| **Usage** (https://router.ezat.io/usage) | Cost, requests and tokens over 7, 30 or 90 days, by model and by key, and **Recent requests** with each request's status, tokens and cost. Totals update every couple of minutes. |
| **Billing** (https://router.ezat.io/billing) | **Current balance**, **Automatic top-up**, **Payment history** (each payment with its credit, tax, total, status and invoice), **Billing details** and **Credit activity** (top-ups, refunds, adjustments, promotional credit, chargebacks) |
| Email | Stripe's receipt for each top-up, low-balance alerts, and a message when an automatic top-up fails |

Every member sees the balance and Usage. Payment history and credit activity are for owners, admins and billing members. Request costs aren't listed under Credit activity; they are in Usage.

## Refunds and chargebacks

- **Refunds.** When a payment is refunded, the credit it bought is taken off the balance in proportion to the amount refunded (the tax refunded with it isn't), and listed as a **Refund** under Credit activity. A fully refunded payment shows **Refunded** in Payment history. Whether a payment can be refunded is set by the [Terms of Service](https://router.ezat.io/terms); to ask, email support@ezat.io.
- **Chargebacks.** If you dispute a payment with your bank, the credit it bought is taken off the balance (a **Chargeback**), automatic top-up is turned off, and the organization is suspended until the dispute is reviewed. While it is suspended, every key is refused with 403 `permission_error`: "This organization is suspended. Contact support@ezat.io."

The [Terms of Service](https://router.ezat.io/terms) also cover taxes and promotional credit.

## For AI agents

1. Balance is per organization, in USD, prepaid. There is no API to top up: the user adds credit at https://router.ezat.io/billing (owners, admins and billing members only; 5 to 5,000 USD per payment), or turns on **Automatic top-up** there.
2. HTTP 402 means the balance is zero or below (`billing_error`, or `insufficient_quota` on the OpenAI-compatible API), or the key reached its spend limit. Don't retry; tell the user to add credit, turn on automatic top-up, or raise the limit.
3. Each request is charged after it finishes. Failed and rejected requests, token counting and model lists are free.
4. An interrupted stream is charged for input and cache tokens and the output generated so far.
5. The balance can go slightly negative; the next top-up covers it.
6. A 403 saying the organization is suspended needs support@ezat.io; retrying won't help.
7. Tax is added on top of the credit and never goes on the balance. Invoices with the company name, address and tax IDs are on the Billing page (**Payment history** → **Invoice**).