Mage API · Image model

GPT Image 2 API

Precise prompts and readable text

Get an API keyTry GPT Image 2 in the playground
POST https://api.mage.space/v1/gpt_image_2/generate

At a glance

The GPT Image 2 API runs GPT Image 2 and 2 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.

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. OpenAI's safety filter applies.

OpenAI's GPT Image 2, GPT Image 2.5 Flare, and GPT Image 2.5 Sunburst, for generation and edits. 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"
Python
import os, time, requests

headers = {"Authorization": f"Bearer {os.environ['MAGE_API_KEY']}"}
request = requests.post(
    "https://api.mage.space/v1/gpt_image_2/generate",
    headers=headers,
    json={
      "prompt": "Editorial portrait in soft daylight, 35mm film look",
      "aspect_ratio": "4:5",
      "model_id": "gpt-image-2"
    },
).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/gpt_image_2/generate', {
  method: 'POST',
  headers,
  body: JSON.stringify({
    "prompt": "Editorial portrait in soft daylight, 35mm film look",
    "aspect_ratio": "4:5",
    "model_id": "gpt-image-2"
  }),
}).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

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

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

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

More image models

Other image generation APIs on Mage

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

Image · from 68 Gems

Nano Banana 2 API

Crisp, readable text, up to 4K

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). 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.

Get an API keyTry GPT Image 2 in the playground

Related