Skip to main content
This walkthrough runs one generation from the command line with curl and jq, to show each step of the API. You need a Mage account with a successful payment (any Gem pack or plan; the signup bonus does not cover the API) and access to API → API Keys.
Writing TypeScript or Python? The TypeScript SDK and the Python SDK do the submitting and polling below in one call. Create a key as in step 1, then:
An API key spends the Gems on your account. Use it in server-side code only, and never commit it to source control.
1

Create a key

  1. Open API → API Keys. In Mage’s navigation, this is API (Beta), below Agent, then the API Keys tab.
  2. Select Create API key. In the popup, enter a Key name, such as Production server, then select Create key.
  3. The You’re ready to build popup shows your new key. Select Copy key and save it securely before closing the popup.
The key starts with mage_sk_ and is shown only once; Mage keeps only a hash of it. The popup also includes an editable quick start and playground. To follow this command-line walkthrough, export the key in your shell:
Your key appears under Active in API Keys. Previously revoked keys and their usage history are under Revoked. See Authentication for key management.
2

Submit a generation

Each model has its own endpoint, POST /v1/{architecture}/generate. The body holds the fields you want to set; every other field keeps the model’s default. This call uses Flux 2.
The response is the request’s current state. Gems are charged now, and status_url is where to look next.
Keep request_id; everything else about the request is reached through it.
3

Poll until it finishes

Read status_url every few seconds until status is completed, failed, or cancelled.
A completed request carries the output in result.
4

Download the output

Temporary media expires 30 days after the request, at result.expires_at. Copy what you want to keep to your own storage.

Cancel a request

A live request stops when you POST to its cancel_url. The response is the request’s state afterwards. Gems are not returned for a cancelled request.

Try a video model

The same call reaches every model; only the endpoint and the fields change. This one runs Plum for five seconds at 16:9. Video takes longer than an image, so poll less often.

Try an audio model

Seed Audio generates voices, dialogue, music, and sound effects as an MP3 of exactly the duration you ask for, from 5 to 120 seconds. The result’s type is audio, and its url is the MP3.
To voice it with a clip of your own, save the clip as an audio reference with POST /v1/references and mention its handle in the prompt: "@radio-host reads the forecast". The same field names mean the same thing on every model: aspect_ratio as W:H, first_image and last_image, resolution, duration. Each model’s reference page lists its fields, the values each one accepts, its defaults, and its price at those defaults. You can also open Playground and select Try this on a model to edit the request, try it in the playground, or copy it as cURL or as code for the TypeScript or Python SDK.

Next steps

TypeScript SDK

Typed configs, a call that waits for the result, and safe retries.

Python SDK

The same, with sync and asyncio clients.

Requests and lifecycle

Statuses, polling, idempotency keys, cancellation, and results.

Models

Every model with its endpoint, fields, and price.

Inputs and uploads

Send images, video, and saved audio clips to a model.

Errors and retries

Every error code, what it means, and what to retry.
Last modified on October 26, 2026