Skip to main content
ARouter supports image generation via the OpenAI-compatible /v1/images/generations endpoint. Use any supported image generation model with a single API key.

Quick Start

curl https://api.arouter.ai/v1/images/generations \
  -H "Authorization: Bearer lr_live_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/dall-e-3",
    "prompt": "A futuristic city skyline at sunset, photorealistic",
    "n": 1,
    "size": "1024x1024"
  }'
from openai import OpenAI

client = OpenAI(
    base_url="https://api.arouter.ai/v1",
    api_key="lr_live_xxxx",
)

response = client.images.generate(
    model="openai/dall-e-3",
    prompt="A futuristic city skyline at sunset, photorealistic",
    n=1,
    size="1024x1024",
    quality="hd",
)

print(response.data[0].url)

Request Parameters

ParameterTypeDescription
modelstringImage generation model ID (see Supported Models)
promptstringText description of the desired image. Max 4,000 characters for DALL-E 3, 1,000 for DALL-E 2.
nintegerNumber of images to generate (default 1). DALL-E 3 only supports n=1.
sizestringImage dimensions (model-specific, see below)
qualitystring"standard" or "hd" (DALL-E 3 only, default "standard")
stylestring"vivid" (hyper-real) or "natural" (more realistic, DALL-E 3 only)
response_formatstring"url" (default) or "b64_json"

Response Format

{
  "created": 1234567890,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "A photorealistic futuristic city skyline at sunset..."
    }
  ]
}
FieldDescription
urlTemporary URL to the generated image (expires after 1 hour)
b64_jsonBase64-encoded image data (when response_format: "b64_json")
revised_promptDALL-E 3 may revise your prompt for better results. This field shows the actual prompt used.

Image Sizes

DALL-E 3

SizeAspect Ratio
1024x1024Square (1:1)
1792x1024Landscape (16:9)
1024x1792Portrait (9:16)

DALL-E 2

Size
256x256
512x512
1024x1024

Supported Models

Use GET /v1/models?output_modalities=image to query the current list of image generation models.
ModelProviderResolutionStyle Control
openai/dall-e-3OpenAIUp to 1792×1024style param
openai/dall-e-2OpenAIUp to 1024×1024
stability/stable-diffusion-3-largeStability AIUp to 1024×1024
black-forest-labs/flux-1-proReplicateFlexible
black-forest-labs/flux-1-schnellReplicateFlexible
Model availability may vary. Always query GET /v1/models?output_modalities=image for the current list.

Advanced Examples

High-Quality Portrait

response = client.images.generate(
    model="openai/dall-e-3",
    prompt="Professional headshot of a software engineer, studio lighting, sharp focus",
    size="1024x1792",
    quality="hd",
    style="natural",
    response_format="b64_json",
)

import base64
image_bytes = base64.b64decode(response.data[0].b64_json)
with open("portrait.png", "wb") as f:
    f.write(image_bytes)

Batch Generation with DALL-E 2

response = client.images.generate(
    model="openai/dall-e-2",
    prompt="A friendly robot assistant helping with paperwork",
    n=4,
    size="512x512",
)

for i, image in enumerate(response.data):
    print(f"Image {i+1}: {image.url}")

Routing to Specific Providers

Use the provider object to control which provider handles your image generation request:
{
  "model": "openai/dall-e-3",
  "prompt": "A mountain landscape at dawn",
  "provider": {
    "order": ["OpenAI"]
  }
}
See Provider Routing for full routing options.

Pricing

Image generation is billed per image, not per token. Costs vary by model and resolution:
ModelSizeCost
openai/dall-e-3 standard1024×1024$0.040
openai/dall-e-3 standard1024×1792 or 1792×1024$0.080
openai/dall-e-3 HD1024×1024$0.080
openai/dall-e-3 HD1024×1792 or 1792×1024$0.120
openai/dall-e-21024×1024$0.020
openai/dall-e-2512×512$0.018
openai/dall-e-2256×256$0.016
Costs for other models (Stability AI, Flux) are charged based on the upstream provider rate. Check usage.cost in the response for the actual charge.
Image URLs returned by ARouter expire after 1 hour. Download and store images you intend to keep.