About
GPT Image 2 is OpenAI's next-generation image generation model. It supports flexible resolutions up to 4K and multiple model variants.
Use it as an image-to-image (editing) API through Infron!!
1. Calling the API
Setup your API Key
To begin using Infron, you first need to create an account and generate your API Key.
Once you have your API key, set it as an environment variable in your runtime environment. This allows your applications to securely access Infron’s API.
export INFRON_KEY="YOUR_API_KEY"
Submit a request
For long-running requests, you can poll for results.
curl https://media.onerouter.pro/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2/image-to-image",
"size": "auto",
"quality": "auto",
"background": "auto",
"moderation": "auto",
"prompt": "Wrap the double-decker bus from the first image with the exact branding design from the second image as a full bus livery. Keep the street scene, people, and background unchanged.",
"image_urls": [
"https://storage.googleapis.com/infron_gcs/image%2Fplayground-inputs%2F15%2F20260520%2F5da1bb9b-69c9-4d8e-b66f-a6fc4d79e596.jpg",
"https://storage.googleapis.com/infron_gcs/image%2Fplayground-inputs%2F15%2F20260520%2Ff188c353-84ab-4263-87d8-74790434d31a.jpg"
]
}'
Response with queue task id
The response will look like this:
{
"code": 200,
"message": "success",
"data": {
"task_id": "bc867aad07b74cc893cf2d3e62725878",
"object": "image",
"model": "openai/gpt-image-2/image-to-image",
"status": "created",
"urls": {
"query": "https://media.onerouter.pro/v1/images/tasks/bc867aad07b74cc893cf2d3e62725878"
},
"created_at": "2026-05-29 14:48:35.72"
}
}
Fetch request status
You can fetch the status of a request to check if it is completed or still in progress.
curl https://media.onerouter.pro/v1/images/tasks/{task_id} \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
# For example
curl https://media.onerouter.pro/v1/images/tasks/bc867aad07b74cc893cf2d3e62725878 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
Response with queue task status query
{
"code": 200,
"message": "success",
"data": {
"task_id": "bc867aad07b74cc893cf2d3e62725878",
"object": "image",
"model": "openai/gpt-image-2/image-to-image",
"status": "in_progress",
"fail_reason": "",
"submit_time": 1780066116,
"start_time": 1780066115,
"finish_time": 0,
"outputs": [],
"created_at": "2026-05-29 14:48:36"
}
}
Possible statuses:
- created
- in_progress
- processing
- completed
- failed
created -> in_progress → processing → completed | failed
Poll every 1-2 seconds until status is "completed" or "failed"
Get the result (when status is "completed")
Once the request is completed, you can fetch the result. See the Output Schema for the expected result format.
{
"code": 200,
"message": "success",
"data": {
"task_id": "bc867aad07b74cc893cf2d3e62725878",
"object": "image",
"model": "openai/gpt-image-2/image-to-image",
"status": "completed",
"fail_reason": "",
"submit_time": 1780066116,
"start_time": 1780066115,
"finish_time": 1780066284,
"outputs": [
"https://storage.googleapis.com/infron_gcs/image%2Fgenerated%2Fofficial_openai_image_82e5bae4849c4cda98066d8ed3889983.png"
],
"usage": {
"completion_tokens": 5488,
"completion_tokens_details": {
"image_tokens": 5488,
"text_tokens": 0
},
"image_count": 1,
"prompt_tokens": 3005,
"prompt_tokens_details": {
"image_tokens": 2960,
"text_tokens": 45
},
"quality": "auto",
"size": "auto",
"total_tokens": 8493,
"web_search": false
},
"cost": {
"total_cost": 0.188545,
"cost_details": {
"prompt_cost": 0,
"completion_cost": 0,
"image_cost": 0.188545,
"video_cost": 0,
"audio_cost": 0,
"native_web_search_cost": 0,
"plugin_web_search_cost": 0,
"tools_cost": 0,
"prompt_cache_read_cost": 0,
"prompt_cache_write_cost": 0,
"prompt_cache_write_5_min": 0,
"prompt_cache_write_1_h": 0,
"reasoning_cost": 0,
"discount_rate": 1,
"is_byok": false,
"byok_cost": 0
}
},
"created_at": "2026-05-29 14:48:36"
}
}
2. Schema
Input
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
| model | string | Yes | -- | Explore all models | Model name. |
| image_urls | array | Yes | -- | -- | The URLs of the images to use as a reference for the generation. |
| prompt | string | Yes | -- | -- | Text prompt for generation; Positive text prompt. |
| n | integer | No | 1 | >=1 | Number of images to generate. |
| size | string | No | auto | auto, 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, 2160x3840, "WIDTHxHEIGHT" | The size of the generated image. Use 'auto' to infer from input images. You can also use 'WIDTHxHEIGHT' format to specify the exact size. The model supports any resolution passed in the size parameter as long as all of these constraints are met: 1) Maximum edge length must be less than 3840px; 2) Both edges must be a multiple of 16; 3) Ratio between the long edge and short edge must not be greater than 3:1; 4) Total pixels must not exceed 8,294,400; 5) Total pixels must not be less than 655,360. |
| quality | string | No | auto | auto, low, medium, high | Quality for the generated image. Use 'auto' to let the model pick the best quality for the prompt. |
| output_format | string | No | png | png, jpeg, webp | Output format for the images. |
| background | string | No | auto | auto, opaque | Opaque or automatic. |
| moderation | string | No | auto | auto, low | You can control moderation strictness with the moderation parameter. |
Example request
curl https://media.onerouter.pro/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2/image-to-image",
"size": "auto",
"quality": "auto",
"background": "auto",
"moderation": "auto",
"prompt": "Wrap the double-decker bus from the first image with the exact branding design from the second image as a full bus livery. Keep the street scene, people, and background unchanged.",
"image_urls": [
"https://storage.googleapis.com/infron_gcs/image%2Fplayground-inputs%2F15%2F20260520%2F5da1bb9b-69c9-4d8e-b66f-a6fc4d79e596.jpg",
"https://storage.googleapis.com/infron_gcs/image%2Fplayground-inputs%2F15%2F20260520%2Ff188c353-84ab-4263-87d8-74790434d31a.jpg"
]
}'
Output
| Parameter | Type | Range | Description |
|---|---|---|---|
| code | integer | -- | Status code of the request. |
| message | string | -- | Status message of the request. |
| data | object | -- | Data of the task. |
| data.task_id | string | -- | ID of the task. |
| data.object | string | -- | Object type of the task. |
| data.model | string | -- | Model name of the task. |
| data.status | string | created, in_progress, processing, completed, failed | Status of the task. |
| data.fail_reason | string | -- | Fail reason of the task. |
| data.submit_time | integer | -- | Timestamp of the task submission. |
| data.start_time | integer | -- | Timestamp of the task start. |
| data.finish_time | integer | -- | Timestamp of the task finish. |
| data.outputs | array | -- | Outputs of the task. |
| data.created_at | string | -- | Timestamp of the task creation. |
Example output
{
"code": 200,
"message": "success",
"data": {
"task_id": "bc867aad07b74cc893cf2d3e62725878",
"object": "image",
"model": "openai/gpt-image-2/image-to-image",
"status": "completed",
"fail_reason": "",
"submit_time": 1780066116,
"start_time": 1780066115,
"finish_time": 1780066284,
"outputs": [
"https://storage.googleapis.com/infron_gcs/image%2Fgenerated%2Fofficial_openai_image_82e5bae4849c4cda98066d8ed3889983.png"
],
"usage": {
"completion_tokens": 5488,
"completion_tokens_details": {
"image_tokens": 5488,
"text_tokens": 0
},
"image_count": 1,
"prompt_tokens": 3005,
"prompt_tokens_details": {
"image_tokens": 2960,
"text_tokens": 45
},
"quality": "auto",
"size": "auto",
"total_tokens": 8493,
"web_search": false
},
"cost": {
"total_cost": 0.188545,
"cost_details": {
"prompt_cost": 0,
"completion_cost": 0,
"image_cost": 0.188545,
"video_cost": 0,
"audio_cost": 0,
"native_web_search_cost": 0,
"plugin_web_search_cost": 0,
"tools_cost": 0,
"prompt_cache_read_cost": 0,
"prompt_cache_write_cost": 0,
"prompt_cache_write_5_min": 0,
"prompt_cache_write_1_h": 0,
"reasoning_cost": 0,
"discount_rate": 1,
"is_byok": false,
"byok_cost": 0
}
},
"created_at": "2026-05-29 14:48:36"
}
}
3. Detailed Pricing
| Size | Low Quality | Medium Quality | High Quality |
|---|---|---|---|
| 1024 x 1024 | $0.015 | $0.061 | $0.219 |
| 1536 x 1024 | $0.018 | $0.072 | $0.260 |
| 1024 x 1536 | $0.018 | $0.072 | $0.260 |
| 2048 x 2048 | $0.023 | $0.092 | $0.330 |
| 2048 x 1152 | $0.020 | $0.080 | $0.290 |
| 3840 x 2160 | $0.024 | $0.113 | $0.413 |
| 2160 x 3840 | $0.024 | $0.113 | $0.413 |