> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.com.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# seedream-5.0-pro

> Seedream 5.0 Pro 图片生成、编辑、透明背景和图层拆分 API。

使用 `doubao-seedream-5-0-pro-260628` 调用同步图片生成接口。请切换能力 Tab 查看对应的请求和响应结构。

<Warning>该模型不支持组图生成、联网搜索和流式输出。请勿传入 `sequential_image_generation`、`sequential_image_generation_options`、`tools` 或 `stream`。</Warning>

<Tabs>
  <Tab title="文生图">
    ## 创建图片

    `POST /v1/images/generations`

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-5-0-pro-260628",
          "prompt": "一只白色陶瓷杯放在浅灰色背景上，居中构图，柔和阴影，产品摄影，无文字",
          "size": "1.5K",
          "response_format": "url",
          "output_format": "jpeg",
          "watermark": false,
          "optimize_prompt_options": { "mode": "fast" }
        }'
      ```
    </div>

    <ParamField body="model" type="string" required>固定为 `doubao-seedream-5-0-pro-260628`。</ParamField>
    <ParamField body="prompt" type="string" required>图片生成提示词。中文建议不超过 300 字，英文建议不超过 600 词。</ParamField>
    <ParamField body="size" type="string" default="2K">`1K`、`1.5K`、`2K` 或合法的 `宽x高`。自定义尺寸总像素数须在 921,600–4,624,220，宽高比须在 `[1/16, 16]`。</ParamField>
    <ParamField body="response_format" type="string" default="url">`url` 或 `b64_json`。URL 有效期为 24 小时。</ParamField>
    <ParamField body="output_format" type="string" default="jpeg">`jpeg` 或 `png`。</ParamField>
    <ParamField body="watermark" type="boolean" default={true}>是否添加“AI 生成”水印。</ParamField>
    <ParamField body="optimize_prompt_options" type="object">提示词优化配置。</ParamField>
    <ParamField body="optimize_prompt_options.mode" type="string" default="standard">`standard` 或 `fast`，两种模式均支持。</ParamField>

    ### 创建响应

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```json 200 theme={null}
      {
        "model": "doubao-seedream-5-0-pro-260628",
        "created": 1787562068,
        "data": [{
          "url": "https://example.com/generated-image.jpeg",
          "size": "1536x1536",
          "output_format": "jpeg"
        }],
        "usage": {
          "input_images": 0,
          "generated_images": 1,
          "output_tokens": 9216,
          "total_tokens": 9216
        }
      }
      ```
    </div>
  </Tab>

  <Tab title="图片编辑">
    ## 编辑或融合图片

    `POST /v1/images/generations`

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-5-0-pro-260628",
          "prompt": "使用图 1 的构图，并采用图 2 的视觉风格。",
          "image": [
            "https://example.com/composition.png",
            "https://example.com/style.png"
          ],
          "size": "1K",
          "response_format": "url",
          "output_format": "jpeg",
          "watermark": false
        }'
      ```
    </div>

    <ParamField body="model" type="string" required>固定为 `doubao-seedream-5-0-pro-260628`。</ParamField>
    <ParamField body="prompt" type="string" required>编辑或参考生成指令。坐标编辑可使用归一化 `<point>` 和 `<bbox>` 标签。</ParamField>
    <ParamField body="image" type="string | string[]" required>图片 URL、Base64 Data URI，或最多 10 张参考图组成的数组。</ParamField>
    <ParamField body="size" type="string" default="2K">`1K`、`1.5K`、`2K` 或合法的自定义像素尺寸。</ParamField>
    <ParamField body="response_format" type="string" default="url">`url` 或 `b64_json`。</ParamField>
    <ParamField body="output_format" type="string" default="jpeg">`jpeg` 或 `png`。</ParamField>
    <ParamField body="watermark" type="boolean" default={true}>是否添加“AI 生成”水印。</ParamField>
    <ParamField body="optimize_prompt_options.mode" type="string" default="standard">`standard` 或 `fast`。</ParamField>

    ### 创建响应

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```json 200 theme={null}
      {
        "model": "doubao-seedream-5-0-pro-260628",
        "created": 1787562132,
        "data": [{
          "url": "https://example.com/fused-image.jpeg",
          "size": "1024x1024",
          "output_format": "jpeg"
        }],
        "usage": {
          "input_images": 2,
          "generated_images": 1,
          "output_tokens": 4096,
          "total_tokens": 4096
        }
      }
      ```
    </div>

    <Note>普通参考图支持 jpeg、png、webp、bmp、tiff、gif、heic 和 heif。单张图片小于 30 MB，宽高比在 `[1/16, 16]`，宽和高均大于 14 px，总像素数不超过 36,000,000。</Note>
  </Tab>

  <Tab title="透明背景">
    ## 保留透明通道

    `POST /v1/images/generations`

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-5-0-pro-260628",
          "prompt": "保留主体并优化边缘，同时保持透明背景。",
          "image": "https://example.com/transparent-source.png",
          "background": "transparent",
          "size": "1K",
          "response_format": "url",
          "output_format": "png",
          "watermark": false
        }'
      ```
    </div>

    <ParamField body="model" type="string" required>固定为 `doubao-seedream-5-0-pro-260628`。</ParamField>
    <ParamField body="prompt" type="string" required>图片编辑指令。</ParamField>
    <ParamField body="image" type="string" required>仅允许 1 张带 Alpha 通道的输入图。PNG 支持透明通道，JPEG 不支持。</ParamField>
    <ParamField body="background" type="string" default="opaque">`transparent` 表示保留透明背景，`opaque` 表示生成普通不透明背景。</ParamField>
    <ParamField body="size" type="string" default="2K">`1K`、`1.5K`、`2K` 或合法的自定义像素尺寸。</ParamField>
    <ParamField body="output_format" type="string" required>`background` 为 `transparent` 时必须使用 `png`。</ParamField>
    <ParamField body="response_format" type="string" default="url">`url` 或 `b64_json`。</ParamField>
    <ParamField body="watermark" type="boolean" default={true}>是否添加“AI 生成”水印。</ParamField>

    ### 创建响应

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```json 200 theme={null}
      {
        "model": "doubao-seedream-5-0-pro-260628",
        "created": 1787562204,
        "data": [{
          "url": "https://example.com/transparent-result.png",
          "size": "1024x1024",
          "output_format": "png"
        }],
        "usage": {
          "input_images": 1,
          "generated_images": 1,
          "output_tokens": 4096,
          "total_tokens": 4096
        }
      }
      ```
    </div>
  </Tab>

  <Tab title="图层拆分">
    ## 拆分图片图层

    `POST /v1/images/generations`

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer <token>' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-5-0-pro-260628",
          "prompt": "仅将鹦鹉主体与背景分离为一个可编辑图层。",
          "image": "https://example.com/parrot-poster.png",
          "layer_decomposition": true,
          "size": "2K",
          "response_format": "url",
          "output_format": "jpeg",
          "watermark": false
        }'
      ```
    </div>

    <ParamField body="model" type="string" required>固定为 `doubao-seedream-5-0-pro-260628`。</ParamField>
    <ParamField body="prompt" type="string">可选的拆层指令，可使用归一化 `<bbox>` 坐标指定元素。</ParamField>
    <ParamField body="image" type="string" required>仅允许 1 张 PNG 或 JPEG。</ParamField>
    <ParamField body="layer_decomposition" type="boolean" required>设为 `true`，返回 1 张底图和最多 16 个可编辑图层。</ParamField>
    <ParamField body="size" type="string" default="auto">`auto`、`1K`、`1.5K` 或 `2K`；该模式不支持自定义像素尺寸。</ParamField>
    <ParamField body="response_format" type="string" default="url">`url` 或 `b64_json`。</ParamField>
    <ParamField body="output_format" type="string" default="jpeg">仅控制底图格式；拆出的图层始终为 PNG。</ParamField>
    <ParamField body="watermark" type="boolean" default={true}>是否添加“AI 生成”水印。</ParamField>

    ### 创建响应

    <div className="kling-api-example-panel seedream-api-example-panel">
      ```json 200 theme={null}
      {
        "model": "doubao-seedream-5-0-pro-260628",
        "created": 1787562257,
        "data": [
          {
            "url": "https://example.com/background.jpeg",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
          },
          {
            "url": "https://example.com/parrot-layer.png",
            "size": "892x2179",
            "output_format": "png",
            "z_index": 1,
            "bounding_box": {
              "absolute": [730, 627, 1301, 2021],
              "normalized": [356, 306, 635, 986]
            },
            "name": "鹦鹉主体",
            "description": "从原图中拆出的透明背景鹦鹉主体"
          }
        ],
        "usage": {
          "input_images": 1,
          "generated_images": 2,
          "output_tokens": 33768,
          "total_tokens": 33768
        }
      }
      ```
    </div>

    <Note>拆层输入图总像素数须在 512 × 512 到 6000 × 6000 之间，宽高比须在 `[1/16, 16]`，文件小于 30 MB。任一目标图层失败时，整个请求失败。</Note>
  </Tab>
</Tabs>

## 请求头

<ParamField header="Authorization" type="string" required>Bearer 鉴权，格式为 `Bearer <token>`。</ParamField>
<ParamField header="Content-Type" type="string" default="application/json" required>请求体格式。</ParamField>

## 响应字段

<ResponseField name="model" type="string">实际使用的模型。响应可能返回上游规范化后的模型名称。</ResponseField>
<ResponseField name="created" type="integer">Unix 秒级创建时间戳。</ResponseField>
<ResponseField name="data" type="object[]">生成图片；拆层模式下为底图和拆出的图层。</ResponseField>
<ResponseField name="data[].url" type="string">`response_format` 为 `url` 时返回的临时图片链接。</ResponseField>
<ResponseField name="data[].b64_json" type="string">`response_format` 为 `b64_json` 时返回的 Base64 图片数据。</ResponseField>
<ResponseField name="data[].output_format" type="string">输出图片格式。</ResponseField>
<ResponseField name="data[].size" type="string">输出图片尺寸。</ResponseField>
<ResponseField name="data[].z_index" type="integer">拆层模式下的图层顺序，底图为 `0`。</ResponseField>
<ResponseField name="data[].name" type="string">拆层模式下模型生成的图层名称。</ResponseField>
<ResponseField name="data[].description" type="string">拆层模式下模型生成的图层描述。</ResponseField>
<ResponseField name="data[].bounding_box.absolute" type="integer[]">图层在输出底图中的 `[left, top, right, bottom]` 像素坐标。</ResponseField>
<ResponseField name="data[].bounding_box.normalized" type="integer[]">图层边界映射到 1000 × 1000 坐标系后的坐标。</ResponseField>
<ResponseField name="usage.generated_images" type="integer">生成结果数；拆层模式下包含底图和所有图层。</ResponseField>
<ResponseField name="usage.input_images" type="integer">输入图片数。</ResponseField>
<ResponseField name="usage.output_tokens" type="integer">输出 Token 数。</ResponseField>
<ResponseField name="usage.total_tokens" type="integer">总 Token 数。</ResponseField>
<ResponseField name="error" type="object">请求级错误信息。</ResponseField>
<ResponseField name="error.code" type="string">请求级错误码。</ResponseField>
<ResponseField name="error.message" type="string">请求级错误说明。</ResponseField>

## 错误响应

<div className="kling-api-example-panel seedream-api-example-panel">
  <Tabs>
    <Tab title="400">
      请求参数非法，或当前模型不支持传入的参数。

      ```json theme={null}
      {
        "error": {
          "message": "The parameter is not supported by the current model.",
          "type": "BadRequest",
          "param": "sequential_image_generation",
          "code": "InvalidParameter"
        }
      }
      ```
    </Tab>

    <Tab title="401">
      API Key 缺失或无效。

      ```json theme={null}
      {
        "error": {
          "code": "unauthorized",
          "message": "Invalid API key"
        }
      }
      ```
    </Tab>

    <Tab title="429">
      请求超过当前限流。

      ```json theme={null}
      {
        "error": {
          "code": "rate_limit_exceeded",
          "message": "Rate limit exceeded"
        }
      }
      ```
    </Tab>
  </Tabs>
</div>

<script src="/public/feedback.js" />
