Skip to content

Mage API · Image model

GPT Image 2 API

Precise prompts and readable text

POST https://api.mage.space/v1/gpt_image_2/generate

At 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_idNameDefault
gpt-image-2GPT Image 2Yes
gpt-image-2.5-flareGPT Image 2.5 Flare
gpt-image-2.5-sunburstGPT Image 2.5 Sunburst
gpt-image-2.6-flareGPT Image 2.6 Flare
gpt-image-2.6-sunburstGPT 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.

FieldValues
aspect_ratio21:9, 16:9, 3:2, 5:4, 1:1, 4:5, 2:3, 9:16, 9:21
resolution1K, 2K
output_formatjpeg, 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.

FieldRole
imageThe reference image.
additional_imagesAdditional 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

  • Image · from 90 Gems

    Grok Image API

    Grok Imagine, in two 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 42 Gems

    Mango API

    Our flagship image family

  • Image · from 25 Gems

    MOSS-Image API

    Long prompts and bilingual text, open weights

FAQ

Frequently asked questions

How much does the GPT Image 2 API cost?
A GPT Image 2 request at the default settings (GPT Image 2) costs 9 Gems, about $0.009. 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 GPT Image 2 API endpoint?
POST https://api.mage.space/v1/gpt_image_2/generate with an Authorization: Bearer header carrying your Mage API key. The response includes a status_url to poll for the result.
Which GPT Image 2 models can I call?
gpt-image-2 (GPT Image 2), 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). The default is GPT Image 2.
Does GPT Image 2 support reference images or characters?
GPT Image 2 accepts image, additional_images. GPT Image 2 takes saved characters, references by @handle in the prompt.
Can I use GPT Image 2 from Claude or ChatGPT?
Yes. Connect the Mage MCP server to Claude, ChatGPT, Claude Code, Grok, or Cursor and ask for GPT Image 2 by name. Your assistant reads its options with get_model and quotes the price before it generates.
How long are GPT Image 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.