GPT-Image
OpenAI's image generation model, good at complex prompt understanding, text rendering and multi-round refinement.
Endpoint
POST $URL/v1/images/generationsSupported Models
| Model | Positioning |
|---|---|
gpt-image-2-pro | High-quality image generation |
gpt-image-2-plus | Enhanced version |
Request Example
bash
curl $URL/v1/images/generations \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-pro",
"prompt": "A tech-inspired product poster with wireless earbuds in the center, dark blue gradient background, bold white text at the bottom: FUTURE SOUND",
"n": 1,
"size": "1024x1024"
}'python
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="$URL/v1")
resp = client.images.generate(
model="gpt-image-2-pro",
prompt="A tech-inspired product poster with wireless earbuds in the center, dark blue gradient background",
n=1,
size="1024x1024",
)
print(resp.data[0].url)ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.YOUR_API_KEY,
baseURL: '$URL/v1',
})
const resp = await client.images.generate({
model: 'gpt-image-2-pro',
prompt: 'A tech-inspired product poster with wireless earbuds in the center',
n: 1,
size: '1024x1024',
})
console.log(resp.data[0].url)Main Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | gpt-image-2-pro / gpt-image-2-plus |
prompt | string | Yes | Image description; include subject, style and text content |
n | integer | No | Number of images |
size | string | No | e.g. 1024x1024, 1792x1024, 1024x1792 |
quality | string | No | standard / hd |
Notes
- GPT-Image has strong text rendering ability, suitable for posters, covers and e-commerce main images.
- Generated result URLs are temporary; please download and save promptly.
