Image generation and editing
Submit prompts or reference images, save results, and check task status.
Select a model
Choose an image model and line supporting the Images API, then configure the key from the API overview. Image models do not all share a protocol; native Gemini image models use their native content structure.
Generate from text
Replace <model-id> with an actual image model before running this Bash request.
curl --fail-with-body 'https://gateway.irouter.io/v1/images/generations' \
-H "Authorization: Bearer $IROUTER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"model":"<model-id>","prompt":"A clean product photograph of a ceramic cup on a white desk."}'Add size, count, quality, and response format only as supported by the model. The basic example omits these options to avoid presenting model-specific settings as universal.
Edit an image
Select an editing-capable model and replace input.png with your reference file. This example applies to lines accepting a single image file field. Configure multiple images and masks according to the selected model.
curl --fail-with-body 'https://gateway.irouter.io/v1/images/edits' \
-H "Authorization: Bearer $IROUTER_API_KEY" \
-F 'model=<model-id>' \
-F 'image=@input.png' \
-F 'prompt=Change the background to a bright studio and keep the main object.'Save results and handle long tasks
Synchronous responses may provide URLs or Base64 images in data. Save according to the actual fields. Temporary result URLs can expire; download results to your own storage. Keep full Base64 responses out of logs.
If a line returns a task ID, follow its documented task protocol. Do not reuse another service's asynchronous endpoints, status names, or polling interval. The playground can display task status for supported models.
A submission timeout does not prove the task never ran. Check tasks and usage before retrying to avoid duplicate generation and charges. Reconcile charges and failures using the applicable records.