# Credit and billing

> Prepaid credit, per-second GPU billing, storage, backups, adding credit, auto top-up, refunds of unused credit, and what happens at $0.00.

Source: https://legion.ambient.xyz/docs/renting/credit-and-billing

Rentals are paid from your organization's prepaid balance. You see it, and add to it, in **Spend**.

## GPU charges

A running rental is billed by the second:

```text
charge = price per GPU-hour × GPUs × seconds Running ÷ 3600
```

- The price is fixed for the life of the rental. It is all-in: it already includes the 5% platform fee, so the fee is part of the charge, not an extra one. See [Prices and fees](https://legion.ambient.xyz/docs/renting/pricing). The rental's **Cost** tab shows how much of the total is the fee.
- Billing starts at **Running**. You aren't billed while a rental starts, restarts, or if it fails.
- Each rental's total is rounded to the cent, half up. A few seconds can come to $0.00.
- Charges are posted about once a minute.

**Example.** Two GPUs at $2.10 per GPU-hour, running for 1 hour 30 minutes (5,400 seconds):

```text
$2.10 × 2 × 5,400 ÷ 3,600 = $6.30
```

### Interruptible rentals

An [interruptible rental](https://legion.ambient.xyz/docs/renting/interruptible-rentals) is billed the same way, at the host's spot auction price: never below the provider's floor and never above your max. When it's preempted or outbid, GPU time is billed until the host's agent reports the stop, never later than 30 seconds after the notice ends, including the 5-minute notice, and there is no first-hour refund.

## Storage

A stopped rental releases its GPUs, which are not billed. It is billed for storage instead:

```text
storage per month = GiB used × $0.20, by the second, per 730-hour month
```

- The default rate is **$0.20 per GiB per 730-hour month** before the platform fee. The rate you are shown is all-in. The rent form and the rental's **Cost** tab show the rate that applies.
- **GiB used** is the disk the rental uses on the host, at most its share.
- It's billed only while your organization has credit, and only while the files are on the host: at most 72 hours after the stop.
- A rental that was set to **Delete it** on preemption never stops with data, so it has no storage charge.
- While its host is in a planned maintenance window, a stopped rental isn't charged for storage either. See [Planned maintenance](https://legion.ambient.xyz/docs/renting/rental-lifecycle#planned-maintenance).

**Example.** A stopped rental that uses 40 GiB costs 40 × $0.20 = $8.00 per month, about $0.011 per hour.

See [Stopping, backups and how long your data is kept](https://legion.ambient.xyz/docs/renting/stopping-and-backups) for how long the files stay, what a restart needs, and when they're deleted.

## Backups

A [backup](https://legion.ambient.xyz/docs/renting/stopping-and-backups#backups) of a stopped rental's `/workspace` is charged once, when you ask for it:

```text
backup price = GiB × $0.05 × days × 24 ÷ 730  +  GiB × $0.12
```

- **$0.05 per GiB per 730-hour month** of storage, by the hour, for the 7 or 30 days you choose.
- **$0.12 per GiB** for one download, which is included. Each further download link is charged $0.12 per GiB again, and every link works once. See [Data sent out of Legion](#data-sent-out-of-legion).
- Each part is rounded up to the cent. The estimate is taken from your credit when you ask. When the backup is ready, the price is worked out from its real size and the difference is refunded. A failed or cancelled backup is refunded in full.

**Example.** A 100 GiB backup kept for 7 days costs $1.16 + $12.00 = $13.16. See [Backup pricing](https://legion.ambient.xyz/docs/renting/stopping-and-backups#backup-pricing).

## Data sent out of Legion

Sending data out of Legion costs Legion money, so some of it is charged to you. Everything not in this table is free.

| What | What you pay |
| --- | --- |
| A **workspace download link** | $0.15 per GiB of the file, rounded up to the cent, at least 1 cent. Every link is charged. Making the file is free. |
| A **backup download link** | The first link is included in the backup's price. Each further link is $0.12 per GiB of the backup. |
| **Relay and exposed-port traffic:** SSH through the gateway, services on `ambi.run`, and the web terminal | The first 100 GiB a month for your organization is free. After that, $0.12 per GiB. |

How it works:

- **Download links work once.** The first time a link is opened it is used up and sends you to the file. The file address it gives stays valid for 5 minutes, enough for a download to start, and a download that has started keeps going. A second try, or a try after the link expired, answers `410 link_used`: make a new link, which is charged again. A link expires 60 minutes after it was made.
- **You see the charge first.** The app shows the estimate before you start a workspace download, and the exact charge before it makes the link. A link is charged when it is made and is not refunded.
- **Workspace downloads are limited** to 3 an hour for your organization.

### Relay and exposed-port traffic

Three doors are measured. Each counts the bytes sent toward you or your visitors:

- **SSH:** what comes back to you through the SSH gateway, including `scp`, `rsync` and port forwards.
- **Exposed ports:** what your services on `ambi.run` send to visitors.
- **Browser terminal:** what the terminal in the app shows you.

How it is counted and charged:

- **Data you send in is free.** Only bytes that go out toward you or a visitor count.
- **The allowance is per organization.** All of your rentals share the first 100 GiB a month. After that, each GiB costs $0.12.
- **The month is UTC.** The count starts again at 00:00 UTC on the first day of each month.
- **Updated about every minute.** A figure can be a minute or two behind what just happened.
- **The charge is taken from your credit** as the traffic passes the free allowance, rounded down to whole cents over the month's total. It never stops traffic by itself: when your credit runs out, the usual rules apply.
- **A price change** applies to traffic that arrives after it.

Where to see it:

- **A rental's Cost tab, Data sent out:** this month's data by door, the last 30 days, what this rental was charged, the free data left for your organization and the price after it.
- **Spend, Rentals, Data transfer:** the organization's month, the free data left, the charge so far and the rentals that sent the most, each linking to its page.
- **Spend, Activity:** each charge is a row, **Data transfer (relay)** or **Data transfer (exports)**, with the rental it was for.
- **The API:** [getRentalTransfer](https://legion.ambient.xyz/docs/api/rentals/get-rental-transfer) for one rental and [getOrgTransfer](https://legion.ambient.xyz/docs/api/rentals/get-org-transfer) for the organization.

These are the prices today. [getStoragePolicy](https://legion.ambient.xyz/docs/api/rentals/get-storage-policy) returns the numbers that apply, and the app shows them before you pay.

## Add credit

Owners add credit in **Spend** with **Add credit**:

- Pay by bank transfer (ACH), by card or with USDC, through Stripe Checkout. **Pay by bank** is offered first.
- Each top-up is from $25 to $10,000, in USD.
- **Bank transfer (ACH)** has the lower fee: 0.8%, capped at $5, compared with 2.9% + 30 cents for a card. If you later ask for a refund of unused credit, only that fee is kept. A bank payment takes 3 to 5 business days to arrive, and the credit is added when it settles.
- **Card** credit arrives within minutes. Your card is approved first and charged after a quick check, so a top-up that is refused is never charged. Your bank may ask you to confirm the payment (3D Secure).
- **Top-ups** in Spend shows each one and what became of it. **Canceled** means your card was not charged: the check refused the top-up, a reviewer refused it, or the approval ran out of time. Nothing was added to your balance.

Only an owner can add credit. A member who sees a no-credit or low-balance notice presses **Ask an owner** and sends the details to an owner of the organization.

Through the API, owners call [createTopUp](https://legion.ambient.xyz/docs/api/billing/create-top-up). Pass `payment_method` as `us_bank_account` or `card` to offer only that way to pay; leave it out to offer every way. It returns a Stripe Checkout page to send the person to.

## Auto top-up

Auto top-up adds credit by itself when your balance runs low, so running rentals and services don't stop at $0.00. Owners set it up in **Spend**, on **Balance & top-ups**, in the **Auto top-up** card.

1. Choose **Set up auto top-up** and enter three amounts:

   - **When your balance falls below:** the balance that starts a top-up, from $1 to $10,000.
   - **Add:** what each auto top-up adds, from $25 to $10,000.
   - **Monthly limit:** the most auto top-up may add in a calendar month (UTC), at least one top-up. It is required, so a lost or misused card can't be drained.

   The form says it back as a sentence, for example: "When your balance falls below $50, add $200. At most $1,000 a month."
2. Choose **Continue to save a card**. Stripe's secure page saves your card; your bank may ask you to confirm it (3D Secure), so later charges made while you are away go through. Legion never sees the card number.
3. You come back to Spend with the amounts as you typed them. Choose **Turn on auto top-up**.

How it works:

- Legion checks your balance every minute. When it is below your amount, it charges the saved card once. Only one auto top-up is in progress at a time, and at most 3 are tried a day.
- It never adds more than the monthly limit. The last top-up of a month is made smaller to fit what is left of the limit, and is skipped if that is under $25.
- The card is approved first and charged after the same quick check as any card top-up, so a top-up that is refused is never charged. The credit is added once the charge is taken.
- Each auto top-up is in **Top-ups**, marked **Automatic**, with the usual receipt by email. Refunds of unused credit and disputes work as for any top-up.

The card shows what it is doing: **On**, **Off** or **Paused**, the card on file (brand, last four digits and expiry), the three amounts, what was added this month and the last attempt.

### When auto top-up pauses

Auto top-up stops trying, and owners get one email saying what failed and how to fix it, when:

| Reason | What to do |
| --- | --- |
| The card was declined | Replace the card, or ask your bank why it was declined and save auto top-up again. |
| Your bank asked to confirm the charge | Replace the card and confirm it with your bank when you save it. |
| The card expired | Replace the card. |
| A top-up is being reviewed | Nothing: it resumes once the review is done, usually within one business day. |
| The monthly limit was reached | Wait for the 1st of next month (UTC), or raise the monthly limit. |

Saving auto top-up again, or saving a new card, turns it back on. The low-balance and no-credit notices across the app say when auto top-up is paused and why, and suggest it when it is off.

### Change it or turn it off

- **Edit** changes the three amounts. The change applies to the next top-up.
- **Replace card** saves a different card on Stripe's page.
- **Turn off** stops auto top-up and keeps the card and the amounts, so **Turn on** brings it back.
- **Remove card** forgets the card and turns auto top-up off. Your balance and your top-ups don't change.

Only an owner can set up or change auto top-up; everyone who can see the balance sees its card. A test organization cannot pay with real money, so it can't use auto top-up.

Through the API: [getAutoTopUp](https://legion.ambient.xyz/docs/api/billing/get-auto-top-up) reads it, [createAutoTopUpCard](https://legion.ambient.xyz/docs/api/billing/create-auto-top-up-card) returns the Stripe page that saves or replaces the card, [putAutoTopUp](https://legion.ambient.xyz/docs/api/billing/put-auto-top-up) sets the amounts and turns it on or off (with an `Idempotency-Key`; turning it on without a saved card is `409 no_saved_card`), and [deleteAutoTopUpCard](https://legion.ambient.xyz/docs/api/billing/delete-auto-top-up-card) removes the card.

## Refund unused credit

Owners can get back credit they have not used. In **Spend**, choose **Refund unused credit**:

1. Legion shows the most you can get back, and a quote for it: what leaves your balance, the payment processing fee that is kept, and what goes back to your card or bank.
2. Choose all of it, or **A smaller amount**. The quote updates for the amount you enter.
3. Choose **Confirm refund**. The money goes back to the cards and bank accounts you paid with, newest top-ups first.

What to know:

- Only paid credit is refunded, from top-ups of the last 180 days. **Promo credit is never refunded.**
- Stripe keeps its processing fee when it refunds a payment, so each top-up's share of that fee is kept from your refund. A bank transfer has the lower fee.
- Stop your running rentals first, so your balance stops changing. A refund is refused while a rental is starting or running.
- If the fee changes between the quote and your confirmation, Legion asks you to look at the new amounts and confirm again. Nothing is refunded until you do.
- A test organization cannot get money back.

Through the API, call [getCreditRefundQuote](https://legion.ambient.xyz/docs/api/billing/get-credit-refund-quote), then [createCreditRefund](https://legion.ambient.xyz/docs/api/billing/create-credit-refund) with the quote's amount and `expected_fee`, and an `Idempotency-Key`. It needs the same permission as topping up.

## Disputed payments

If a payment is disputed with the card's or bank's issuer (a chargeback), the disputed amount is taken back from your balance. A balance can go below zero this way. An organization more than $50.00 below zero is suspended until [support](https://legion.ambient.xyz/docs/account/support) restores it. Providers whose earnings were paid for by a disputed payment also have those earnings taken back; see [Earnings and payouts](https://legion.ambient.xyz/docs/providing/earnings-and-payouts).

## When credit runs out

When the balance reaches $0.00:

- Running rentals are stopped.
- New rentals, and starting a stopped one, are refused with `402 insufficient_credit`.
- Members of your organization get an email.
- The stopped rentals' files follow the usual clock: deleted 72 hours after the stop, after an email 12 hours before. Adding credit doesn't extend it; back up what you need. See [Stopping, backups and how long your data is kept](https://legion.ambient.xyz/docs/renting/stopping-and-backups).

Spend shows your runway: how long the balance lasts at the rate of everything running now. To keep rentals and services running, turn on [auto top-up](#auto-top-up): it adds credit before the balance reaches $0.00.

## Promo codes

A promo code can add credit, a bonus on a top-up or a discount on compute. Promo credit is used before paid credit, can expire and is never refunded as cash. See [Promo codes](https://legion.ambient.xyz/docs/renting/promo-codes).
