API 参考OpenAI 兼容
Images
DALL-E API - 通过 UniterRouter 从文本提示生成图像。访问 DALL-E 3、Stable Diffusion、Midjourney 风格的统一图像生成 API。
Images
使用各种图像生成模型从文本描述创建图像。
端点
POST https://api.uniterouter.ai/v1/images/generations请求体
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | 是 | 要使用的图像模型 ID |
prompt | string | 是 | 所需图像的文本描述 |
n | integer | 否 | 要生成的图像数量(默认:1) |
size | string | 否 | 图像尺寸(例如 1024x1024) |
quality | string | 否 | 图像质量:standard 或 hd |
style | string | 否 | 风格:natural 或 vivid |
response_format | string | 否 | url(默认)或 b64_json |
支持的模型
| 模型 | 提供商 | 尺寸 | 特性 |
|---|---|---|---|
dall-e-3 | OpenAI | 1024x1024, 1792x1024, 1024x1792 | 高清质量、风格 |
dall-e-2 | OpenAI | 256x256, 512x512, 1024x1024 | 多图像 |
flux-pro | Black Forest Labs | 多种 | 高质量 |
flux-schnell | Black Forest Labs | 多种 | 快速生成 |
请求示例
curl https://api.uniterouter.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $UNITEROUTER_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "宁静的日式庭院,樱花盛开",
"size": "1024x1024",
"quality": "hd"
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.uniterouter.ai/v1",
api_key="your_api_key",
)
response = client.images.generate(
model="dall-e-3",
prompt="宁静的日式庭院,樱花盛开",
size="1024x1024",
quality="hd",
n=1
)
image_url = response.data[0].url
print(f"生成的图像: {image_url}")import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uniterouter.ai/v1",
apiKey: process.env.UNITEROUTER_API_KEY,
});
const response = await client.images.generate({
model: "dall-e-3",
prompt: "宁静的日式庭院,樱花盛开",
size: "1024x1024",
quality: "hd",
n: 1,
});
console.log(`生成的图像: ${response.data[0].url}`);响应
{
"created": 1706123456,
"data": [
{
"url": "https://...",
"revised_prompt": "宁静的日式庭院,精致的粉色樱花..."
}
]
}尺寸选项
DALL-E 3
| 尺寸 | 宽高比 | 用途 |
|---|---|---|
1024x1024 | 1:1 | 正方形,通用 |
1792x1024 | 16:9 | 横向,头图 |
1024x1792 | 9:16 | 纵向,移动端 |
质量与风格
- 质量:
standard(更快)或hd(更多细节) - 风格:
natural(写实)或vivid(戏剧性)
注意:DALL-E 的图像 URL 是临时的,约 1 小时后过期。请及时下载图像或使用 b64_json 格式。
How is this guide?