GPT Image 2 API
Complete API reference for GPT Image 2 models powered by OpenAI.
Model Variants
This API supports four model variants:
Quick Comparison
Supported Aspect Ratios
16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
GPT Image 2 (Text-to-Image)
Endpoint
POST /api/v1/image/task
Authentication
Authorization: Bearer YOUR_API_KEY
Request Parameters
Required
Note: The width:height ratio must be one of: 16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
Example Request
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'gpt-image-2',
prompt: 'A minimalist product shot of a ceramic mug on marble, soft studio light',
width: 1,
height: 1,
resolution: '1k',
quality: 'medium'
})
});
const { data } = await response.json();
const taskId = data.task_id;
const pollResponse = await fetch(
`https://api.flaq.ai/api/v1/image/${taskId}`,
{
headers: { Authorization: 'Bearer YOUR_API_KEY' }
}
);
const result = await pollResponse.json();
console.log(result.data.task_result.images[0].url);
GPT Image 2 Edit (Image Editing)
Endpoint
POST /api/v1/image/task
Request Parameters
Required
Optional
Note: When width and height are provided, the ratio must be one of: 16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
Single Image Edit Example
{
model_name: 'gpt-image-2-edit',
prompt: 'Replace the background with a clean studio scene and brighten the product lighting',
image_url_list: ['https://example.com/product-photo.jpg'],
width: 16,
height: 9,
resolution: '1k',
quality: 'medium'
}
Multi-Image Composition Example
{
model_name: 'gpt-image-2-edit',
prompt: 'Blend these reference images into a polished campaign composition while keeping the main subject identity consistent',
image_url_list: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg',
'https://example.com/image3.jpg'
],
width: 16,
height: 9,
resolution: '2k',
quality: 'high'
}
GPT Image 2 Client
Uses the same parameters and capabilities as GPT Image 2, with model_name set to gpt-image-2-client. This is a preview experience variant and may be less stable.
Example Request
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'gpt-image-2-client',
prompt: 'A luxury skincare still life with soft reflections and elegant typography',
width: 4,
height: 5,
resolution: '1k',
quality: 'medium'
})
});
const { data } = await response.json();
const taskId = data.task_id;
GPT Image 2 Edit Client
Uses the same parameters and capabilities as GPT Image 2 Edit, with model_name set to gpt-image-2-edit-client. This is a preview experience variant and may be less stable.
Example Request
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'gpt-image-2-edit-client',
prompt: 'Turn this portrait into a clean editorial poster while preserving the face and pose',
image_url_list: ['https://example.com/portrait.jpg'],
width: 4,
height: 5,
resolution: '1k',
quality: 'medium'
})
});
const { data } = await response.json();
const taskId = data.task_id;
Initial Response
All GPT Image 2 variants return a task_id for polling:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "submitted",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}"
},
"message": "success"
}
Polling Response
Poll GET /api/v1/image/{task_id} to check status:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_result": {
"credit": 0.0997,
"images": [
{
"url": "https://example.com/generated-image.jpeg"
}
]
}
},
"message": "success"
}
Status Values
submitted: Task accepted
processing: Image generation or editing in progress
succeed: Task completed successfully
failed: Task failed
Processing Time
Typical processing time is 15-60 seconds depending on resolution, quality, prompt complexity, and image count for edit requests.
Best Practices
- Be explicit about composition: GPT Image 2 performs best when prompts describe subject, framing, lighting, and intended style clearly.
- Choose quality based on workflow: Use
low or medium for iteration, and high for polished output.
- Match aspect ratio to delivery target: Set the ratio up front for social posts, banners, product pages, or editorial layouts.
- Use clean source images for edits: Sharp, well-lit inputs improve identity preservation and local edit quality.
- Limit multi-image requests to strong references: For edit variants, provide only the images that matter to avoid conflicting visual guidance.