OpenAI

gpt-image-2 API pricing and integration

Integrate gpt-image-2 using the published protocols below. Review context limits and billing units before choosing request parameters.

Model ID: gpt-image-2 · Catalog updated: 2026-11-04

Published base prices

Text input
$5.00
/ 1M tokens
Image input
$8.00
/ 1M tokens
Image output
$30.00
/ 1M tokens
-

Account discounts and final billing are shown in your dashboard.

Model parameters and protocols

Context window
See model documentation
Maximum output
See model documentation
Billing type
composite
Published protocols
/v1/images/generations · /v1/images/edits

Parameters and tool support

A listed protocol does not imply support for every parameter or hosted tool. Image input, reasoning options, structured output, and tool execution depend on the model and route. Validate your workload with a small request and preserve session context for tool continuations.

Tools and sessions guide

Integration examples

Complete examples

Generated from the model’s public capabilities and updated with every selection.

Supported protocols only
Protocol
Language
pip install openai
Images · GeneratePythonDefault providerSSE
Images · Generate · Python
import base64
import os
from pathlib import Path
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GR_API_KEY"],
    base_url="https://endpoint.greatrouter.com"
)

response = client.images.generate(
    model="gpt-image-2",
    prompt="A watercolor painting of a lighthouse at sunset",
    size="1024x1024",
    stream=True,
    partial_images=2,
)
for event in response:
    if event.type == "image_generation.completed":
        Path("image.png").write_bytes(base64.b64decode(event.b64_json))