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

ParameterTypeDescription
modelstringRequired. gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, nano-banana-2, nano-banana-2.1 or nano-banana-pro
promptstringRequired. What to draw
resolutionstring0.5K (nano-banana-2 only), 1K (default), 2K, 4K
sizestringAspect ratio, such as 1:1, 3:2, 16:9 or 9:16. GPT Image doesn't accept pixel sizes
nintegerNumber of images. 1–4 for gpt-image-2.5-*; 1 for other models
image_urlsarrayReference images as https:// links or Data URLs
response_formatstringurl (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:

FieldDescription
modelRequired. The image model ID
promptRequired. What to change
image / image[]Required. The source image, up to 20 MB each; use image[] for several
resolution, size, response_formatSame 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

StatusError codeDescription
400image_generation_failedGeneration 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
504task_timeoutStill 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
FlyRouter

One key, every top AI model