跳转到主要内容
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)

请求参数

参数类型描述
modelstring图像生成模型 ID
promptstring所需图像的文字描述。DALL-E 3 最多 4,000 个字符,DALL-E 2 最多 1,000 个字符。
ninteger生成图像数量(默认 1)。DALL-E 3 仅支持 n=1
sizestring图像尺寸(因模型而异)
qualitystring"standard""hd"(仅 DALL-E 3,默认 "standard"
stylestring"vivid"(超现实)或 "natural"(仅 DALL-E 3)
response_formatstring"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-3OpenAI最高 1792×1024style 参数
openai/dall-e-2OpenAI最高 1024×1024
stability/stable-diffusion-3-largeStability AI最高 1024×1024
black-forest-labs/flux-1-proReplicate灵活

定价

模型尺寸费用
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-21024×1024$0.020
ARouter 返回的图像 URL 在 1 小时后过期。请下载并保存您想保留的图像。