Mage API · Image model
GPT Image 2 API
Precise prompts and readable text
POST https://api.mage.space/v1/gpt_image_2/generateAt a glance
The GPT Image 2 API runs GPT Image 2 and 4 other variants through Mage at POST https://api.mage.space/v1/gpt_image_2/generate. A request at the default settings costs 9 Gems (about $0.009), with no subscription. GPT Image 2 takes saved characters, references by @handle in the prompt.
- ImageOutput
- 5Variants
- 9Gems per image, default
- $0.009About, in USD
Overview
What the GPT Image 2 API does
OpenAI's GPT Image models, which follow the prompt to the letter and render readable text. Generate or edit from many reference images, or make animated GIFs on GPT Image 2.6. OpenAI's safety filter applies.
OpenAI's GPT Image models for generation and edits: GPT Image 2, GPT Image 2.5 Flare and Sunburst, and GPT Image 2.6 Flare and Sunburst, which also make animated GIFs. OpenAI's safety filter applies.
It accepts image, additional_images as inputs.
Quick start
Call the GPT Image 2 API
Set MAGE_API_KEY, submit to /gpt_image_2/generate, and poll status_url until the request completes.
cURL
STATUS_URL=$(curl --request POST 'https://api.mage.space/v1/gpt_image_2/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": "gpt-image-2"
}' | 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('gpt_image_2', {
prompt: 'Editorial portrait in soft daylight, 35mm film look',
aspect_ratio: '4:5',
model_id: 'gpt-image-2',
});
console.log(request.result.url);Python
# pip install mage-space
from mage_space import Mage
mage = Mage() # reads MAGE_API_KEY
request = mage.run("gpt_image_2", {
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "gpt-image-2",
})
print(request["result"]["url"])Models
GPT Image 2 model_id values
Send model_id to pick a variant. A request without one runs the default.
| model_id | Name | Default |
|---|---|---|
| gpt-image-2 | GPT Image 2 | Yes |
| gpt-image-2.5-flare | GPT Image 2.5 Flare | |
| gpt-image-2.5-sunburst | GPT Image 2.5 Sunburst | |
| gpt-image-2.6-flare | GPT Image 2.6 Flare | |
| gpt-image-2.6-sunburst | GPT Image 2.6 Sunburst |
Options
GPT Image 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 |
| output_format | jpeg, gif |
Inputs
Media inputs GPT Image 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. |
Rules
What the GPT Image 2 API enforces
- Each model offers some `quality` levels only; a level the chosen model does not offer is refused.
- Set `output_format` to `gif` on a GPT Image 2.6 model for an animated GIF, with `frame_count` from 2 to 16 (default 9) and `frame_duration_ms` from 20 to 2000 (default 200). Other models refuse it. `resolution` does not apply: each `aspect_ratio` has one frame size, near 640 pixels. The result is a `.gif` file, and its `type` stays `image`.
- A GIF is priced by `quality` and by the frame range it falls in (2 to 8, 9, 10 to 12, or 13 to 16), not per frame. The price table below shows stills: read a GIF's price from the cost estimate.
- A GIF on Mage, such as an earlier result, passed as an image input runs on its first frame. A GIF from anywhere else is refused: image inputs are JPEG or PNG.
More image models
Other image generation APIs on Mage
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
MOSS-Image API
Long prompts and bilingual text, open weights
FAQ
Frequently asked questions
How much does the GPT Image 2 API cost?
What is the GPT Image 2 API endpoint?
Which GPT Image 2 models can I call?
Does GPT Image 2 support reference images or characters?
Can I use GPT Image 2 from Claude or ChatGPT?
How long are GPT Image 2 results kept?
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.