Tokaify APITokaify API
API 参考
AI 模型接口图像doubao接口doubao-seedream-4-0-250828

图像编辑

doubao-seedream-4-0-250828 图像编辑接口

Seedream 4.0 的图像编辑通过 /v1/images/edits 接口完成,参考图通过 JSON 请求体中的 image 字段传入,不走 OpenAI 式文件上传协议。

POST
/v1/images/edits

Authorization

BearerAuth

AuthorizationBearer <token>

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

In: header

Request Body

multipart/form-data

model*string

图像编辑模型名称。

Default"doubao-seedream-4-0-250828"
prompt*string

编辑提示词。

image*file

必填。要编辑的原图文件。当前上游要求文件上传,不支持用 JSON 直接传图片 URL。

Formatbinary
mask?file

可选。遮罩图片文件,透明区域表示需要编辑的区域。

Formatbinary
n?integer

生成图片数量。

Formatint32
Range1 <= value
size?string

输出图片尺寸。请使用明确的 <宽>x<高>,例如 1920x1920;总像素不得小于 3686400,实际可用值取决于模型和上游通道。

Default"1920x1920"
quality?string

图片质量。实际可选值取决于模型和上游通道。

Default"auto"
Value in"auto" | "standard" | "hd" | "low" | "medium" | "high"
response_format?string

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

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

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

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

输出图片格式。支持情况取决于模型。

Default"png"
Value in"png" | "jpeg" | "webp"
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

curl -X POST "https://api.tokaify.com/v1/images/edits" \  -F model="doubao-seedream-4-0-250828" \  -F prompt="把图片改成水彩插画风格,保留主体构图。" \  -F image="@/path/to/image.jpg" \  -F n="1" \  -F size="1920x1920" \  -F quality="auto" \  -F background="auto" \  -F output_format="png" \  -F output_compression="90" \  -F moderation="auto" \  -F watermark="false" \  -F user="user-123"
{
  "created": 1,
  "data": {}
}

请求参数

字段类型必选默认值描述
modelstring固定为 doubao-seedream-4-0-250828
promptstring编辑指令,例如替换背景、保持主体、改变风格或融合多张参考图。
imagestring 或 string[]原图/参考图 URL 或 Base64;多图融合最多建议 14 张。
sizestring1920x1920请优先使用明确的 <宽>x<高>,例如 1920x1920;总像素不得小于 3686400
response_formatstring不传支持 urlb64_json;默认无需传此字段。
watermarkbooleantrue是否添加 AI 生成水印。
streambooleanfalse是否开启流式输出。

示例代码

curl https://api.tokaify.com/v1/images/edits \
  -H "Authorization: Bearer $TOKAIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-4-0-250828",
    "prompt": "保留人物主体,将背景改成未来感办公室,写实摄影风格",
    "image": "https://example.com/input.png",
    "size": "1920x1920"
  }'
import requests

response = requests.post(
    "https://api.tokaify.com/v1/images/edits",
    headers={"Authorization": "Bearer YOUR_TOKAIFY_API_KEY"},
    json={
        "model": "doubao-seedream-4-0-250828",
        "prompt": "保留人物主体,将背景改成未来感办公室,写实摄影风格",
        "image": "https://example.com/input.png",
        "size": "1920x1920",
    },
)
print(response.json())
const response = await fetch("https://api.tokaify.com/v1/images/edits", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.TOKAIFY_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "doubao-seedream-4-0-250828",
    prompt: "保留人物主体,将背景改成未来感办公室,写实摄影风格",
    image: "https://example.com/input.png",
    size: "1920x1920",
  }),
});
console.log(await response.json());

响应示例

{
  "created": 1777432320,
  "data": [
    {
      "url": "https://api.tokaify.com/assets/images/seedream-edit.png",
      "b64_json": null,
      "revised_prompt": "保留人物主体,未来感办公室背景,写实摄影风格"
    }
  ]
}

业务提示

计费倍率按后台模型倍率与渠道倍率配置执行。参考图数量越多、尺寸越高,延迟和费用越高。

这篇文档对您有帮助吗?

最后更新于