> ## 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 4.0

> 通过 AnyFast 调用 Seedream 4.0，支持文生图、图生图和连续图片生成。

Seedream 4.0 通过同一个同步接口完成文生图和图生图。AnyFast 模型 ID 为 `doubao-seedream-4-0-250828`。

| 能力  | 输入         | 输出           |
| --- | ---------- | ------------ |
| 文生图 | 文本提示词      | 一张或多张图片      |
| 图生图 | 文本提示词和参考图片 | 编辑、参考生成或连续图片 |

<Note>
  接口会在生成完成后直接返回图片列表，不会返回需要轮询的任务 ID。
</Note>

## 能力示例

<Tabs sync={false}>
  <Tab title="文生图">
    只传 `prompt` 即可从文本创建图片；使用 `size`、`seed` 和水印参数控制输出。
  </Tab>

  <Tab title="图生图">
    在请求中增加 `image` 数组。每项可使用公网图片 URL 或 Base64 data URI；提示词描述要保留、修改或组合的内容。

    <Warning>
      使用外部图片 URL 时，请确保上游可在 10 秒内下载图片。较大文件建议使用 Base64 data URI。
    </Warning>
  </Tab>
</Tabs>

## 调用示例

<Tabs sync={false}>
  <Tab title="文生图">
    <CodeGroup>
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-4-0-250828",
          "prompt": "日出时分宁静的山景，山谷间弥漫着薄雾",
          "size": "2048x2048",
          "watermark": false
        }'
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://www.anyfast.com.cn/v1/images/generations",
          headers={"Authorization": "Bearer YOUR_API_KEY"},
          json={
              "model": "doubao-seedream-4-0-250828",
              "prompt": "日出时分宁静的山景，山谷间弥漫着薄雾",
              "size": "2048x2048",
              "watermark": False,
          },
      )
      response.raise_for_status()
      print(response.json()["data"][0]["url"])
      ```
    </CodeGroup>
  </Tab>

  <Tab title="图生图">
    <CodeGroup>
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.com.cn/v1/images/generations \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "doubao-seedream-4-0-250828",
          "prompt": "结合两张参考图生成三张连贯的游乐园电影分镜",
          "image": [
            "https://example.com/reference-1.png",
            "https://example.com/reference-2.png"
          ],
          "sequential_image_generation": "auto",
          "sequential_image_generation_options": {"max_images": 3},
          "size": "2048x2048",
          "watermark": false
        }'
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://www.anyfast.com.cn/v1/images/generations",
          headers={"Authorization": "Bearer YOUR_API_KEY"},
          json={
              "model": "doubao-seedream-4-0-250828",
              "prompt": "结合两张参考图生成三张连贯的游乐园电影分镜",
              "image": [
                  "https://example.com/reference-1.png",
                  "https://example.com/reference-2.png",
              ],
              "sequential_image_generation": "auto",
              "sequential_image_generation_options": {"max_images": 3},
              "size": "2048x2048",
              "watermark": False,
          },
      )
      response.raise_for_status()
      print([item["url"] for item in response.json()["data"]])
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## 参数与输出

| 参数                                               | 文生图 | 图生图 | 说明                               |
| ------------------------------------------------ | --- | --- | -------------------------------- |
| `model`                                          | 必填  | 必填  | 固定为 `doubao-seedream-4-0-250828` |
| `prompt`                                         | 必填  | 必填  | 图片生成或编辑提示词                       |
| `image`                                          | 不传  | 必填  | 参考图片 URL 或 Base64 data URI 数组    |
| `sequential_image_generation`                    | 可选  | 可选  | `auto` 开启连续图片生成                  |
| `sequential_image_generation_options.max_images` | 可选  | 可选  | 连续生成的最大图片数量                      |
| `size`                                           | 可选  | 可选  | 输出图片尺寸                           |
| `watermark`                                      | 可选  | 可选  | 是否添加水印，默认 `false`                |
| `seed`                                           | 可选  | 可选  | 随机种子                             |
| `logo_info`                                      | 可选  | 可选  | 自定义 Logo 水印配置                    |

支持的明确像素尺寸为：`1024x1024`、`864x1152`、`1152x864`、`1312x736`、`736x1312`、`832x1248`、`1248x832`、`1568x672`、`2048x2048`、`1728x2304`、`2304x1728`、`2848x1600`、`1600x2848`、`2496x1664`、`1664x2496`、`3136x1344`、`4096x4096`、`3520x4704`、`4704x3520`、`5504x3040`、`3040x5504`、`3328x4992`、`4992x3328` 和 `6240x2656`。

成功响应中的 `data` 是生成图片列表，每项包含 `url` 和 `size`；`usage` 返回生成数量与 Token 用量。

<Card title="API 参考" icon="code" href="/api-reference/model-api/bytedance/doubao-seedream-4-0-250828">
  查看 Seedream 4.0 文生图和图生图的完整字段与响应。
</Card>

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