Routescope APIRoutescope API
模型接口API文档图像模型Doubao Seedream

图像编辑

Doubao Seedream 图像编辑 API

Doubao Seedream 系列图像编辑接口统一使用 /v1/images/edits,支持参考图编辑、多图融合和视觉重绘。参考图通过 JSON 请求体中的 image 字段传入,不走 OpenAI 式文件上传协议。

POST
/v1/images/edits
curl -X POST "https://api.routescope.ai/v1/images/edits" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-image-2",    "prompt": "基于这两张参考图生成一张新图",    "images": [      {        "image_url": "https://example.com/a.png"      },      {        "image_url": "https://example.com/b.png"      }    ],    "size": "1024x1024"  }'
{
  "created": 1,
  "data": {}
}

Authorization

BearerAuth

AuthorizationBearer <token>

模型 relay 接口鉴权。请求头:Authorization: Bearer

In: header

Request Body

application/json

model*string

模型名称。腾讯 tokenhub 渠道会在网关内映射为上游需要的模型名。

Default"gpt-image-2"
prompt*string

图片编辑提示词。

images?

推荐的 JSON URL 图片参数。每一项一个图片 URL 对象。

image?string||

兼容字段:可传单个 URL、URL 数组或对象。推荐优先使用 images[].image_url

image_urls?array<string>

兼容字段:URL 字符串数组。推荐优先使用 images[].image_url

mask?string

可选。蒙版图片 URL,透明区域表示需要编辑的区域。

Formaturi
n?integer

生成图片数量。

Formatint32
Range1 <= value
size?string

输出图片尺寸。

Default"1024x1024"
quality?string

图片质量。具体可用值取决于上游模型。

response_format?string

返回格式。支持 urlb64_json;默认无需传此字段,不同上游通道支持情况可能不同。

Value in"url" | "b64_json"
background?string

背景填充方式。支持情况取决于模型。

Default"auto"
Value in"transparent" | "opaque" | "auto"
output_format?string

输出格式。具体可用值取决于上游模型。

output_compression?integer

输出压缩级别,仅适用于 jpegwebp

Default90
Formatint32
Range0 <= value <= 100
moderation?string

安全审核强度。支持情况取决于模型。

Default"auto"
Value in"auto" | "low"
watermark?boolean

是否添加水印。支持情况取决于上游通道。

Defaultfalse
user?string

终端用户标识,可用于滥用监控。

Response Body

application/json

模型选择表

模型 ID适用场景
doubao-seedream-4-0-250828参考图编辑、多图融合和图像重绘。
doubao-seedream-4-5-251128高质量参考图编辑、多图融合和高一致性改图。
doubao-seedream-5-0-260128高质量参考图编辑、多图融合和复杂视觉重绘。
doubao-seedream-5-0-lite-260128轻量编辑、低延迟改图和批量草图迭代。

通用参数

字段类型必选默认值说明
modelstringSeedream 编辑模型 ID。
promptstring编辑指令。建议明确指定保留区域、修改区域和目标风格。
imagestring 或 string[]原图/参考图 URL 或 Base64。最多建议 14 张。
sizestring1920x1920编辑输出尺寸,优先使用 <宽>x<高>,总像素不得小于 3686400
response_formatstring返回格式,支持 urlb64_json。默认无需传。
watermarkbooleantrue是否添加 AI 生成水印。
streambooleanfalse是否启用流式输出。Seedream 5.0 Lite 编辑未列出 stream

模型差异参数

字段适用模型默认值/范围差异说明
sizeSeedream 4.0 / 4.5 / 5.0 / 5.0 Lite默认 1920x1920优先使用 <宽>x<高>,总像素不得小于 3686400,实际可用性以渠道为准。
streamSeedream 4.0 / 4.5 / 5.0默认 falseSeedream 5.0 Lite 编辑未统一列出 stream,不要写入 Lite 编辑示例。

示例代码

curl https://api.routescope.ai/v1/images/edits \
  -H "Authorization: Bearer $ROUTESCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5-0-260128",
    "prompt": "保留主体建筑,把场景改成赛博朋克夜景,带霓虹灯和高细节",
    "image": "https://example.com/building.png",
    "size": "1920x1920"
  }'
import requests

response = requests.post(
    "https://api.routescope.ai/v1/images/edits",
    headers={"Authorization": "Bearer YOUR_ROUTESCOPE_API_KEY"},
    json={
        "model": "doubao-seedream-5-0-260128",
        "prompt": "保留主体建筑,把场景改成赛博朋克夜景,带霓虹灯和高细节",
        "image": "https://example.com/building.png",
        "size": "1920x1920",
    },
)
print(response.json())
const response = await fetch("https://api.routescope.ai/v1/images/edits", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ROUTESCOPE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "doubao-seedream-5-0-260128",
    prompt: "保留主体建筑,把场景改成赛博朋克夜景,带霓虹灯和高细节",
    image: "https://example.com/building.png",
    size: "1920x1920",
  }),
});
console.log(await response.json());

响应示例

{
  "created": 1777432320,
  "data": [
    {
      "url": "https://api.routescope.ai/assets/images/seedream-5-0-edit.png",
      "b64_json": null,
      "revised_prompt": "保留主体建筑,赛博朋克夜景风格,霓虹灯,高细节。"
    }
  ]
}

注意事项

  • 计费倍率按 Routescope 后台模型倍率与渠道倍率配置执行。
  • Lite 版本更适合轻量编辑,复杂一致性编辑建议使用非 Lite 版本。
  • 高分辨率编辑耗时比标准文生图更长。

最后更新于