Router One
Router One
图片生成

创建图片编辑(图生图)

根据文本指令改写参考图(图生图):风格迁移、替换背景、修改主体、局部修复等。与文生图一样是同步接口,请求会在图片生成完成后返回;典型耗时 5-30 秒,建议客户端 HTTP 超时设置不少于 60 秒。 与其他 JSON 接口不同,该接口使用 `multipart/form-data`,参考图以文件形式上传。传一个 `image` 字段即可;所选模型支持多参考图时,可重复传多个 `image` 字段(也接受 `image[]`)。每个文件必须是图片格式,大小不超过 25 MB。 响应结构与计费和文生图一致:`data` 数组长度等于实际生成的图片数量,`url` 方式返回的链接有效期约 1 小时,如需长期保存请下载或转存。

POST
/v1/images/edits
AuthorizationBearer <token>

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

In: header

modelstring

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

promptstring

描述如何改写参考图的文本指令,例如「把这张照片变成水彩画风格」「把背景换成日落海滩」。建议长度不超过 4000 字符。

Lengthlength <= 4000
imagefile

参考图文件(PNG / JPEG / WebP 等)。所选模型支持多参考图时,可重复传多个 image 字段(也接受 image[])。单个文件不超过 25 MB。

Formatbinary
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/edits" \  -F model="image-default" \  -F prompt="string" \  -F image="string"
{
  "created": 1700000000,
  "data": [
    {
      "url": "https://cdn.router.one/img/def456.png"
    }
  ]
}
{
  "error": {
    "message": "invalid request body: image is required",
    "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"
  }
}