Create Image Generation
根据文本提示词生成图片。该接口为同步接口,请求会在图片生成完成后返回;典型耗时 5-30 秒,建议客户端 HTTP 超时设置不少于 60 秒。 响应中的 `data` 数组长度等于实际生成的图片数量,按张数计费。当 `response_format` 为 `url` 时返回的图片链接具有有效期(通常 1 小时),如需长期保存请下载或转存到自有存储。
使用 API Key 进行认证。在 Router One 控制台获取你的 API Key,格式为 sk-xxx。
In: header
模型 ID。需选择支持图片生成能力的模型,可在控制台模型市场查询。
图片生成的文本提示词。描述越具体、越富画面感,生成效果通常越好。建议长度不超过 4000 字符。
length <= 4000本次请求生成的图片数量。按张数计费。
11 <= value <= 10生成图片的尺寸,格式 宽x高(像素)。常用值:1024x1024、512x512、1792x1024、1024x1792。具体支持范围取决于所选模型。
图片质量。hd 通常分辨率更高、细节更丰富,但生成耗时与计费可能更高。
"standard""standard" | "hd"响应中图片的返回方式。
url(默认):返回 CDN URL,有效期约 1 小时,需自行下载或转存b64_json:直接在响应中返回 base64 编码的图片字节,响应体较大但无需额外下载
"url""url" | "b64_json"Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://api.router.one/v1/images/generations" \ -H "Content-Type: application/json" \ -d '{ "model": "image-default", "prompt": "一只戴着宇航员头盔的橙色小猫,漂浮在星空背景中,电影感打光" }'{
"created": 1700000000,
"data": [
{
"url": "https://cdn.router.one/img/abc123.png",
"revised_prompt": "An orange kitten wearing an astronaut helmet, floating in starry space, cinematic lighting"
}
]
}{
"error": {
"message": "Model 'unknown-model' does not support image generation",
"type": "invalid_request_error",
"code": "invalid_request"
}
}{
"error": {
"message": "Invalid API key",
"type": "authentication_error",
"code": "invalid_api_key"
}
}{
"error": {
"message": "Insufficient balance",
"type": "billing_error",
"code": "insufficient_balance"
}
}{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "string",
"type": "string",
"code": "string"
}
}{
"error": {
"message": "Service temporarily unavailable, please retry",
"type": "service_unavailable",
"code": "service_unavailable"
}
}Create Chat Completion POST
创建一个聊天补全请求。兼容 OpenAI Chat Completions API 格式,支持流式和非流式响应。 设置 `model` 为 `auto` 时,Router One 将根据路由策略自动选择最佳模型。
Get Video Generation Status GET
查询视频生成任务状态。`status` 字段取值: - `pending` — 任务已接受,尚未开始处理 - `processing` — 正在生成,可读取 `progress` - `completed` — 生成完成,读取 `url` 获取视频文件 - `failed` — 生成失败,读取 `error` 获取原因 建议轮询间隔不少于 3 秒。视频文件 URL 具有有效期(通常 24 小时),如需长期保存请下载或转存到自有存储。