Router One
Images

Create Image Generation

根据文本提示词生成图片。该接口为同步接口,请求会在图片生成完成后返回;典型耗时 5-30 秒,建议客户端 HTTP 超时设置不少于 60 秒。 响应中的 `data` 数组长度等于实际生成的图片数量,按张数计费。当 `response_format` 为 `url` 时返回的图片链接具有有效期(通常 1 小时),如需长期保存请下载或转存到自有存储。

POST
/v1/images/generations
AuthorizationBearer <token>

使用 API Key 进行认证。在 Router One 控制台获取你的 API Key,格式为 sk-xxx

In: header

modelstring

模型 ID。需选择支持图片生成能力的模型,可在控制台模型市场查询。

promptstring

图片生成的文本提示词。描述越具体、越富画面感,生成效果通常越好。建议长度不超过 4000 字符。

Lengthlength <= 4000
n?integer

本次请求生成的图片数量。按张数计费。

Default1
Range1 <= value <= 10
size?string

生成图片的尺寸,格式 宽x高(像素)。常用值:1024x1024512x5121792x10241024x1792。具体支持范围取决于所选模型。

quality?string

图片质量。hd 通常分辨率更高、细节更丰富,但生成耗时与计费可能更高。

Default"standard"
Value in"standard" | "hd"
response_format?string

响应中图片的返回方式。

  • url(默认):返回 CDN URL,有效期约 1 小时,需自行下载或转存
  • b64_json:直接在响应中返回 base64 编码的图片字节,响应体较大但无需额外下载
Default"url"
Value in"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"
  }
}