Repository navigation
Image Generation
hanyuestar edited this page Aug 6, 2026
·
1 revision
one-api 支持通过 OpenAI 兼容的 /v1/images/generations 接口调用多种图片生成服务。
| 渠道类型 | 类型 ID | 上游服务 | 默认模型 | 请求方式 |
|---|---|---|---|---|
| OpenAI | 1 | OpenAI Dall-E | dall-e-3, dall-e-2 | 同步透传 |
| Azure | 3 | Azure OpenAI Dall-E | dall-e-3 (部署名) | 同步 Azure 路由 |
| 阿里通义千问 | 17 | DashScope (通义万相) | wanx-v1, ali-stable-diffusion-xl, ali-stable-diffusion-v1.5 | 异步轮询 → 回规 |
| 阿里云百炼 ★ | 49 | DashScope (通义万相) | wanx-v1, ali-stable-diffusion-xl, ali-stable-diffusion-v1.5 | 异步轮询 → 回规 |
| 智谱 ChatGLM | 16 | 智谱 CogView | cogview-3 | 同步转换 |
| Replicate | 46 | Replicate | 模型标识 (如 black-forest-labs/flux-schnell) |
异步轮询 + PNG 转码 |
| 字节火山引擎 ★ | 40 | 火山方舟 Seedream | doubao-seedream-5-0-pro-250828, doubao-seedream-5-0-lite-260128, doubao-seedream-4-5-251128, doubao-seedream-4-0 | 同步透传 (OpenAI 兼容) |
| OpenAI 兼容 | 50 | 任意 OpenAI 兼容服务 | dall-e-3 | 同步透传 |
| API2D / CloseAI / OpenAI-SB 等代理 | 2/4/5/6/7/9/10/12/13/20 | 各中转站 | 按中转站支持 | 同步透传 |
★ 标记的为本次 Fork 新增支持。
- 渠道类型:选择对应类型
- 密钥:填写 API Key
-
代理地址 (Base URL):填写服务地址
- OpenAI 官方:
https://api.openai.com - 其他兼容服务: 其 Base URL
- OpenAI 官方:
- 模型:选择或填入 dall-e-3、dall-e-2 或其他图片模型
请求将转发至 {base_url}/v1/images/generations。
- 渠道类型:Azure
- 密钥:Azure API Key
-
AZURE_OPENAI_ENDPOINT:
https://{resource}.openai.azure.com -
默认 API 版本:
2024-03-01-preview - 模型:填入 Azure 中的 dall-e 部署名
- 渠道类型:阿里通义千问 或 阿里云百炼
- 密钥:DashScope API Key (sk- 开头) 或百炼 API Key
-
模型:
wanx-v1、ali-stable-diffusion-xl、ali-stable-diffusion-v1.5 - 无需填写代理地址(后端自动路由到 DashScope)
阿里生图为异步任务模式:提交 → 获取 task_id → 轮询任务状态 → 成功后下载图片。one-api 内部自动完成整个流程,客户端感知为一次同步请求,返回标准 OpenAI 图片响应格式。
- 渠道类型:字节火山引擎 (Doubao)
- 密钥:火山 ARK API Key
-
模型:
doubao-seedream-5-0-pro-250828、doubao-seedream-5-0-lite-260128、doubao-seedream-4-5-251128、doubao-seedream-4-0 -
代理地址:
https://ark.cn-beijing.volces.com
火山引擎 Seedream 暴露 OpenAI 兼容的
/api/v3/images/generations接口,one-api 直接透传请求和响应。
- 渠道类型:智谱 ChatGLM
- 密钥:智谱 API Key
-
模型:
cogview-3 - 无需填写代理地址
- 渠道类型:Replicate
- 密钥:Replicate API Token (r8_ 开头)
-
模型:填入 Replicate 上的模型标识,如
black-forest-labs/flux-schnell - 无需填写代理地址
Replicate 为异步任务模式,one-api 自动轮询并下载生成的图片,统一转为 PNG 并以 Base64 返回。
所有渠道统一使用 OpenAI 格式:
{
"model": "dall-e-3",
"prompt": "一只坐在草地上的橘猫",
"n": 1,
"size": "1024x1024",
"quality": "standard",
"response_format": "url"
}响应统一为 OpenAI 格式:
{
"created": 1722936000,
"data": [
{
"url": "https://...",
"b64_json": "...",
"revised_prompt": "..."
}
]
}图片生成按模型、尺寸和生成数量计费。各模型的尺寸选项和倍率见源码 relay/billing/ratio/image.go。
| 模型 | 生成数量范围 | Prompt 长度限制 |
|---|---|---|
| dall-e-2 | 1-10 | 1000 |
| dall-e-3 | 1 | 4000 |
| wanx-v1 | 1-4 | 4000 |
| doubao-seedream | 1 | 1200 |
| cogview-3 | 1 | 833 |