Mage API · Image model
Flux 2 API
Long prompts and multi-reference edits
POST https://api.mage.space/v1/flux2/generateAt 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.
- ImageOutput
- 1Variant
- 40Gems per image, default
- $0.04About, 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"TypeScript
// npm install @mage-space/sdk
import Mage from '@mage-space/sdk';
const mage = new Mage(); // reads MAGE_API_KEY
const request = await mage.run('flux2', {
prompt: 'Editorial portrait in soft daylight, 35mm film look',
aspect_ratio: '4:5',
model_id: 'flux2-dev',
});
console.log(request.result.url);Python
# pip install mage-space
from mage_space import Mage
mage = Mage() # reads MAGE_API_KEY
request = mage.run("flux2", {
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "flux2-dev",
})
print(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
GPT Image 2 API
Precise prompts and readable text
Grok Image API
Grok Imagine, in two tiers
Guava API
Photorealism that passes for a photograph
HiDream API
Fast and versatile, with negative prompts
Krea 2 API
Gorgeous aesthetics in seconds
Mango API
Our flagship image family
FAQ
Frequently asked questions
How much does the Flux 2 API cost?
What is the Flux 2 API endpoint?
Which Flux 2 models can I call?
Does Flux 2 support reference images or characters?
Can I use Flux 2 from Claude or ChatGPT?
How long are Flux 2 results kept?
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.