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 小時後過期。請下載並儲存您想保留的圖像。