Generate images

Create an image from a text prompt.

POSThttps://your-instance.com/v1/images/generations

Synchronous image generation in the OpenAI format. The response carries either a URL or base64 bytes depending on response_format.

Request body

  • modelstringrequired

    Image model to use, e.g. gpt-image-2.

  • promptstringrequired

    Description of the image you want.

  • nintegerdefault: 1

    How many images to generate.

  • sizestringdefault: "1024x1024"

    Output dimensions. Supported sizes vary by model.

  • qualitystringdefault: "standard"

    Rendering quality. Higher quality costs more.

  • response_formatstringdefault: "url"

    Either "url" or "b64_json".

Example

curl https://your-instance.com/v1/images/generations \
  -H "Authorization: Bearer $CLAWROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A lighthouse in a storm, oil painting",
    "size": "1024x1024"
  }'