CloseRouter

Images

Generate and edit images through the API.

Before the request

Choose a model and operation. GET /media/models lists supported parameters and prices; POST /media/quote estimates the maximum cost without generating an image.

Save the result before its link expires in 30 days. For an unfinished request, check its status instead of submitting a new generation.

GPT Image generation

curl
curl https://api.closerouter.dev/v1/images/generations \
  -H "Authorization: Bearer $CLOSEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-2",
    "prompt": "A minimal product photo on a white background",
    "n": 1,
    "size": "1024x1024",
    "quality": "medium"
  }'

Gemini image generation

curl
curl https://api.closerouter.dev/v1/images/generations \
  -H "Authorization: Bearer $CLOSEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3-pro-image",
    "prompt": "A minimal product photo on a white background",
    "size": "1024x1024",
    "input": { "resolution": "4K" }
  }'

Image edits

multipart/form-data
curl https://api.closerouter.dev/v1/images/edits \
  -H "Authorization: Bearer $CLOSEROUTER_API_KEY" \
  -F "model=openai/gpt-image-2" \
  -F "image[]=@input.png" \
  -F "prompt=Replace the background with a clean studio backdrop"

Parameters and limits