> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mage.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Billing and retention

> How the Mage API charges Gems: the price of a request, when it is charged and refunded, cancellations, auto top-up, and how long results and inputs are kept.

Every API request is paid in Gems from your account. Membership plans and their unlimited models do not apply to the API.

> [!WARNING]
>
> The API and the [MCP server](https://docs.mage.space/api/mcp.md) need a successful payment on your
> account first: buy any [Gem pack or plan](https://www.mage.space/gems). Until
> then every call answers `402 payment_required`. The signup bonus works in the
> Mage app only. Keys made before the payment start working as soon as it goes
> through.

## Prices

The price depends on the model and its settings: resolution, duration, and on some models the number of references. Each model's page shows the price of its default settings. Before you submit, `GET /v1/account` shows the balance; after you submit, `billing.gems_charged` on the request shows the exact charge. A request the balance cannot cover is refused with `402 insufficient_gems` and `gems_required`, and nothing is charged.

## When Gems move

| Event | Gems |
| - | - |
| The request is accepted | Charged. `billing.gems_charged` is the price. |
| The generation fails | Refunded. The status read shows `gems_refunded`. |
| The model's provider blocks the content | Refunded. The request reports `failed` with `content_blocked` and a [`reason`](https://docs.mage.space/api/errors#provider-blocks). |
| Mage's content policy forbids the output | Kept, as in the app. The request reports `failed` with `content_blocked`. |
| You cancel the request | Kept, as in the app. |
| The request is refused before it runs | Nothing is charged. |

## Auto top-up

If auto top-up is on for your account, an API request that needs more Gems than the balance holds triggers it exactly as a generation in the app would, including the charge to your card. Manage it in [API → Billing](https://www.mage.space/api?tab=billing), where you can also see your Gem balances and transactions. Billing shows a warning when auto top-up is disabled; leave it off if you want API spend bounded by the balance. See [how Gems work](https://docs.mage.space/plans/how-gems-work.md).

## Retention

Results and inputs live in a 30-day temporary area. A result's `expires_at` and an upload ticket's `url_expires_at` say when each URL stops working. A completed request stays `completed` after its media expires; only the download stops. Copy anything you want to keep to your own storage.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.