Skip to content

Seedream 图像生成 ​

使用本接口输入文本描述或参考图片生成图像,支持文生图、单图生图、多图生图与组图生成;其中 Seedream 5.0 pro 还支持图层拆分与交互编辑能力。

接口地址 ​

http
POST /v1/images/generations

认证 ​

方式说明
Bearer Token在请求头中携带 Authorization: Bearer <API_key> 用于验证账户信息。

请求头 ​

参数名类型必填说明
Content-Typestring是请求体的媒介类型,请设置为 application/json
Authorizationstring是Bearer API_key,用于验证账户信息

模型能力 ​

  • Seedream 5.0 pro(doubao-seedream-5-0-pro-260628):支持图层拆分(将单张图拆解为 1 张底图 + 最多 16 个可独立编辑的图层)、交互编辑(通过坐标、框选、箭头等指定编辑位置);仅支持生成单图(不支持 sequential_image_generation),暂不支持组图、联网搜索与流式输出
  • Seedream 5.0 lite(doubao-seedream-5-0-260128):支持组图生成(sequential_image_generation 为 auto 时,文生组图最多 15 张、单图生组图最多 14 张)、多图生图、单图生图与文生图;disabled 时仅生成单图

请求体 ​

参数名类型必填默认值说明
modelstring是-模型 ID,取值见下方"支持模型 ID"
promptstring是-提示词,用于生成图像或指定图层拆分意图;中文建议不超过 300 字,英文不超过 600 词
imagestring / string[]否-参考图片,支持 URL 或 Base64(data:image/<格式>;base64,<编码>,格式需小写);单张要求见下方说明
sizestring否-图像尺寸,各模型支持的档位与像素范围不同,详情见下方"尺寸说明"
layer_decompositionboolean否false图层拆分开关:true 开启图层拆分模式(仅 Seedream 5.0 pro,此时 image 必填且仅支持单张)
optimize_prompt_optionsobject否-提示词优化配置,详情见下方子表格
output_formatstring否jpeg输出图片格式,取值 png / jpeg;图层拆分场景下仅控制底图格式,图层始终为 png
backgroundstring否opaque图片透明通道:transparent(透明背景)/ opaque(不透明)。仅 Seedream 5.0 pro,且仅支持图生图、输入 1 张带透明通道的图片
response_formatstring否url返回格式:url(图片下载链接,24 小时内有效)/ b64_json(Base64 编码)
sequential_image_generationstring否disabled组图模式:auto(自动判断是否返回组图)/ disabled(关闭组图,仅生成一张)。仅 Seedream 5.0 lite
sequential_image_generation_optionsobject否-组图配置,仅 sequential_image_generation 为 auto 时生效,详情见下方子表格
streamboolean否false流式输出开关:true 时逐张返回生成的图片。仅 Seedream 5.0 lite 支持
toolsobject[]否-工具配置(仅 Seedream 5.0 lite),如开启联网搜索,详情见下方子表格
watermarkboolean否true水印开关:false 不添加水印,true 在图片右下角添加"AI 生成"水印

optimize_prompt_options 详细参数 ​

参数名类型必填默认值说明
optimize_prompt_options.modestring否standard提示词优化模式:standard(质量更高、耗时较长);fast(更快、效果略低,Seedream 5.0 lite 不支持)

sequential_image_generation_options 详细参数 ​

参数名类型必填默认值说明
sequential_image_generation_options.max_imagesinteger否15本次请求最多生成的图片数量,取值范围 [1, 15];实际数量还受参考图数影响(输入的参考图数 + 最终生成的图片数 ≤ 15)

tools 详细参数 ​

参数名类型必填说明
tools[].typestring是工具类型:web_search(联网搜索)。开启后模型根据提示词自主判断是否搜索互联网内容,搜索次数可通过 usage.tool_usage.web_search 查询

image 参数说明 ​

  • 图片生成场景:Seedream 5.0 pro 最多支持 10 张参考图;Seedream 5.0 lite 最多支持 14 张
  • 单张图片要求:格式 jpeg / png / webp / bmp / tiff / gif / heic / heif;宽高比 [1/16, 16];边长 > 14px;大小不超过 30MB;总像素 [196, 6000×6000]
  • 图层拆分场景:image 为必选,仅支持单张,格式为 png / jpeg,总像素 [512×512, 6000×6000]

尺寸说明(size) ​

各模型支持两种配置方式(不可混用):方式 1 指定分辨率档位(模型结合 prompt 判断宽高比),方式 2 直接指定宽高像素值(宽x高)。

模型方式 1 可选值(默认)方式 2 约束
Seedream 5.0 pro(图片生成)1K / 1.5K / 2K(默认 2K,1.5K 与 1K 价格相同且效果更优)总像素 [1280x720, 2048x2048x1.1025],宽高比 [1/16, 16]
Seedream 5.0 pro(图层拆分)1K / 1.5K / 2K / auto(默认 auto,按输入图尺寸输出;底图与各图层按原图宽高比输出)不支持方式 2
Seedream 5.0 lite2K / 3K / 4K(无默认值)默认 2048x2048,总像素 [2560x1440, 4096x4096],宽高比 [1/16, 16]

Seedream 5.0 pro(图片生成场景)分辨率档位对应的宽高像素参考值:

分辨率宽高比宽高像素值
1K1:11024x1024
1K4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3 / 21:91152x864 / 864x1152 / 1424x800 / 800x1424 / 1248x832 / 832x1248 / 1568x672
1.5K1:11536x1536
1.5K4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3 / 21:91792x1344 / 1344x1792 / 2048x1152 / 1152x2048 / 1872x1248 / 1248x1872 / 2352x1008
2K1:12048x2048
2K4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3 / 21:92368x1776 / 1776x2368 / 2816x1584 / 1584x2816 / 2496x1664 / 1664x2496 / 3136x1344

请求示例 ​

文生图 ​

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "prompt": "一只可爱的橘猫,戴着圆框眼镜,坐在窗台边看报纸,午后阳光洒落",
         "size": "2K",
         "response_format": "b64_json",
         "watermark": true
     }'
python
import base64
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "prompt": "一只可爱的橘猫,戴着圆框眼镜,坐在窗台边看报纸,午后阳光洒落",
    "size": "2K",
    "response_format": "b64_json",
    "watermark": True,
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
data = resp.json()

# 提取返回图像并保存
for item in data["data"]:
    image = item["b64_json"]
    with open("output.png", "wb") as f:
        f.write(base64.b64decode(image))

图生图(多图生图) ​

在 image 中传入参考图片(可多张),结合文本提示词生成图像。

Base64 编码说明: image 支持 Base64 编码,格式为 data:image/png;base64,<Base64 编码>,编码参考脚本如下:

bash
#!/usr/bin/env bash
set -euo pipefail
IMAGE_PATH="./input.png"

if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
    B64FLAGS="--input"
else
    B64FLAGS="-w0"
fi
echo -n "data:image/png;base64," > base64.txt
base64 $B64FLAGS "$IMAGE_PATH" >> base64.txt
bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "prompt": "将参考图中的猫放在海边日落的场景中,保持写实风格",
         "image": [
             "https://example.com/reference-cat.png",
             "data:image/png;base64,<Base64 Code>"
         ],
         "size": "2K"
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "prompt": "将参考图中的猫放在海边日落的场景中,保持写实风格",
    "image": [
        "https://example.com/reference-cat.png",
        "data:image/png;base64,<Base64 Code>",
    ],
    "size": "2K",
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
result = resp.json()
print(result)

多图融合 ​

输入多张参考图片,模型将多张图中的元素按提示词要求融合到一张图中(如图1人物与图2服饰的换装融合)。

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "doubao-seedream-5-0-pro-260628",
         "prompt": "将图1的服装换为图2的服装",
         "image": [
             "https://example.com/figure-1.png",
             "https://example.com/outfit-2.png"
         ],
         "size": "2K",
         "output_format": "png",
         "watermark": false
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "将图1的服装换为图2的服装",
    "image": [
        "https://example.com/figure-1.png",
        "https://example.com/outfit-2.png",
    ],
    "size": "2K",
    "output_format": "png",
    "watermark": False,
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
result = resp.json()
print(result["data"][0]["url"])

图层拆分(Layer Decomposition) ​

开启 layer_decomposition 后,模型将输入图拆解为 1 张底图 + 最多 16 个可独立编辑的图层(均带透明通道)。prompt 中可通过 <bbox>left top right bottom</bbox> 指定需要拆分元素的坐标位置。

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "doubao-seedream-5-0-pro-260628",
         "prompt": "将图片进行精确图层分离,需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>178 714 826 810</bbox>;鹦鹉的坐标为<bbox>347 305 642 997</bbox>。",
         "image": "https://example.com/input.png",
         "layer_decomposition": true,
         "size": "2K",
         "output_format": "jpeg",
         "response_format": "url",
         "watermark": true
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "将图片进行精确图层分离,需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>178 714 826 810</bbox>;鹦鹉的坐标为<bbox>347 305 642 997</bbox>。",
    "image": "https://example.com/input.png",
    "layer_decomposition": True,
    "size": "2K",
    "output_format": "jpeg",
    "response_format": "url",
    "watermark": True,
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
result = resp.json()

# 底图 z_index 固定为 0,图层从 1 开始递增
for item in result["data"]:
    print(item["z_index"], item.get("name"), item["size"])

交互编辑 ​

输入带手绘草图/标记区域的参考图与编辑指令文本,模型基于标记区域执行精准编辑(如添加、替换、移除局部元素)。

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "doubao-seedream-5-0-pro-260628",
         "prompt": "根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册,并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。",
         "image": "https://example.com/sketch.png",
         "size": "2K",
         "output_format": "png",
         "response_format": "url",
         "watermark": false
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册,并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。",
    "image": "https://example.com/sketch.png",
    "size": "2K",
    "output_format": "png",
    "response_format": "url",
    "watermark": False,
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
result = resp.json()
print(result["data"][0]["url"])

组图生成(多参考图生组图) ​

sequential_image_generation 为 auto 时开启组图模式,模型根据提示词与参考图自主判断生成一组内容关联的图片(输入的参考图数量 + 最终生成的图片数量 ≤ 15 张)。

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "doubao-seedream-5-0-260128",
         "prompt": "生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片,涵盖早晨、中午、晚上",
         "image": [
             "https://example.com/reference-girl.png",
             "https://example.com/reference-cow.png"
         ],
         "sequential_image_generation": "auto",
         "sequential_image_generation_options": {
             "max_images": 3
         },
         "size": "2K",
         "output_format": "png",
         "watermark": false
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "doubao-seedream-5-0-260128",
    "prompt": "生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片,涵盖早晨、中午、晚上",
    "image": [
        "https://example.com/reference-girl.png",
        "https://example.com/reference-cow.png",
    ],
    "sequential_image_generation": "auto",
    "sequential_image_generation_options": {"max_images": 3},
    "size": "2K",
    "output_format": "png",
    "watermark": False,
}

resp = requests.post(url, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
result = resp.json()

# 遍历输出每张图片的 URL 与尺寸
for item in result["data"]:
    print(item["url"], item["size"])

支持模型 ID ​

  • doubao-seedream-5-0-pro-260628 —— 支持图层拆分(最多 16 个图层)、交互编辑、多图生图(最多 10 张参考图)
  • doubao-seedream-5-0-260128 —— 支持组图生成、多图/单图生图(最多 14 张参考图)、联网搜索与流式输出

<Model ID> 需替换为具体模型 ID,具体可用模型、分辨率与参考图数量以平台实际为准。

响应体 ​

参数名类型说明
createdinteger本次请求创建时间的 Unix 时间戳(秒)
modelstring本次请求使用的模型 ID
dataobject[]输出图像的信息列表;url、b64_json、size 为公共字段,其余字段因场景而异
data.urlstring图片下载链接,response_format 为 url 时返回,24 小时内有效
data.b64_jsonstring图片 Base64 数据,response_format 为 b64_json 时返回
data.sizestring图像宽高像素值,格式 宽x高,如 2048x2048
data.output_formatstring输出图片格式,png 或 jpeg
data.z_indexinteger图层叠放顺序索引,底图固定为 0,图层从 1 开始递增(图层拆分场景)
data.namestring图层拆分元素的名称/标签(图层拆分场景)
data.descriptionstring图层拆分元素的详细描述(图层拆分场景)
data.bounding_boxobject图层在底图坐标系中的边界框信息(图层拆分场景)
data.bounding_box.absolutearray绝对像素坐标 [left, top, right, bottom],底图左上角为 (0, 0)
data.bounding_box.normalizedarray归一化坐标 [left, top, right, bottom],取值区间 [0, 1000]
data.errorobject组图中单张图片生成失败时的错误信息(code、message),不影响其他图片
errorobject顶层错误信息(code、message),整个请求未能生成任何图片时返回
usageobject用量信息
usage.generated_imagesinteger成功生成的图片张数,仅对成功生成的图片计费
usage.input_imagesinteger输入模型的图片张数
usage.output_tokensinteger生成图片花费的 token 数量,计算逻辑为 sum(图片长 * 图片宽) / 256 后向下取整
usage.total_tokensinteger本次请求消耗的总 token 数,当前不计算输入 token,与 output_tokens 值一致
usage.tool_usageobject工具用量信息
usage.tool_usage.web_searchinteger联网搜索次数,为 0 表示未搜索

响应示例 ​

以下响应示例以 response_format 为 url 为例,展示文生图 / 图生图、多图融合、图层拆分、交互编辑与组图生成的典型输出结构(b64_json 场景下 data.url 对应替换为 data.b64_json)。

图层拆分场景说明: 底图 z_index 固定为 0、不返回 bounding_box;每个图层返回 z_index、name、description 与 bounding_box,可依据 bounding_box.absolute / normalized 将图层还原到底图或自定义画布中。

组图生成场景说明: 组图模式下 data 中返回多张图片;若单张生成失败,该张额外返回 error 字段(code、message),不影响其他图片。

json
{
  "created": 1722769557,
  "model": "<Model ID>",
  "data": [
    {
      "url": "https://.../image_1.png",
      "size": "2048x2048",
      "output_format": "png"
    }
  ],
  "usage": {
    "generated_images": 1,
    "output_tokens": 16384,
    "total_tokens": 16384
  }
}
json
{
  "model": "doubao-seedream-5-0-pro-260628",
  "created": 1757323224,
  "data": [
    {
      "url": "https://.../fused.png",
      "size": "1760x2368"
    }
  ],
  "usage": {
    "generated_images": 1,
    "output_tokens": 16280,
    "total_tokens": 16280
  }
}
json
{
  "model": "doubao-seedream-5-0-pro-260628",
  "created": 1784696685,
  "data": [
    {
      "url": "https://.../base.png",
      "size": "2048x2048",
      "output_format": "jpeg",
      "z_index": 0
    },
    {
      "url": "https://.../layer_title.png",
      "size": "1273x265",
      "output_format": "png",
      "z_index": 1,
      "bounding_box": {
        "absolute": [383, 120, 1655, 384],
        "normalized": [187, 59, 808, 188]
      },
      "name": "Seedream标题文字",
      "description": "黄色大号衬线字体的Seedream标题文字"
    }
  ],
  "usage": {
    "input_images": 1,
    "generated_images": 8,
    "output_tokens": 23107,
    "total_tokens": 23107
  }
}
json
{
  "model": "doubao-seedream-5-0-pro-260628",
  "created": 1757323224,
  "data": [
    {
      "url": "https://.../edited.png",
      "size": "2048x2048"
    }
  ],
  "usage": {
    "generated_images": 1,
    "output_tokens": 18000,
    "total_tokens": 18000
  }
}
json
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://.../image_1.png",
      "size": "2720x1536"
    },
    {
      "url": "https://.../image_2.png",
      "size": "2720x1536"
    },
    {
      "url": "https://.../image_3.png",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}

说明:

  • url 返回的图片链接在生成后 24 小时内失效,请及时下载保存。
  • 若 response_format 为 b64_json,生成的图像为 Base64 编码,需在客户端解码后保存使用。