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)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.arouter.ai/v1",
apiKey: "lr_live_xxxx",
});
const response = await client.images.generate({
model: "openai/dall-e-3",
prompt: "A futuristic city skyline at sunset, photorealistic",
n: 1,
size: "1024x1024",
quality: "hd",
});
console.log(response.data[0].url);
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",
"quality": "hd"
}'
Request Parameters
| Parameter | Type | Description |
|---|
model | string | Image generation model ID (see Supported Models) |
prompt | string | Text description of the desired image. Max 4,000 characters for DALL-E 3, 1,000 for DALL-E 2. |
n | integer | Number of images to generate (default 1). DALL-E 3 only supports n=1. |
size | string | Image dimensions (model-specific, see below) |
quality | string | "standard" or "hd" (DALL-E 3 only, default "standard") |
style | string | "vivid" (hyper-real) or "natural" (more realistic, DALL-E 3 only) |
response_format | string | "url" (default) or "b64_json" |
{
"created": 1234567890,
"data": [
{
"url": "https://...",
"revised_prompt": "A photorealistic futuristic city skyline at sunset..."
}
]
}
| Field | Description |
|---|
url | Temporary URL to the generated image (expires after 1 hour) |
b64_json | Base64-encoded image data (when response_format: "b64_json") |
revised_prompt | DALL-E 3 may revise your prompt for better results. This field shows the actual prompt used. |
Image Sizes
DALL-E 3
| Size | Aspect Ratio |
|---|
1024x1024 | Square (1:1) |
1792x1024 | Landscape (16:9) |
1024x1792 | Portrait (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.
| Model | Provider | Resolution | Style Control |
|---|
openai/dall-e-3 | OpenAI | Up to 1792×1024 | style param |
openai/dall-e-2 | OpenAI | Up to 1024×1024 | — |
stability/stable-diffusion-3-large | Stability AI | Up to 1024×1024 | — |
black-forest-labs/flux-1-pro | Replicate | Flexible | — |
black-forest-labs/flux-1-schnell | Replicate | Flexible | — |
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:
| Model | Size | Cost |
|---|
openai/dall-e-3 standard | 1024×1024 | $0.040 |
openai/dall-e-3 standard | 1024×1792 or 1792×1024 | $0.080 |
openai/dall-e-3 HD | 1024×1024 | $0.080 |
openai/dall-e-3 HD | 1024×1792 or 1792×1024 | $0.120 |
openai/dall-e-2 | 1024×1024 | $0.020 |
openai/dall-e-2 | 512×512 | $0.018 |
openai/dall-e-2 | 256×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.