# Service billing

> What a service costs: GPU-hours on replicas billed by the second, the floor and ceiling shown before you create, the monthly spend cap and its alerts, what pausing costs, and the Usage tab.

Source: https://legion.ambient.xyz/docs/renting/services/billing

A service has no fee of its own. You pay for the replicas that run, as you would for any rental, from your organization's prepaid credit. After this page you know what the number on the cost card means, how the spend cap works, and where to see what a service has used.

## What you pay for

- **GPU time, by the second.** Each replica is a rental of your organization, billed per GPU-hour from the moment it is running, including the time it spends loading the model. A replica that never started costs nothing. See [Credit and billing](https://legion.ambient.xyz/docs/renting/credit-and-billing).
- **The price you see is the price you pay.** Prices include the platform fee, like every price on Legion: see [Prices and fees](https://legion.ambient.xyz/docs/renting/pricing). The price ceiling you set is all-in too, and it is a price per replica per hour.
- **Warm replicas** keep a disk and bill for its storage while stopped, not for GPU time. See [Warm replicas](https://legion.ambient.xyz/docs/renting/services/scaling#warm-replicas).
- **Data sent out** through the service is measured like other traffic from a rental. See [Data sent out of Legion](https://legion.ambient.xyz/docs/renting/credit-and-billing#data-sent-out-of-legion).
- **A service on a rental** bills that rental, as it always did. Stopping the rental stops the cost.

## The cost card

Before you create a service, and on its Overview, the cost card gives the range, not a single number:

| Line | What it is |
| --- | --- |
| **Likely hardware** | What Legion would rent now: the cheapest GPU model and count that fit, its price per hour and how many hosts can run it. |
| **While idle** | What it costs with no traffic. 0 when it can scale to zero, otherwise the minimum replicas, plus storage of warm replicas. This is the **floor**. |
| **At minimum** | The minimum number of replicas running. |
| **At maximum** | The maximum number of replicas running. This is the **ceiling**: Legion never runs more. |
| **Spend cap** | The most this service can spend in a month, and how many hours at maximum that pays for. |

The numbers use current prices of the cheapest hardware that fits, and spot prices can move. They are an estimate: your bill is what the replicas ran. With the API, `estimateService` (`POST /v1/services/estimate`) returns the same figures, and the CLI's `legion services create --dry-run` prints them.

## The monthly spend cap

Every autoscaled service has a monthly spend cap. You set it when you create the service, and you can change it at any time. A service on a rental can have one too.

- **It is a calendar month, in UTC.** It starts over on the first of the month at 00:00 UTC.
- **It counts GPU time** of the replicas, at their all-in prices. Storage of warm replicas is shown next to it but not counted, because it is cents a day and the cap exists to stop a runaway.
- **Alerts at 50, 80 and 100 percent.** Legion emails the organization's owners and the person who created the service, once each a month, and shows a notice in the app.
- **Legion stops adding replicas before the cap.** It doesn't scale up when the projected spend of the next 10 minutes would cross the cap.
- **At 100 percent the service pauses.** Its replicas drain for up to 30 seconds and stop, and callers get `402 spend_cap_reached`. The status reads **Cap reached**. The overrun is small: about two minutes of the service's spend rate.
- **To get going again,** raise the cap above this month's spend. The service un-caps and returns to its minimum. Otherwise it resumes by itself on the first of the next month.

Why monthly: a daily cap starts over every midnight, so a leaked key would spend it again each day. A monthly cap stops once and waits for a person.

Your credit is the hard stop under every cap. When credit runs out, the service shows **No credit**, callers get `402 insufficient_credit`, and replicas stop. Add credit and it scales back up. So that a service never stops for want of credit, turn on [auto top-up](https://legion.ambient.xyz/docs/renting/credit-and-billing#auto-top-up): it charges a saved card when your balance falls below the amount you choose, up to a monthly limit.

## Pause

Pausing scales the service to zero and keeps its URL and keys. Callers get `503 service_paused`. Nothing bills for GPU time while it is paused. Warm replicas keep billing storage until they expire, 60 hours after they stopped. Resume from the service's page, `legion services resume` or `resumeService`. A capped service can't resume until the cap is raised.

## See what it used

The **Usage** tab shows replica-hours and cost for each day, requests, errors, and how far this month's spend is toward the cap, as "so much of the cap". The **Overview** shows requests and latency over the last hour, day or week, and the **Metrics** tab has the detail: see [Service metrics](https://legion.ambient.xyz/docs/renting/services/metrics). The **Replicas** tab shows each replica's rate and this month's cost, with a total. The replicas are also rentals, so their charges appear in **Spend** like any other rental's.

The month's figure on the service is Legion's estimate, the number the cap is enforced on. When billing has its own total, the page shows it beside the estimate, so what you see matches your bill.

From a terminal, `legion services usage` (`--window 1h|24h|7d` for the request points in `-o json`). With the API, `getServiceUsage` (`GET /v1/services/{service_id}/usage`) returns requests, latency and cost together, and `listServiceEvents` returns the activity feed.

## Deleting a service

Deleting stops and deletes every replica with its workspace, revokes all keys and releases the URL. Charges already made still apply. Once it is deleted, its name is free for a new service of yours, which gets a new URL. The old URL stays reserved for 30 days so nobody else can claim it and catch traffic that old keys would have sent. To change a service's model, hardware or price ceiling you don't need to delete it: see [Change the model, hardware or price ceiling](https://legion.ambient.xyz/docs/renting/services/scaling#change-the-model-hardware-or-price-ceiling).
