Image
gpt-image-2-generate
API usage guide for gpt-image-2-generate.
Model ID
Calling method: sync
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
API usage guide for gpt-image-2-generate.
gpt-image-2-generate
Authorization: Bearer YOUR_API_KEY
POST /api/v1/ie/requestqueue/apikey/requests
curl -X POST "https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-generate",
"payload": {
"prompt": "A photograph of a red fox in an autumn forest",
"size": "1920x1080",
"quality": "medium",
"output_format": "png",
"n": 1
}
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
model | string | Yes | Model identifier | - |
payload.prompt | string | Yes | Text description of the image to generate | - |
payload.size | string (enum) | No | Output resolution and aspect ratio | "1920x1080" |
payload.quality | string (enum) | No | Image quality level — affects detail and cost | "medium" |
payload.n | integer | No | Number of images to generate | 1 |
payload.output_format | string (enum) | No | File format of the generated image | "png" |
{
"request_id": "cd5b59d5-1b3f-4fd5-9899-15ecea1f28ba",
"model": "gpt-image-2-generate",
"status": "success",
"outcome": {
"media_urls": [{"id": "0", "url": "https://storage.googleapis.com/..."}],
"thumbnail_image_url": "https://storage.googleapis.com/..."
}
}
| Token Type | Price |
|---|---|
| Text input tokens | $5.00 / 1M tokens |
| Cached text input tokens | $1.25 / 1M tokens |
| Image input tokens | $8.00 / 1M tokens |
| Cached image input tokens | $2.00 / 1M tokens |
| Image output tokens | $30.00 / 1M tokens |
Total cost =
(text_input_tokens × $5.00 / 1,000,000)
+ (cached_text_input_tokens × $1.25 / 1,000,000)
+ (image_input_tokens × $8.00 / 1,000,000)
+ (cached_image_input_tokens × $2.00 / 1,000,000)
+ (image_output_tokens × $30.00 / 1,000,000)
| Quality | 1024x1024 | 1024x1536 | 1536x1024 |
|---|---|---|---|
| Low | $0.006 | $0.005 | $0.005 |
| Medium | $0.053 | $0.041 | $0.041 |
| High | $0.211 | $0.165 | $0.165 |
GET /api/v1/ie/requestqueue/apikey/requests/{request_id}
https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests/v1
curl -X POST "https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A red fox in an autumn forest",
"size": "1024x1024",
"quality": "medium",
"output_format": "png",
"n": 1
}'
| Parameter | Type | Required | Description | Default | Notes |
|---|---|---|---|---|---|
model | string | Yes | Must be "gpt-image-2" | - | No other value accepted |
prompt | string | Yes | Text description | - | - |
size | string | No | WxH format | "1024x1024" | Both dimensions must be multiples of 16; max edge 3840px; aspect ratio ≤ 3:1 |
quality | string | No | low / medium / high / auto | "medium" | - |
n | integer | No | Number of images (1–10) | 1 | Each image billed separately |
output_format | string | No | png / jpeg | "png" | - |
output_compression | integer | No | Compression level 0–100 | null | Only valid for jpeg |
background | string | No | auto / opaque | "auto" | - |
moderation | string | No | auto / low | "auto" | - |
{
"created": 1780943845,
"size": "1024x1024",
"quality": "low",
"output_format": "png",
"data": [
{ "b64_json": "<base64-encoded-image>" }
],
"usage": {
"input_tokens": 16,
"input_tokens_details": { "text_tokens": 16, "image_tokens": 0 },
"output_tokens": 196,
"output_tokens_details": { "image_tokens": 196, "text_tokens": 0 },
"total_tokens": 212
}
}
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests/v1"
)
response = client.images.generate(
model="gpt-image-2",
prompt="A red fox in an autumn forest",
size="1024x1024",
quality="medium"
)
print(response.data[0].b64_json)