API reference
Images
POST https://api.flyrouter.ai/v1/images/generations
POST https://api.flyrouter.ai/v1/images/edits
OpenAI Images-compatible endpoints for generating and editing images. The API waits until the image is ready and returns it synchronously; this usually takes from tens of seconds to a few minutes, so set your client timeout to 10 minutes or more. For a walkthrough, see Image generation.
Generate images
Terminal
curl https://api.flyrouter.ai/v1/images/generations \
-H "Authorization: Bearer $FLYROUTER_API_KEY" \
-H "Content-Type: application/json" \
--max-time 660 \
-d '{
"model": "gpt-image-2",
"prompt": "A minimalist coffee shop logo on a white background",
"size": "1:1",
"resolution": "1K"
}'Request parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Required. gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, nano-banana-2, nano-banana-2.1 or nano-banana-pro |
prompt | string | Required. What to draw |
resolution | string | 0.5K (nano-banana-2 only), 1K (default), 2K, 4K |
size | string | Aspect ratio, such as 1:1, 3:2, 16:9 or 9:16. GPT Image doesn't accept pixel sizes |
n | integer | Number of images. 1–4 for gpt-image-2.5-*; 1 for other models |
image_urls | array | Reference images as https:// links or Data URLs |
response_format | string | url (default) or b64_json |
Response
json
{
"created": 1761800000,
"data": [
{ "url": "https://api.flyrouter.ai/v1/tasks/task_abc/artifacts/image-0/content?access=..." }
]
}With b64_json, each item includes both b64_json (the image as Base64) and url.
Edit images
The request body is multipart/form-data:
| Field | Description |
|---|---|
model | Required. The image model ID |
prompt | Required. What to change |
image / image[] | Required. The source image, up to 20 MB each; use image[] for several |
resolution, size, response_format | Same as above |
Terminal
curl https://api.flyrouter.ai/v1/images/edits \
-H "Authorization: Bearer $FLYROUTER_API_KEY" \
--max-time 660 \
-F model="gpt-image-2" \
-F image="@product.png" \
-F prompt="Place the product on a wooden table in soft natural light"Errors
| Status | Error code | Description |
|---|---|---|
400 | image_generation_failed | Generation failed (for example, the content was rejected). Not billed |
400 | — | Invalid parameters, such as a pixel size for GPT Image or n out of range |
504 | task_timeout | Still not finished after 10 minutes. The task keeps running in the background; use the task ID in the error message with GET /v1/tasks/{task_id}/artifacts to fetch the result |