Back to Models
GPT Image 2
openaiopenai/gpt-image-2
OpenAI's most advanced image generation model with native reasoning β thinks before drawing. 2K resolution, multi-image consistency, magazine-quality typography, and image editing. Released April 21, 2026.
Context Length
--
Max Output
--
Image Priceper 1M tokens
$0.0636/ image
Input Priceper 1M tokens
$6.00/ 1M tokens
Modalities
textimageβimage
Pricing Breakdown
| Type | Rate |
|---|---|
| Image | $0.0636 / image |
| Input | $6.00 / 1M tokens |
| Output | $36.00 / 1M tokens |
| Image input | $9.60 / 1M tokens |
| Cached image input | $2.40 / 1M tokens |
| Low quality | $0.0072 / image |
| Medium quality | $0.0636 / image |
| High quality | $0.2532 / image |
image is medium-quality generation price per image
Supported Parameters
promptsizequalitybackgroundoutput_formatnuser
API Usage Examples
Use the global api.therouter.ai endpoint shown below for new integrations; the legacy China accelerated endpoint is retired.
Recommended: use the async API
Image generation typically takes 30β180s, beyond the edge sync timeout. The examples below use the ?async=true submit + poll pattern. Read the full async image generation & edit guide β
cURL
# 1) Submit job (returns 202 immediately with a polling URL).
# Image generation takes 30-180s β always use the async path in production.
JOB=$(curl -s -X POST "https://api.therouter.ai/v1/images/generations?async=true" -H "Content-Type: application/json" -H "Authorization: Bearer $THE_ROUTER_API_KEY" -d '{
"model": "openai/gpt-image-2",
"prompt": "A cinematic product render with soft studio lighting"
}' | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
echo "submitted: $JOB"
# 2) Poll until terminal (succeeded / failed / cancelled / expired).
while :; do
R=$(curl -s "https://api.therouter.ai/v1/jobs/$JOB" -H "Authorization: Bearer $THE_ROUTER_API_KEY")
S=$(echo "$R" | python3 -c "import sys,json;print(json.load(sys.stdin)['status'])")
echo "status: $S"
case "$S" in
succeeded) echo "$R" | python3 -c "import sys,json;print(json.load(sys.stdin)['unsigned_urls'][0])"; break ;;
failed|cancelled|expired) echo "$R"; exit 1 ;;
esac
sleep 5
doneImage Editing Examples
Upload an image and describe the edit you want with a text prompt; the model returns the edited image as base64.
cURL
# Same async submit + poll pattern as /v1/images/generations.
JOB=$(curl -s -X POST "https://api.therouter.ai/v1/images/edits?async=true" -H "Authorization: Bearer $THE_ROUTER_API_KEY" -F "model=openai/gpt-image-2" -F "prompt=Turn this scene into a watercolor painting" -F "size=1024x1024" -F "image=@input.png" | python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
echo "submitted: $JOB"
while :; do
R=$(curl -s "https://api.therouter.ai/v1/jobs/$JOB" -H "Authorization: Bearer $THE_ROUTER_API_KEY")
S=$(echo "$R" | python3 -c "import sys,json;print(json.load(sys.stdin)['status'])")
echo "status: $S"
case "$S" in
succeeded) echo "$R" | python3 -c "import sys,json;print(json.load(sys.stdin)['unsigned_urls'][0])"; break ;;
failed|cancelled|expired) echo "$R"; exit 1 ;;
esac
sleep 5
done