OpenAI logo
OpenAI

GPT Image 2

OpenAI frontier image generation and editing model with text and image input, flexible sizes, and high-quality image output

Category Image Model ID gpt-image-2
Model TypeImage generation and editing
Input / OutputText and image input, image output
API EndpointsSupports Image API generations and edits

Pricing & Specs

πŸ’° Pricing

Input (Text)$5 / M tokens
Input (Image)$8 / M tokens
Price$30 / M image output tokens

βš™οΈ Specs

Model TypeImage generation and editing
Input / OutputText and image input, image output
API EndpointsSupports Image API generations and edits
SizesSupports 1024x1024, 1024x1536, 2048x2048, 3840x2160, and more; max side 3840px, total pixels up to 8,294,400
Qualitylow / medium / high / auto
Output FormatPNG by default, JPEG / WebP optional; Image API returns base64 images
BackgroundTransparent backgrounds are not currently supported
Standard PricingText input $5 / 1M tokens ($1.25 cached), image input $8 / 1M tokens ($2 cached), image output $30 / 1M tokens
Snapshotgpt-image-2-2026-04-21
Doc StatusUpdated from OpenAI's official model page, image generation guide, and pricing page

API Examples

Python

from openai import OpenAI
import base64

client = OpenAI(
    base_url="https://api.xairouter.com/v1",
    api_key="your-api-key"
)

result = client.images.generate(
    model="gpt-image-2",
    prompt="A vertical poster for a modern tea brand, glass cup, grapefruit slices, fresh white and green background",
    size="1024x1536",
    quality="high",
    output_format="png",
)

image_base64 = result.data[0].b64_json
with open("poster.png", "wb") as f:
    f.write(base64.b64decode(image_base64))

cURL

curl -s https://api.xairouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A vertical poster for a modern tea brand, glass cup, grapefruit slices, fresh white and green background",
    "size": "1024x1536",
    "quality": "high",
    "output_format": "png"
  }' | jq -r '.data[0].b64_json' | base64 --decode > poster.png