# GPT Image 2 API Complete API reference for GPT Image 2 models powered by OpenAI. ## Model Variants This API supports four model variants: | Model | ID | Description | |-------|-----|-------------| | **GPT Image 2** | `gpt-image-2` | Text-to-image generation | | **GPT Image 2 Edit** | `gpt-image-2-edit` | Image editing and multi-image composition | | **GPT Image 2 Client** | `gpt-image-2-client` | Preview text-to-image generation with the same core capabilities as GPT Image 2 | | **GPT Image 2 Edit Client** | `gpt-image-2-edit-client` | Preview image editing and multi-image composition with the same core capabilities as GPT Image 2 Edit | ## Quick Comparison | Feature | GPT Image 2 | GPT Image 2 Edit | GPT Image 2 Client | GPT Image 2 Edit Client | |---------|-------------|------------------|--------------------|-------------------------| | Input | Text prompt | Image(s) + Text prompt | Text prompt | Image(s) + Text prompt | | Resolution Options | `1k`, `2k`, `4k` | `1k`, `2k`, `4k` | `1k`, `2k`, `4k` | `1k`, `2k`, `4k` | | Quality Options | `low`, `medium`, `high` | `low`, `medium`, `high` | `low`, `medium`, `high` | `low`, `medium`, `high` | | Aspect Ratios | 10 options | 10 options | 10 options | 10 options | | Image Input | No | Yes (1-16 images) | No | Yes (1-16 images) | | Multi-Image Support | No | Yes | No | Yes | ### 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 | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"gpt-image-2"` | | `prompt` | string | Image generation prompt | | `width` | number | Width ratio value (for example, `16` for `16:9`) | | `height` | number | Height ratio value (for example, `9` for `16:9`) | | `resolution` | string | Output resolution: `"1k"`, `"2k"`, or `"4k"` | | `quality` | string | Output quality: `"low"`, `"medium"`, or `"high"` | **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 ```javascript 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; // Poll for results 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 | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"gpt-image-2-edit"` | | `prompt` | string | Description of desired edits | | `image_url_list` | string[] | Array of input image URLs (1-16 items) | #### Optional | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `width` | number | - | Width ratio value (for example, `16` for `16:9`) | | `height` | number | - | Height ratio value (for example, `9` for `16:9`) | | `resolution` | string | `"1k"` | Output resolution: `"1k"`, `"2k"`, or `"4k"` | | `quality` | string | `"medium"` | Output quality: `"low"`, `"medium"`, or `"high"` | **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 ```javascript { 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 ```javascript { 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 ```javascript 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 ```javascript 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; ``` ## Response Format ### Initial Response All GPT Image 2 variants return a `task_id` for polling: ```json { "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: ```json { "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 1. **Be explicit about composition**: GPT Image 2 performs best when prompts describe subject, framing, lighting, and intended style clearly. 2. **Choose quality based on workflow**: Use `low` or `medium` for iteration, and `high` for polished output. 3. **Match aspect ratio to delivery target**: Set the ratio up front for social posts, banners, product pages, or editorial layouts. 4. **Use clean source images for edits**: Sharp, well-lit inputs improve identity preservation and local edit quality. 5. **Limit multi-image requests to strong references**: For edit variants, provide only the images that matter to avoid conflicting visual guidance.