Developer Reference
GPT Image 2 API — Pricing, Endpoints & Code Examples
Everything developers need to integrate GPT Image 2 into their applications. Code examples, pricing, and endpoint documentation.
Official API not yet released
GPT Image 2 has been spotted on LM Arena but OpenAI has not launched the public API. Use our compatible endpoint to build and test today — switch base URLs on launch day.
Expected Endpoint Spec
Endpoint
POST /v1/images/generations
Model
gpt-image-2
Parameters
prompt— Text description of the imagesize— 1024x1024, 1024x1792, 1792x1024, 4096x4096quality— standard, hd, 4kbackground— opaque, transparentn— Number of images (1-4)
Pricing Estimates
| Quality | Resolution | Est. Price |
|---|---|---|
| Standard | 1024x1024 | $0.02-0.04 |
| HD | 1024x1792 / 1792x1024 | $0.04-0.08 |
| 4K | 4096x4096 | $0.08-0.12 |
| Transparent | Any size | +$0.01 surcharge |
* Pricing estimates based on gpt-image-1 patterns. Official pricing may differ.
Code Examples
Python
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.gpt-image-2.xyz/v1" # Switch to api.openai.com on launch
)
response = client.images.generate(
model="gpt-image-2",
prompt="A futuristic city skyline at sunset with flying cars",
size="1024x1024",
quality="hd",
n=1,
)
image_url = response.data[0].url
print(image_url)Node.js
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: "your-api-key",
baseURL: "https://api.gpt-image-2.xyz/v1", // Switch to api.openai.com on launch
});
const response = await openai.images.generate({
model: "gpt-image-2",
prompt: "A futuristic city skyline at sunset with flying cars",
size: "1024x1024",
quality: "hd",
n: 1,
});
console.log(response.data[0].url);cURL
curl -X POST https://api.gpt-image-2.xyz/v1/images/generations \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A futuristic city skyline at sunset with flying cars",
"size": "1024x1024",
"quality": "hd",
"n": 1
}'Our Compatible API
Our compatible API is available today at https://api.gpt-image-2.xyz/v1. It follows the OpenAI endpoint format exactly, so you can:
- Use the official OpenAI Python and Node.js SDKs — just change the base URL
- Build and test your integration today
- Switch to
api.openai.comwhen GPT Image 2 launches — one line change
Try the API Visually
Try it now