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

# 豆包图片生成 API

> 使用 doubao-seedream 模型生成高质量图片

## 支持的模型

<CardGroup cols={2}>
  <Card title="doubao-seedream-4-0-250828" icon="image">
    基础版图片生成模型
  </Card>

  <Card title="doubao-seedream-4-5-251128" icon="sparkles">
    增强版图片生成模型
  </Card>

  <Card title="doubao-seedream-5-0-260128" icon="stars">
    最新图像创作模型,精准解析复杂指令
  </Card>
</CardGroup>

## 文生图

通过文本描述生成图片。

<Note>
  **配置说明：**

  * 将 `api.xxx.com` 替换为您的实际 API 域名
  * 将 `sk-xxx` 替换为您的 API 密钥（可在控制台获取）
</Note>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.xxx.com/v1/images/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-xxx" \
    -d '{
      "model": "doubao-seedream-4-0-250828",
      "prompt": "星际穿越,黑洞,黑洞里冲出一辆快支离破碎的复古列车,抢视觉冲击力,电影大片,末日既视感,动感,对比色,oc渲染,光线追踪,动态模糊,景深,超现实主义,深蓝,画面通过细腻的丰富的色彩层次塑造主体与场景,质感真实,暗黑风背景的光影效果营造出氛围,整体兼具艺术幻想感,夸张的广角透视效果,耀光,反射,极致的光影,强引力,吞噬",
      "size": "2K",
      "sequential_image_generation": "disabled",
      "stream": false,
      "response_format": "url",
      "watermark": false
    }'
  ```

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

  url = "https://api.xxx.com/v1/images/generations"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer sk-xxx"
  }

  data = {
      "model": "doubao-seedream-4-0-250828",
      "prompt": "星际穿越,黑洞,黑洞里冲出一辆快支离破碎的复古列车,抢视觉冲击力,电影大片,末日既视感,动感,对比色,oc渲染,光线追踪,动态模糊,景深,超现实主义,深蓝,画面通过细腻的丰富的色彩层次塑造主体与场景,质感真实,暗黑风背景的光影效果营造出氛围,整体兼具艺术幻想感,夸张的广角透视效果,耀光,反射,极致的光影,强引力,吞噬",
      "size": "2K",
      "sequential_image_generation": "disabled",
      "stream": False,
      "response_format": "url",
      "watermark": False
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(json.dumps(result, indent=2, ensure_ascii=False))
  ```

  ```json Response theme={null}
  {
    "model": "doubao-seedream-4-0-250828",
    "created": 1765250822,
    "data": [
      {
        "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/...",
        "size": "3136x1344"
      }
    ],
    "usage": {
      "generated_images": 1,
      "output_tokens": 16464,
      "total_tokens": 16464
    }
  }
  ```
</CodeGroup>

## 参数说明

### 常用参数

| 参数名                                   | 类型           | 必填 | 说明       | 默认值/可选值                                                                                  |
| ------------------------------------- | ------------ | -- | -------- | ---------------------------------------------------------------------------------------- |
| `model`                               | string       | ✅  | 模型名称     | `doubao-seedream-4-0-250828`, `doubao-seedream-4-5-251128`, `doubao-seedream-5-0-260128` |
| `prompt`                              | string       | ✅  | 文本提示词    | 支持中英文,建议≤300汉字或600英文单词                                                                   |
| `image`                               | string/array | ❌  | 输入图片URL  | 图生图/多图融合时使用,支持URL或Base64                                                                 |
| `size`                                | string       | ✅  | 图片尺寸     | `2K`, `4K`, 或指定宽高如`2048x2048`                                                            |
| `sequential_image_generation`         | string       | ❌  | 序列图片生成模式 | `disabled`(关闭), `auto`(自动), 默认`disabled`                                                 |
| `sequential_image_generation_options` | object       | ❌  | 组图配置     | `max_images`: 最多图片数(1-15), 默认15                                                          |
| `stream`                              | boolean      | ❌  | 是否流式返回   | `true`, `false`, 默认`false`                                                               |
| `response_format`                     | string       | ❌  | 响应格式     | `url`(链接), `b64_json`(Base64), 默认`url`                                                   |
| `watermark`                           | boolean      | ❌  | 是否添加水印   | `true`, `false`, 默认`false`                                                               |

### 推荐宽高比

| 宽高比  | 宽高像素值     |
| ---- | --------- |
| 1:1  | 2048x2048 |
| 4:3  | 2304x1728 |
| 3:4  | 1728x2304 |
| 16:9 | 2560x1440 |
| 9:16 | 1440x2560 |
| 3:2  | 2496x1664 |
| 2:3  | 1664x2496 |
| 21:9 | 3024x1296 |

## 图生图

基于输入图片生成新图片。

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.xxx.com/v1/images/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-xxx" \
    -d '{
      "model": "doubao-seedream-4-0-250828",
      "prompt": "生成狗狗趴在草地上的近景画面",
      "image": "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imageToimage.png",
      "size": "2K",
      "sequential_image_generation": "disabled",
      "stream": false,
      "response_format": "url",
      "watermark": false
    }'
  ```

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

  url = "https://api.xxx.com/v1/images/generations"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer sk-xxx"
  }

  data = {
      "model": "doubao-seedream-4-0-250828",
      "prompt": "生成狗狗趴在草地上的近景画面",
      "image": "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imageToimage.png",
      "size": "2K",
      "sequential_image_generation": "disabled",
      "stream": False,
      "response_format": "url",
      "watermark": False
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(json.dumps(result, indent=2, ensure_ascii=False))
  ```

  ```json Response theme={null}
  {
    "model": "doubao-seedream-4-0-250828",
    "created": 1765250879,
    "data": [
      {
        "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/...",
        "size": "1696x2272"
      }
    ],
    "usage": {
      "generated_images": 1,
      "output_tokens": 15052,
      "total_tokens": 15052
    }
  }
  ```
</CodeGroup>

## 图生组图

基于输入图片生成一组连续的图片。

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.xxx.com/v1/images/generations \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer sk-xxx" \
     -d '{
       "model": "doubao-seedream-4-0-250828",
       "prompt": "生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片,涵盖早晨、中午、晚上",
       "image": ["https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_1.png", "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_2.png"],
       "sequential_image_generation": "auto",
       "sequential_image_generation_options": {
           "max_images": 3
       },
       "size": "2K"
     }'
  ```

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

  url = "https://api.xxx.com/v1/images/generations"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer sk-xxx"
  }

  data = {
      "model": "doubao-seedream-4-0-250828",
      "prompt": "生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片,涵盖早晨、中午、晚上",
      "image": [
          "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_1.png",
          "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_2.png"
      ],
      "sequential_image_generation": "auto",
      "sequential_image_generation_options": {
          "max_images": 3
      },
      "size": "2K"
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(json.dumps(result, indent=2, ensure_ascii=False))
  ```

  ```json Response theme={null}
  {
    "model": "doubao-seedream-4-0-250828",
    "created": 1765251003,
    "data": [
      {
        "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/..._0.jpeg",
        "size": "2848x1600"
      },
      {
        "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/..._1.jpeg",
        "size": "2848x1600"
      },
      {
        "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/..._2.jpeg",
        "size": "2848x1600"
      }
    ],
    "usage": {
      "generated_images": 3,
      "output_tokens": 53400,
      "total_tokens": 53400
    }
  }
  ```
</CodeGroup>

## 多图融合

融合多张图片的特征生成新图片。

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.xxx.com/v1/images/generations \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer sk-xxx" \
    -d '{
      "model": "doubao-seedream-4-0-250828",
      "prompt": "将图1的服装换为图2的服装",
      "image": ["https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png", "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_2.png"],
      "sequential_image_generation": "disabled",
      "size": "2K"
    }'
  ```

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

  url = "https://api.xxx.com/v1/images/generations"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer sk-xxx"
  }

  data = {
      "model": "doubao-seedream-4-0-250828",
      "prompt": "将图1的服装换为图2的服装",
      "image": [
          "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png",
          "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_2.png"
      ],
      "sequential_image_generation": "disabled",
      "size": "2K"
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(json.dumps(result, indent=2, ensure_ascii=False))
  ```
</CodeGroup>

<Note>
  返回的图片URL通常有24小时的有效期，请及时下载保存。
</Note>
