# Images

Generate images with a supported model and size. Results are returned as base64 JSON.

`POST /v1/images/generations`

`GET /v1/images/requests/{request_id}`

## Generate an image

Send model and prompt. Optional n is 1–10, size defaults to 1024x1024, and response_format must be b64_json. Use a size the selected model supports.

- Prompts can contain up to 16,000 characters. Extra fields such as quality, style, background and stream are unsupported. Image edits and variations are not exposed.
- Read data[].b64_json and decode it. URL-formatted results are unsupported. Store a copy in your application if you need lasting access.

### cURL

```text
curl --fail-with-body "https://urouter.net/gateway/v1/images/generations" \
  -H "Authorization: Bearer $UROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "model": "YOUR_IMAGE_MODEL_ID",
  "prompt": "A squirrel in a raincoat.",
  "n": 1,
  "size": "1024x1024",
  "response_format": "b64_json"
}'
```

## Recover a result

Save x-request-id. GET /v1/images/requests/{request_id} retrieves the owned image result while it remains available. Use the account’s API key for the read.

- Send one Idempotency-Key per logical generation. Reusing it with the same payload can return the stored result without starting another generation.
- HTTP 410 result_expired means the result is no longer retrievable. Its original charge remains recorded. Replay will not generate a replacement.
- For a timeout or outcome_unknown, read request status before deciding what to do. Never change the idempotency key just to bypass an unresolved request.
