ARouter 通过与 OpenAI 兼容的 /v1/images/generations 端点支持图像生成。
快速开始
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);
请求参数
| 参数 | 类型 | 描述 |
|---|
model | string | 图像生成模型 ID |
prompt | string | 所需图像的文字描述。DALL-E 3 最多 4,000 个字符,DALL-E 2 最多 1,000 个字符。 |
n | integer | 生成图像数量(默认 1)。DALL-E 3 仅支持 n=1。 |
size | string | 图像尺寸(因模型而异) |
quality | string | "standard" 或 "hd"(仅 DALL-E 3,默认 "standard") |
style | string | "vivid"(超现实)或 "natural"(仅 DALL-E 3) |
response_format | string | "url"(默认)或 "b64_json" |
响应格式
{
"created": 1234567890,
"data": [
{"url": "https://...", "revised_prompt": "A photorealistic futuristic city skyline at sunset..."}
]
}
图像尺寸
DALL-E 3
| 尺寸 | 宽高比 |
|---|
1024x1024 | 正方形(1:1) |
1792x1024 | 横向(16:9) |
1024x1792 | 纵向(9:16) |
支持的模型
| 模型 | 提供商 | 分辨率 | 风格控制 |
|---|
openai/dall-e-3 | OpenAI | 最高 1792×1024 | style 参数 |
openai/dall-e-2 | OpenAI | 最高 1024×1024 | — |
stability/stable-diffusion-3-large | Stability AI | 最高 1024×1024 | — |
black-forest-labs/flux-1-pro | Replicate | 灵活 | — |
| 模型 | 尺寸 | 费用 |
|---|
openai/dall-e-3 标准版 | 1024×1024 | $0.040 |
openai/dall-e-3 标准版 | 1024×1792 或 1792×1024 | $0.080 |
openai/dall-e-3 HD 版 | 1024×1024 | $0.080 |
openai/dall-e-3 HD 版 | 1024×1792 或 1792×1024 | $0.120 |
openai/dall-e-2 | 1024×1024 | $0.020 |
ARouter 返回的图像 URL 在 1 小时后过期。请下载并保存您想保留的图像。