Skip to main content
This walkthrough runs one generation from the command line with curl and jq. You need a Mage account with Gems on it and the API tab in your settings.
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

Open Settings → API, create a key, and copy it. The key starts with mage_sk_ and is shown once; Mage keeps only a hash of it. Export it in your shell:
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.
Each model’s page lists its fields, the tokens each one accepts, its defaults, and its price at those defaults. The playground on the page runs the call for you.

Next steps

Requests and lifecycle

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

Models

Every model with its endpoint, fields, and price.

Inputs and uploads

Send images and video by URL, data URL, or upload.

Errors and retries

Every error code, what it means, and what to retry.
Last modified on September 17, 2026