At a glance
The Flux 2 API runs Flux 2 through Mage at POST https://api.mage.space/v1/flux2/generate. A request at the default settings costs 40 Gems (about $0.04), with no subscription. Flux 2 takes no @handle mentions.
Image
Output
1
Variant
40
Gems per image, default
$0.04
About, in USD
Overview
What the Flux 2 API does
Flux 2 Dev, the open-weights model that thrives on long, detailed prompts. Generates or edits from up to 3 reference images, up to 2K.
Flux 2 Dev, an open-weights model for long, detailed prompts, generation, and edits from up to three reference images.
It accepts image, additional_images as inputs.
Quick start
Call the Flux 2 API
Set MAGE_API_KEY, submit to /flux2/generate, and poll status_url until the request completes.
cURL
STATUS_URL=$(curl --request POST 'https://api.mage.space/v1/flux2/generate' \
--header "Authorization: Bearer $MAGE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "flux2-dev"
}' | jq -r '.status_url')
# Repeat until status is "completed"; result.url is the file
curl "$STATUS_URL" --header "Authorization: Bearer $MAGE_API_KEY"Python
import os, time, requests
headers = {"Authorization": f"Bearer {os.environ['MAGE_API_KEY']}"}
request = requests.post(
"https://api.mage.space/v1/flux2/generate",
headers=headers,
json={
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "flux2-dev"
},
).json()
while request["status"] in ("queued", "in_progress"):
time.sleep(3)
request = requests.get(request["status_url"], headers=headers).json()
print(request["status"], request["result"] and request["result"]["url"])JavaScript
const headers = {
Authorization: `Bearer ${process.env.MAGE_API_KEY}`,
'Content-Type': 'application/json',
};
let request = await fetch('https://api.mage.space/v1/flux2/generate', {
method: 'POST',
headers,
body: JSON.stringify({
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "flux2-dev"
}),
}).then((response) => response.json());
while (['queued', 'in_progress'].includes(request.status)) {
await new Promise((resolve) => setTimeout(resolve, 3000));
request = await fetch(request.status_url, { headers }).then((r) => r.json());
}
console.log(request.status, request.result?.url);Models
Flux 2 model_id values
Send model_id to pick a variant. A request without one runs the default.
| model_id | Name | Default |
|---|---|---|
| flux2-dev | Flux 2 | Yes |
Options
Flux 2 parameters
Allowed values across all variants; a variant may offer fewer. The docs list the options per variant.
| Field | Values |
|---|---|
| aspect_ratio | 21:9, 16:9, 3:2, 5:4, 1:1, 4:5, 2:3, 9:16, 9:21 |
| resolution | 1k, 2k |
Inputs
Media inputs Flux 2 accepts
Send each as an https URL, a data URL, or an upload of up to 100 MB.
| Field | Role |
|---|---|
| image | The reference image. |
| additional_images | Additional reference images. |
More image models
Other image generation APIs on Mage
Image · from 9 Gems
GPT Image 2 API
Precise prompts and readable text
Image · from 75 Gems
Grok Image API
Grok Imagine, in three quality tiers
Image · from 37 Gems
Guava API
Photorealism that passes for a photograph
Image · from 20 Gems
HiDream API
Fast and versatile, with negative prompts
Image · from 20 Gems
Krea 2 API
Gorgeous aesthetics in seconds
Image · from 135 Gems
Mango API
Our flagship image family
FAQ
Frequently asked questions
How much does the Flux 2 API cost?
A Flux 2 request at the default settings (Flux 2) costs 40 Gems, about $0.04. Other resolutions, durations, and variants change the price; the response reports the exact charge. A generation that fails is refunded; one Mage's content policy blocks is not.
What is the Flux 2 API endpoint?
POST https://api.mage.space/v1/flux2/generate with an Authorization: Bearer header carrying your Mage API key. The response includes a status_url to poll for the result.
Which Flux 2 models can I call?
flux2-dev. The default is Flux 2.
Does Flux 2 support reference images or characters?
Flux 2 accepts image, additional_images. Flux 2 takes no @handle mentions.
Can I use Flux 2 from Claude or ChatGPT?
Yes. Connect the Mage MCP server to Claude, ChatGPT, Claude Code, Grok, or Cursor and ask for Flux 2 by name. Your assistant reads its options with get_model and quotes the price before it generates.
How long are Flux 2 results kept?
Results and inputs are kept for 30 days. Download anything you want to keep to your own storage.
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.