# 图片生成 API

> 全部文档的索引见 [llms.txt](https://ark.volcengine.com/llms.txt)；在任一文档页面地址后追加 `.md` 可获取该页的 Markdown 版本。

`POST https://ark.cn-beijing.volces.com/api/v3/images/generations`

本文介绍 Doubao Seedream 5.0 pro、Doubao Seedream 5.0 flash、Doubao Seedream 5.0 lite、Doubao Seedream 4.5 及 Doubao Seedream 4.0 图片生成模型的调用 API，包括输入输出参数、取值范围、注意事项等信息，供您使用接口时查阅字段含义。

**模型能力**

* **Seedream 5.0 pro<sup>==new==</sup>**、**Seedream 5.0 flash<sup>==new==</sup>**
  * 图层拆分：支持将单张图片拆解为底图（1 张）+ 多个图层输出（最多 16 个图层）。
  * 交互编辑：支持通过坐标、框选、箭头等多种方式指定编辑位置，精准编辑图片。
  * 生成单图（不支持配置 `sequential_image_generation`）
    * 多图生图：输入多张参考图片（2-10）+ 文本提示词，生成单张图片。
    * 单图生图：输入单张参考图片 + 文本提示词，生成单张图片。
    * 文生图：输入文本提示词，生成单张图片。
  * 暂不支持组图生成、联网搜索、流式输出。
* **Seedream 5.0 lite**、**Seedream 4.5 / 4.0**
  * 生成组图（组图：基于您输入的内容，生成的一组内容关联的图片；需配置 `sequential_image_generation` 为 `auto`）
    * 多图生组图：输入多张参考图片（2-14）+ 文本提示词，生成一组内容关联的图片（输入的参考图数量 + 最终生成的图片数量 ≤ 15 张）。
    * 单图生组图：输入单张参考图片 + 文本提示词，生成一组内容关联的图片（最多生成 14 张图片）。
    * 文生组图：输入文本提示词，生成一组内容关联的图片（最多生成 15 张图片）。
  * 生成单图（配置 `sequential_image_generation` 为 `disabled`）
    * 多图生图：输入多张参考图片（2-14）+ 文本提示词，生成单张图片。
    * 单图生图：输入单张参考图片 + 文本提示词，生成单张图片。
    * 文生图：输入文本提示词，生成单张图片。

## 鉴权

本接口支持鉴权方式如下，详情请参见 [Base URL 及鉴权](/docs/base-url-and-authentication)。

* API Key 鉴权，请在 [API Key 管理](https://ark.volcengine.com/region:cn-beijing/apiKey) 页面，获取长效 API Key。

---

<span id="request-parameters"></span>
## 请求参数

### Body 参数

**prompt** `string` | 提示词

用于生成图像或指定图层拆分意图的提示词。

> **说明**
>
> * **提示词语言支持**：所有模型均支持中英文提示词；
>   * `Seedream 5.0 pro` / `Seedream 5.0 flash` 额外支持俄语、阿拉伯语、菲律宾语、泰语、土耳其语、韩语、马来语、西班牙语、葡萄牙语、印尼语、法语、德语、越南语、日语。
> * **提示词字数建议**：中文提示词不超过 300 字，英文提示词不超过 600 词。字数过多信息容易分散，模型可能因此忽略细节，只关注重点，造成图片缺失部分元素。

**图片生成场景 `必选`**

用于描述生成图像的内容，模型根据提示词生成对应图像。（查看提示词指南：[Seedream 4.0-5.0 提示词指南](/docs/seedream-4-0-5-0-prompt-guide)）

**图层拆分场景 `可选`**

用于指定图层拆分意图，模型根据提示词意图识别并拆分指定元素。
若不传入提示词，模型将自动识别图片中的所有主要元素并拆分为独立图层。

**image** `string / string[]` | 参考图片

输入的图片信息，支持 URL 或 Base64 编码。

* 图片 URL：请确保图片 URL 可被访问。
* Base64 编码：请遵循此格式 `data:image/<图片格式>;base64,<Base64 编码>`。注意 `<图片格式>` 需小写，如 `data:image/png;base64,<base64_image>`。

**图片生成场景 `可选`**

Seedream 5.0 pro / Seedream 5.0 flash 最多支持传入 10 张参考图；Seedream 5.0 lite / 4.5 / 4.0 最多支持传入 14 张参考图。

**单张图片传入要求**：

* 图片格式：jpeg、png、webp、bmp、tiff、gif、heic、heif
* 宽高比（宽 / 高）范围：[1/16, 16]
* 宽高长度（px）> 14
* 大小：不超过 30MB
* 总像素：[196, `6000×6000`（3600万）]（对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制）

**图层拆分场景 `必选`**

当开启图层拆分模式时（`layer_decomposition` 为 `true`），`image` 为必选参数，且仅支持输入单张图片（传入多张报错）。

**单张图片传入要求**：

* 图片格式：png、jpeg
* 宽高比：[1/16, 16]
* 大小：不超过 30MB
* 总像素（宽×高）范围：[`512×512`（262144）, `6000×6000`（3600万）]（对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制）

**layer_decomposition<sup>==new==</sup>** `boolean` `默认值 false` | 图层拆分开关

控制是否开启图层拆分功能。

图层拆分会将单张图片的主体、背景、文字等内容自动拆解为 1 张底图和最多 16 个可独立编辑的图层。每个图层为带透明通道的 PNG 图片。

* `true`：图层拆分模式。模型将输入图拆解为一张底图和多个图层。
* `false`：图片生成模式，不进行图层拆分。

> **说明：图层拆分模式使用说明**
>
> * 仅支持输入单张待拆分图，传入多张报错。
> * 任一图层生成失败，整体请求报错，不支持部分成功。
> * 若提示词要求的拆分数量超过上限，可能导致部分图层信息丢失。
> * 响应结构体 `data` 中，将返回每个产出图层的位置和内容信息，包括图层顺序（`z_index`）、边界框信息（`bounding_box`）、名称（`name`）和描述（`description`）。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**size** `string` | 图像尺寸

指定生成图像的尺寸信息。对于不同模型和不同场景，参数的配置方式、可选分辨率、默认值、总像素取值范围、宽高比取值范围不同，请展开以下各模型对应说明查看。

**Seedream 5.0 pro / Seedream 5.0 flash（图片生成场景）**

支持以下两种方式，不可混用：

* 方式 1（推荐）：指定分辨率档位，并在 prompt 中用自然语言描述图片宽高比、图片形状或图片用途，最终由模型判断生成图片的大小。
    * 默认值：`2K`
    * 可选值：`1K`、`1.5K`、`2K`

> **注意：价格说明**
>
> `1.5K` 与 `1K` 价格相同（详情参见 [模型价格](/docs/model-pricing#457edfd0)），且图片生成效果更优。

* 方式 2：指定宽高像素值（`宽x高`）。
    * 总像素取值范围：[`1280x720`（921600）, `2048x2048x1.1025`（4624220）]
    * 宽高比取值范围：[1/16, 16]

> **说明**
>
> 采用方式 2 时，需同时满足总像素取值范围和宽高比取值范围。其中，总像素是对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制。
>
> * **有效示例**：`2048x1024`。总像素值 2048x1024=2097152，符合 [921600, 4624220] 的区间要求；宽高比 2048/1024=2，符合 [1/16, 16] 的区间要求，故该示例值有效。
> * **无效示例**：`512x512`。总像素值 512x512=262144，未达到 921600 的最低要求，故该示例值无效。

使用方式 1 时，模型实际映射的宽高像素参考值（不限于以下标准值，仅列常见）：

| 分辨率 | 宽高比 | 宽高像素值 |
| --- | --- | --- |
| 1K | 1:1 | 1024x1024 |
|^^| 4:3 | 1152x864 |
|^^| 3:4 | 864x1152 |
|^^| 16:9 | 1424x800 |
|^^| 9:16 | 800x1424 |
|^^| 3:2 | 1248x832 |
|^^| 2:3 | 832x1248 |
|^^| 21:9 | 1568x672 |
| 1.5K | 1:1 | 1536x1536 |
|^^| 4:3 | 1792x1344 |
|^^| 3:4 | 1344x1792 |
|^^| 16:9 | 2048x1152 |
|^^| 9:16 | 1152x2048 |
|^^| 3:2 | 1872x1248 |
|^^| 2:3 | 1248x1872 |
|^^| 21:9 | 2352x1008 |
| 2K | 1:1 | 2048x2048 |
|^^| 4:3 | 2368x1776 |
|^^| 3:4 | 1776x2368 |
|^^| 16:9 | 2816x1584 |
|^^| 9:16 | 1584x2816 |
|^^| 3:2 | 2496x1664 |
|^^| 2:3 | 1664x2496 |
|^^| 21:9 | 3136x1344 |

**Seedream 5.0 pro / Seedream 5.0 flash（图层拆分场景）**

仅支持通过指定分辨率档位的方式设置。输出图的分辨率规则如下：
* **底图**：输出底图的分辨率和 `size` 指定的分辨率一致；输出底图和原待拆分图的宽高比一致。
* **各图层**：输出图层的分辨率和 `size` 指定的分辨率接近；每个输出图层和其在原图中的宽高比一致。

`size` 的默认值与可选值：

* 默认值：`auto`
* 可选值：`1K`、`1.5K`、`2K`、`auto`（根据输入图的尺寸和宽高比进行输出）

> **注意：价格说明**
>
> `1.5K` 与 `1K` 价格相同（详情参见 [模型价格](/docs/model-pricing#457edfd0)）。

> **说明：auto 适配规则**
>
> auto 模式下，模型将根据输入图片中底图和每个图层的原始尺寸进行输出：
>
> * 若输入图片中底图和每个图层的原始尺寸在 [`1280x720`（921600）, `2048x2048x1.1025`（4624220）] 之间，按照原尺寸输出底图与每个图层；且各自保持其在原图中的宽高比。
> * 若输入图片中底图和每个图层的原始尺寸小于 1K，按 1K 输出底图与每个图层；且各自保持其在原图中的宽高比。
> * 若输入图片中底图和每个图层的原始尺寸大于 2K，按 2K 输出底图与每个图层；且各自保持其在原图中的宽高比。

模型实际映射的宽高像素参考值（不限于以下标准值，仅列常见）：

| 分辨率 | 宽高比 | 宽高像素值 |
| --- | --- | --- |
| 1K | 1:1 | 1024x1024 |
|^^| 4:3 | 1152x864 |
|^^| 3:4 | 864x1152 |
|^^| 16:9 | 1424x800 |
|^^| 9:16 | 800x1424 |
|^^| 3:2 | 1248x832 |
|^^| 2:3 | 832x1248 |
|^^| 21:9 | 1568x672 |
| 1.5K | 1:1 | 1536x1536 |
|^^| 4:3 | 1792x1344 |
|^^| 3:4 | 1344x1792 |
|^^| 16:9 | 2048x1152 |
|^^| 9:16 | 1152x2048 |
|^^| 3:2 | 1872x1248 |
|^^| 2:3 | 1248x1872 |
|^^| 21:9 | 2352x1008 |
| 2K | 1:1 | 2048x2048 |
|^^| 4:3 | 2368x1776 |
|^^| 3:4 | 1776x2368 |
|^^| 16:9 | 2816x1584 |
|^^| 9:16 | 1584x2816 |
|^^| 3:2 | 2496x1664 |
|^^| 2:3 | 1664x2496 |
|^^| 21:9 | 3136x1344 |

**Seedream 5.0 lite**

支持以下两种方式，不可混用：

* 方式 1：指定分辨率，并在 prompt 中用自然语言描述图片宽高比、图片形状或图片用途，最终由模型判断生成图片的大小。
    * 可选值：`2K`、`3K`、`4K`
* 方式 2：指定生成图像的宽高像素值。
    * 默认值：`2048x2048`
    * 总像素取值范围：[`2560x1440`（3686400）, `4096x4096`（16777216）]
    * 宽高比取值范围：[1/16, 16]

> **说明**
>
> 采用方式 2 时，需同时满足总像素取值范围和宽高比取值范围。其中，总像素是对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制。
>
> * **有效示例**：`3750x1250`。总像素值 3750x1250=4687500，符合 [3686400, 16777216] 的区间要求；宽高比 3750/1250=3，符合 [1/16, 16] 的区间要求，故该示例值有效。
> * **无效示例**：`1500x1500`。总像素值 1500x1500=2250000，未达到 3686400 的最低要求；宽高 1500/1500=1，虽符合 [1/16, 16] 的区间要求，但未同时满足两项限制，故该示例值无效。

采用方式 1 时，模型实际映射的宽高像素参考值：

| 分辨率 | 宽高比 | 宽高像素值 |
| --- | --- | --- |
| 2K | 1:1 | 2048x2048 |
| | 4:3 | 2304x1728 |
| | 3:4 | 1728x2304 |
| | 16:9 | 2848x1600 |
| | 9:16 | 1600x2848 |
| | 3:2 | 2496x1664 |
| | 2:3 | 1664x2496 |
| | 21:9 | 3136x1344 |
| 3K | 1:1 | 3072x3072 |
| | 4:3 | 3456x2592 |
| | 3:4 | 2592x3456 |
| | 16:9 | 4096x2304 |
| | 9:16 | 2304x4096 |
| | 3:2 | 3744x2496 |
| | 2:3 | 2496x3744 |
| | 21:9 | 4704x2016 |
| 4K | 1:1 | 4096x4096 |
| | 4:3 | 4704x3520 |
| | 3:4 | 3520x4704 |
| | 16:9 | 5504x3040 |
| | 9:16 | 3040x5504 |
| | 3:2 | 4992x3328 |
| | 2:3 | 3328x4992 |
| | 21:9 | 6240x2656 |

**Seedream 4.5**

支持以下两种方式，不可混用：

* 方式 1：指定分辨率，并在 prompt 中用自然语言描述图片宽高比、图片形状或图片用途，最终由模型判断生成图片的大小。
    * 可选值：`2K`、`4K`
* 方式 2：指定生成图像的宽高像素值。
    * 默认值：`2048x2048`
    * 总像素取值范围：[`2560x1440`（3686400）, `4096x4096`（16777216）]
    * 宽高比取值范围：[1/16, 16]

> **说明**
>
> 采用方式 2 时，需同时满足总像素取值范围和宽高比取值范围。其中，总像素是对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制。
>
> * **有效示例**：`3750x1250`。总像素值 3750x1250=4687500，符合 [3686400, 16777216] 的区间要求；宽高比 3750/1250=3，符合 [1/16, 16] 的区间要求，故该示例值有效。
> * **无效示例**：`1500x1500`。总像素值 1500x1500=2250000，未达到 3686400 的最低要求；宽高 1500/1500=1，虽符合 [1/16, 16] 的区间要求，但未同时满足两项限制，故该示例值无效。

采用方式 1 时，模型实际映射的宽高像素参考值：

| 分辨率 | 宽高比 | 宽高像素值 |
| --- | --- | --- |
| 2K | 1:1 | 2048x2048 |
| | 4:3 | 2304x1728 |
| | 3:4 | 1728x2304 |
| | 16:9 | 2848x1600 |
| | 9:16 | 1600x2848 |
| | 3:2 | 2496x1664 |
| | 2:3 | 1664x2496 |
| | 21:9 | 3136x1344 |
| 4K | 1:1 | 4096x4096 |
| | 4:3 | 4704x3520 |
| | 3:4 | 3520x4704 |
| | 16:9 | 5504x3040 |
| | 9:16 | 3040x5504 |
| | 3:2 | 4992x3328 |
| | 2:3 | 3328x4992 |
| | 21:9 | 6240x2656 |

**Seedream 4.0**

支持以下两种方式，不可混用：

* 方式 1：指定分辨率，并在 prompt 中用自然语言描述图片宽高比、图片形状或图片用途，最终由模型判断生成图片的大小。
    * 可选值：`1K`、`2K`、`4K`
* 方式 2：指定生成图像的宽高像素值。
    * 默认值：`2048x2048`
    * 总像素取值范围：[`1280x720`（921600）, `4096x4096`（16777216）]
    * 宽高比取值范围：[1/16, 16]

> **说明**
>
> 采用方式 2 时，需同时满足总像素取值范围和宽高比取值范围。其中，总像素是对单张图宽度和高度的像素乘积限制，而不是对宽度或高度的单独值进行限制。
>
> * **有效示例**：`1600x600`。总像素值 1600x600=960000，符合 [921600, 16777216] 的区间要求；宽高比 1600/600=8/3，符合 [1/16, 16] 的区间要求，故该示例值有效。
> * **无效示例**：`800x800`。总像素值 800x800=640000，未达到 921600 的最低要求；宽高 800/800=1，虽符合 [1/16, 16] 的区间要求，但未同时满足两项限制，故该示例值无效。

采用方式 1 时，模型实际映射的宽高像素参考值：

| 分辨率 | 宽高比 | 宽高像素值 |
| --- | --- | --- |
| 1K | 1:1 | 1024x1024 |
| | 4:3 | 1152x864 |
| | 3:4 | 864x1152 |
| | 16:9 | 1280x720 |
| | 9:16 | 720x1280 |
| | 3:2 | 1248x832 |
| | 2:3 | 832x1248 |
| | 21:9 | 1512x648 |
| 2K | 1:1 | 2048x2048 |
| | 4:3 | 2304x1728 |
| | 3:4 | 1728x2304 |
| | 16:9 | 2848x1600 |
| | 9:16 | 1600x2848 |
| | 3:2 | 2496x1664 |
| | 2:3 | 1664x2496 |
| | 21:9 | 3136x1344 |
| 4K | 1:1 | 4096x4096 |
| | 4:3 | 4704x3520 |
| | 3:4 | 3520x4704 |
| | 16:9 | 5504x3040 |
| | 9:16 | 3040x5504 |
| | 3:2 | 4992x3328 |
| | 2:3 | 3328x4992 |
| | 21:9 | 6240x2656 |

**optimize_prompt_options** `object` | 提示词优化配置

提示词优化功能的配置。

**mode** `string` `默认值 standard` | 优化模式

`optimize_prompt_options.mode`

设置提示词优化功能使用的模式。

* `standard`：标准模式，生成内容的质量更高，耗时较长。
* `fast`：快速模式，生成内容的耗时更短，效果略低于标准模式；Seedream 5.0 flash / lite / 4.5 当前不支持。

> **说明**
>
> 如您的业务对生成时延较为敏感，推荐使用 Seedream 5.0 pro 的 `fast` 模式或使用 Seedream 5.0 flash 以获得更快的图片生成速度。

**output_format** `string` `默认值 jpeg` | 图像格式

指定生成图像的文件格式。可选值：
* `png`
* `jpeg`。

> **注意**
>
> * 图层拆分场景下，`output_format` 仅控制底图的输出格式，图层始终以 `png` 格式输出。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`
* `Seedream 5.0 lite`

**background<sup>==new==</sup>** `string` `默认值 opaque` | 图片透明通道

用于控制是否生成带透明通道的图片。可选值：

* `transparent`：透明背景模式，输出带有透明背景的图。
* `opaque`：不透明背景模式，生成常规的实体背景图。

> **注意：透明背景模式使用要求**
>
> * 仅支持图生图场景，且只支持输入 **1 张带透明通道**的图片；
> * 输出图片默认为 `png` 格式，若同时配置 `output_format` 为 `jpeg`，将触发报错；
> * 若传入了不支持透明通道的文件格式（如 `jpeg`），将触发报错。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**response_format** `string` `默认值 url` | 返回格式

指定生成图像的返回格式。支持以下两种返回方式：

* `url`：返回图片下载链接，**链接在图片生成后 24 小时内有效，请及时下载图片**。
* `b64_json`：以 Base64 编码字符串的 JSON 格式返回图像数据。

**sequential_image_generation** `string` `默认值 disabled` | 组图模式

控制是否关闭组图功能（组图：基于您输入的内容，生成的一组内容关联的图片）。

* `auto`：自动判断模式，模型会根据用户提供的提示词自主判断是否返回组图以及组图包含的图片数量。
* `disabled`：关闭组图功能，模型只会生成一张图。

组图输出示例详见 [Seedream 图像创作教程 - 组图输出](/docs/seedream-4-0-5-0#ec79cfda)。

**模型支持**：

* `Seedream 5.0 lite`
* `Seedream 4.5`
* `Seedream 4.0`

**sequential_image_generation_options** `object` | 组图配置

组图功能的配置。仅当 `sequential_image_generation` 为 `auto` 时生效。

**模型支持**：

* `Seedream 5.0 lite`
* `Seedream 4.5`
* `Seedream 4.0`

**max_images** `integer` `默认值 15` | 最大生成数量

`sequential_image_generation_options.max_images`

指定本次请求，最多可生成的图片数量。

> **说明**
>
> 实际可生成的图片数量，除受到 `max_images` 影响外，还受到输入的参考图数量影响。**输入的参考图数量+最终生成的图片数量≤15 张**。

**取值范围**：`[1, 15]`

**stream** `boolean` `默认值 false` | 流式输出开关

控制是否开启流式输出模式。

* `false`：非流式输出模式，等待所有图片全部生成结束后再一次性返回所有信息。
* `true`：流式输出模式，即时返回每张图片输出的结果。在生成单图和组图的场景下，流式输出模式均生效。

流式输出示例详见 [Seedream 图像创作教程 - 流式输出](/docs/seedream-4-0-5-0#e5bef0d7)。

**模型支持**：

* `Seedream 5.0 lite`
* `Seedream 4.5`
* `Seedream 4.0`

**tools** `object[]` | 工具配置

配置模型要调用的工具。

**模型支持**：

* `Seedream 5.0 lite`

**type** `string` `必选` | 工具类型

`tools.type`

指定使用的工具类型。

* `web_search`：联网搜索功能。

> **说明**
>
> * 开启联网搜索后，模型会根据用户的提示词自主判断是否搜索互联网内容（如商品、天气等），提升生成图片的时效性，但也会增加一定的时延。
> * 实际搜索次数可通过字段 `usage.tool_usage.web_search` 查询，如果为 0 表示未搜索。

**watermark** `boolean` `默认值 true` | 水印开关

是否在生成的图片中添加水印。

* `false`：不添加水印。
* `true`：在图片右下角添加“AI 生成”字样的水印标识。

**model** `string` `必选` | 模型 ID

您需要调用的模型的 ID（Model ID），[开通模型服务](https://ark.volcengine.com/region:cn-beijing/openManagement?LLM=%7B%7D&OpenTokenDrawer=false)，并 [查询 Model ID](/docs/model-list#9df4d9fd)。

您也可通过 Endpoint ID 来调用模型，获得限流、计费类型（前付费 / 后付费）、运行状态查询、监控、安全等高级能力，可参考 [获取 Endpoint ID](https://ark.volcengine.com/region:cn-beijing/docs/create-standard-inference-endpoint)。

## 响应参数

### 非流式调用响应

**created** `integer` | 创建时间

本次请求创建时间的 Unix 时间戳（秒）

**model** `string` | 模型 ID

本次请求使用的模型 ID（模型名称-版本）

**data** `object[]` | 图像数据

输出图像的信息。不同任务场景返回字段有所区别，其中 `url`、`b64_json`、`size`、`output_format` 为公共返回字段。

* 组图生成场景，若某张图生成失败，额外返回该图片的错误信息（`error`）。
* 图层拆分场景，额外返回每个图层的叠放顺序（`z_index`）、名称（`name`）、描述（`description`）、边界框坐标（`bounding_box`）。

**公共字段**

**url** `string` | 图片 URL

`data.url`

图片 URL，当 `response_format` 指定为 `url` 时返回。该链接将在生成后 **24 小时内失效**，请务必及时保存图像。

推荐配置火山引擎 TOS 提供的数据订阅功能，将您的模型推理产物自动转存到自己的 TOS 桶中，便于长期备份或二次加工。详细介绍请参见 [TOS 数据订阅](https://docs.volcengine.com/docs/TorchObjectStorage/Datasubscription-5?lang=zh)。

**b64_json** `string` | 图片 Base64 数据

`data.b64_json`

图片的 Base64 信息，当 `response_format` 指定为 `b64_json` 时返回

**size** `string` | 图像尺寸

`data.size`

图像的宽高像素值，格式 `<宽像素>x<高像素>`，例如 `2048x2048`。

**output_format<sup>==new==</sup>** `string` | 输出格式

`data.output_format`

输出图像的格式信息（`png` 或 `jpeg`）。

> **注意**
>
> * 图层拆分场景下，`output_format` 仅控制底图的输出格式，图层始终以 `png` 格式输出。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**特殊字段（图层拆分场景）**

**z_index<sup>==new==</sup>** `integer` | 图层叠放顺序

`data.z_index`

图层的叠放顺序索引。底图固定为 `0`，图层从 `1` 开始递增，数值越大越靠上层。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**name<sup>==new==</sup>** `string` | 图层名称

`data.name`

当前图层拆分元素的名称/标签。由模型根据拆分出的主体特征自动生成，用于标识该图层的主体内容。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**description<sup>==new==</sup>** `string` | 图层描述

`data.description`

当前图层拆分元素的详细描述。由模型生成的语义描述，提供比 `name` 更丰富的图层特征（如颜色、状态、材质等）。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**bounding_box<sup>==new==</sup>** `object` | 图层边界框

`data.bounding_box`

输出图层在输出底图坐标系中所占区域的边界框信息。仅图层返回该字段；底图覆盖整张画布，不返回该字段。

> **说明：使用说明**
>
> * `bounding_box` 表示图层在待拆分图中的相对位置与宽高比，等比缩放至输出底图坐标系后的坐标。
>   * 若需将图层还原到输出底图中，建议优先使用 `absolute` 坐标。
>   * 若需将图层还原到任意自定义的画布中，可使用 `normalized` 坐标。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**absolute** `array` | 绝对坐标

`data.bounding_box.absolute`

输出图层边界框在输出底图坐标系中的绝对像素坐标（单位：像素），输出底图左上角坐标为 `(0, 0)`。格式为由 4 个整数构成的数组：`[left, top, right, bottom]`。

* `left`：图层左边界到输出底图左边界的水平距离。
* `top`：图层上边界到输出底图上边界的垂直距离。
* `right`：图层右边界到输出底图左边界的水平距离。
* `bottom`：图层下边界到输出底图上边界的垂直距离。

> **说明：坐标示例**
>
> 例如 `[225, 442, 796, 1414]` 表示图层左上角坐标为 `(225, 442)`，右下角坐标为 `(796, 1414)`。

> **注意：使用 bounding_box.absolute 还原图层**
>
> 使用 `bounding_box.absolute` 可将输出图层还原到其在输出底图坐标系中的边界框区域。计算方式如下：
>
> * 图层在输出底图中的左上角坐标：`x = left`，`y = top`。
> * 图层在输出底图中的占用宽度：`w = right - left`。
> * 图层在输出底图中的占用高度：`h = bottom - top`。
>
> 将输出图层缩放至 `w × h`，再放置到输出底图的 `(x, y)` 位置。多个图层需要组合时，按 `z_index` 从小到大依次叠放。

**normalized** `array` | 归一化坐标

`data.bounding_box.normalized`

图层边界框在输出底图坐标系中的归一化坐标，由绝对坐标按输出底图宽高换算至 `[0, 1000]` 的离散整数区间得到。格式为由 4 个整数构成的数组：`[left, top, right, bottom]`。

* `left`、`right`：图层左右边界在底图宽度方向上的相对位置。`0` 表示底图最左侧，`1000` 表示底图最右侧。
* `top`、`bottom`：图层上下边界在底图高度方向上的相对位置。`0` 表示底图最上方，`1000` 表示底图最下方。

> **说明：坐标示例**
>
> 例如 `[220, 432, 777, 1000]` 表示：图层左边界距离底图左边界 22.0% 底图宽度，上边界距离底图上边界 43.2% 底图高度，右边界距离底图左边界 77.7% 底图宽度，下边界与底图下边缘对齐。

> **注意：使用 bounding_box.normalized 还原图层**
>
> 使用 `bounding_box.normalized` 可将输出图层还原到目标画布中的边界框区域。设目标画布的宽高为 `W × H`：
>
> * 图层在目标画布中的左上角坐标：`x = left / 1000 × W`，`y = top / 1000 × H`。
> * 图层在目标画布中的占用宽度：`w = (right - left) / 1000 × W`。
> * 图层在目标画布中的占用高度：`h = (bottom - top) / 1000 × H`。
>
> 将输出图层缩放至 `w × h`，再放置到目标画布的 `(x, y)` 位置。归一化坐标为整数，换算后可能存在取整误差。

**特殊字段（组图生成场景）**

**error** `object` | 单图错误信息

`data.error`

某张图片生成失败时返回的错误信息。其他成功生成的图片不受影响

> **说明**
>
> 组图生成过程中某张图生成失败时：
>
> * 若失败原因为审核不通过：仍会继续请求下一个图片生成任务，即不影响同请求内其他图片的生成流程。
> * 若失败原因为内部服务异常（500）：不会继续请求下一个图片生成任务。

**模型支持**：

* `Seedream 5.0 lite`
* `Seedream 4.5`
* `Seedream 4.0`

**code** `string` | 错误码

`data.error.code`

错误码，请参见 [错误码](/docs/error-codes)

**message** `string` | 错误消息

`data.error.message`

错误提示信息，便于排查问题

**error** `object` | 错误信息

本次请求顶层错误信息。当整个请求未能生成任何图片时返回

**code** `string` | 错误码

`error.code`

错误码，请参见 [错误码](/docs/error-codes)

**message** `string` | 错误消息

`error.message`

错误提示信息，便于排查问题

**tools** `object[]` | 工具调用列表

本次请求中配置并被模型调用的工具列表

**模型支持**：

* `Seedream 5.0 lite`

**type** `string` | 工具类型

`tools.type`

指定使用的工具类型。

* `web_search`：联网搜索功能。

> **说明**
>
> * 开启联网搜索后，模型会根据用户的提示词自主判断是否搜索互联网内容（如商品、天气等），提升生成图片的时效性，但也会增加一定的时延。
> * 实际搜索次数可通过字段 `usage.tool_usage.web_search` 查询，如果为 0 表示未搜索。

**usage** `object` | 用量信息

本次请求的用量信息，包括生成图片数量、消耗的 token 数量等

**generated_images** `integer` | 成功生成图片数

`usage.generated_images`

模型成功生成的图片张数，不包含生成失败的图片。仅对成功生成图片按张数进行计费

**input_images<sup>==new==</sup>** `integer` | 输入图片数

`usage.input_images`

输入模型的图片张数。

**模型支持**：

* `Seedream 5.0 pro`
* `Seedream 5.0 flash`

**output_tokens** `integer` | 输出 token 数

`usage.output_tokens`

模型生成的图片花费的 token 数量。计算逻辑为：`sum(图片长 * 图片宽) / 256` 后取整

**tool_usage** `object` | 工具用量

`usage.tool_usage`

使用工具的用量信息

**模型支持**：

* `Seedream 5.0 lite`

**web_search** `integer` | 联网搜索次数

`usage.tool_usage.web_search`

调用联网搜索工具的次数，仅开启联网搜索时返回。如果为 0 表示未搜索

**total_tokens** `integer` | 总 token 数

`usage.total_tokens`

本次请求消耗的总 token 数量。当前不计算输入 token，故与 `output_tokens` 值一致

### 流式调用响应

字段结构详见 [图片生成流式响应事件](/docs/image-generation-streaming-responses)。


## 代码示例

## 图层拆分

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "将图片进行精确图层分离，需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>757 210 939 280</bbox>、<bbox>63 212 320 282</bbox>、<bbox>178 714 826 810</bbox>、<bbox>814 819 949 894</bbox>、<bbox>326 824 669 930</bbox>；鹦鹉的坐标为<bbox>347 305 642 997</bbox>。",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png",
    "layer_decomposition": true,
    "size": "2K",
    "output_format": "jpeg",
    "response_format": "url",
    "watermark": true
}'
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "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
    }
}
```

### Python


#### Request

```python
import os

# Install SDK: python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv("ARK_API_KEY"),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="将图片进行精确图层分离，需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>757 210 939 280</bbox>、<bbox>63 212 320 282</bbox>、<bbox>178 714 826 810</bbox>、<bbox>814 819 949 894</bbox>、<bbox>326 824 669 930</bbox>；鹦鹉的坐标为<bbox>347 305 642 997</bbox>。",
    image="https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png",
    layer_decomposition=True,
    size="2K",
    output_format="jpeg",
    response_format="url",
    watermark=True,
)

for item in imagesResponse.data:
    print(item)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "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
    }
}
```

### Java


#### Request

```java
package com.ark.sample;

import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-pro-260628") // Replace with Model ID
                .prompt("将图片进行精确图层分离，需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>757 210 939 280</bbox>、<bbox>63 212 320 282</bbox>、<bbox>178 714 826 810</bbox>、<bbox>814 819 949 894</bbox>、<bbox>326 824 669 930</bbox>；鹦鹉的坐标为<bbox>347 305 642 997</bbox>。")
                .image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png"))
                .layerDecomposition(true)
                .size("2K")
                .outputFormat(OutputFormat.JPEG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .build();

        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        imagesResponse.getData().forEach(item -> System.out.println(item));

        service.shutdownExecutor();
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "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
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatJpeg

    generateReq := &model.CreateImageGenerationRequest{
        Model:              "doubao-seedream-5-0-pro-260628",
        Prompt:             model.NewOptString("将图片进行精确图层分离，需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>757 210 939 280</bbox>、<bbox>63 212 320 282</bbox>、<bbox>178 714 826 810</bbox>、<bbox>814 819 949 894</bbox>、<bbox>326 824 669 930</bbox>；鹦鹉的坐标为<bbox>347 305 642 997</bbox>。"),
        Image: model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{"https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png"})),
        LayerDecomposition: model.NewOptBool(true),
        Size:               model.NewOptString("2K"),
        OutputFormat: model.NewOptOutputFormat(outputFormat),
        ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
        Watermark:          model.NewOptBool(true),
    }

    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
        fmt.Printf("generate images error: %v\n", err)
        return
    }

    for _, item := range imagesResponse.Data {
        fmt.Printf("%+v\n", item)
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "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
    }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv("ARK_API_KEY"),
)

imagesResponse = client.images.generate(
    model="doubao-seedream-5-0-pro-260628",
    prompt="将图片进行精确图层分离，需分离的文字坐标为<bbox>180 64 812 198</bbox>、<bbox>757 210 939 280</bbox>、<bbox>63 212 320 282</bbox>、<bbox>178 714 826 810</bbox>、<bbox>814 819 949 894</bbox>、<bbox>326 824 669 930</bbox>；鹦鹉的坐标为<bbox>347 305 642 997</bbox>。",
    size="2K",
    output_format="jpeg",
    response_format="url",
    extra_body={
        "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_layer_input.png",
        "layer_decomposition": True,
        "watermark": True,
    },
)

for item in imagesResponse.data:
    print(item)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1784696685,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048",
            "output_format": "jpeg",
            "z_index": 0
        },
        {
            "url": "https://...",
            "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
    }
}
```

## 交互编辑

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册，并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_input2.png",
    "size": "2K",
    "output_format": "png",
    "watermark": true
}'
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 18000,
        "total_tokens": 18000
    }
}
```

### Python


#### Request

```python
import os

# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv("ARK_API_KEY"),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册，并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。",
    image="https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_input2.png",
    size="2K",
    output_format="png",
    response_format="url",
    watermark=True,
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 18000,
        "total_tokens": 18000
    }
}
```

### Java


#### Request

```java
package com.ark.sample;

import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-pro-260628") // Replace with Model ID
                .prompt("根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册，并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。")
                .image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_input2.png"))
                .size("2K")
                .outputFormat(OutputFormat.PNG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .build();

        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        System.out.println(imagesResponse.getData().get(0).getUrl());

        service.shutdownExecutor();
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 18000,
        "total_tokens": 18000
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    generateReq := &model.CreateImageGenerationRequest{
        Model:          "doubao-seedream-5-0-pro-260628",
        Prompt:         model.NewOptString("根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册，并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。让新添加的物体自然融入原有场景中。"),
        Image: model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{"https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream_50_pro_input2.png"})),
        Size:           model.NewOptString("2K"),
        OutputFormat: model.NewOptOutputFormat(outputFormat),
        ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
        Watermark:      model.NewOptBool(true),
    }

    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
        fmt.Printf("generate images error: %v\n", err)
        return
    }

    fmt.Printf("%s\n", imagesResponse.Data[0].URL.Or(""))
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 18000,
        "total_tokens": 18000
    }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key: https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv("ARK_API_KEY"),
)

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

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "2048x2048"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 18000,
        "total_tokens": 18000
    }
}
```

## 文生图

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "充满活力的特写编辑肖像，模特眼神犀利，头戴雕塑感帽子，色彩拼接丰富，眼部焦点锐利，景深较浅，具有Vogue杂志封面的美学风格，采用中画幅拍摄，工作室灯光效果强烈。",
    "size": "2K",
    "output_format":"png",
    "watermark": true
}'
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx
    }
}
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="充满活力的特写编辑肖像，模特眼神犀利，头戴雕塑感帽子，色彩拼接丰富，眼部焦点锐利，景深较浅，具有Vogue杂志封面的美学风格，采用中画幅拍摄，工作室灯光效果强烈。",
    size="2K",
    output_format="png",
    response_format="url",
    watermark=True
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx
    }
}
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        // Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-pro-260628") // Replace with Model ID
                .prompt("充满活力的特写编辑肖像，模特眼神犀利，头戴雕塑感帽子，色彩拼接丰富，眼部焦点锐利，景深较浅，具有Vogue杂志封面的美学风格，采用中画幅拍摄，工作室灯光效果强烈。")
                .size("2K")
                .outputFormat(OutputFormat.PNG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .build();
        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        System.out.println(imagesResponse.getData().get(0).getUrl());

        service.shutdownExecutor();
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        // Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG


    generateReq := &model.CreateImageGenerationRequest{
       Model:          "doubao-seedream-5-0-pro-260628", // Replace with Model ID
       Prompt:         model.NewOptString("充满活力的特写编辑肖像，模特眼神犀利，头戴雕塑感帽子，色彩拼接丰富，眼部焦点锐利，景深较浅，具有Vogue杂志封面的美学风格，采用中画幅拍摄，工作室灯光效果强烈。"),
       Size:           model.NewOptString("2K"),
       OutputFormat: model.NewOptOutputFormat(outputFormat),
       ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
       Watermark:      model.NewOptBool(true),
    }

    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
       fmt.Printf("generate images error: %v\n", err)
       return
    }

    fmt.Printf("%s\n", imagesResponse.Data[0].URL.Or(""))
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx
    }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="充满活力的特写编辑肖像，模特眼神犀利，头戴雕塑感帽子，色彩拼接丰富，眼部焦点锐利，景深较浅，具有Vogue杂志封面的美学风格，采用中画幅拍摄，工作室灯光效果强烈。",
    size="2K",
    output_format="png",
    response_format="url",
    extra_body={
        "watermark": True,
    },
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx
    }
}
```

## 图生图

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水（或玻璃）。透过液态水流，可以看到模特的皮肤细节。光影从反射变为折射。",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png",
    "size": "2K",
    "output_format":"png",
    "watermark": true
}'
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水（或玻璃）。透过液态水流，可以看到模特的皮肤细节。光影从反射变为折射。",
    image="https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png",
    size="2K",
    output_format="png",
    response_format="url",
    watermark=True
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-pro-260628") // Replace with Model ID
                .prompt("保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水（或玻璃）。透过液态水流，可以看到模特的皮肤细节。光影从反射变为折射。")
                .image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png"))
                .size("2K")
                .outputFormat(OutputFormat.PNG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .build();

        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        System.out.println(imagesResponse.getData().get(0).getUrl());

        service.shutdownExecutor();
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    generateReq := &model.CreateImageGenerationRequest{
       Model:          "doubao-seedream-5-0-pro-260628",
       Prompt:         model.NewOptString("保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水（或玻璃）。透过液态水流，可以看到模特的皮肤细节。光影从反射变为折射。"),
       Image: model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{"https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png"})),
       Size:           model.NewOptString("2K"),
       OutputFormat: model.NewOptOutputFormat(outputFormat),
       ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
       Watermark:      model.NewOptBool(true),
    }

    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
       fmt.Printf("generate images error: %v\n", err)
       return
    }

    fmt.Printf("%s\n", imagesResponse.Data[0].URL.Or(""))
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    model="doubao-seedream-5-0-pro-260628",
    prompt="保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水（或玻璃）。透过液态水流，可以看到模特的皮肤细节。光影从反射变为折射。",
    size="2K",
    output_format="png",
    response_format="url",
    extra_body = {
        "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png",
        "watermark": True
    }
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

## 多图融合

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-pro-260628",
    "prompt": "将图1的服装换为图2的服装",
    "image": ["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png"],
    "size": "2K",
    "output_format":"png",
    "watermark": true
}'
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)
imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-pro-260628",
    prompt="将图1的服装换为图2的服装",
    image=["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png"],
    size="2K",
    output_format="png",
    response_format="url",
    watermark=True
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-pro-260628") // Replace with Model ID
                .prompt("将图1的服装换为图2的服装")
                .image(CreateImageGenerationRequestImage.ofList(Arrays.asList(
                    "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png",
                    "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png"
                )))
                .size("2K")
                .outputFormat(OutputFormat.PNG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .build();
        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        System.out.println(imagesResponse.getData().get(0).getUrl());

        service.shutdownExecutor();
    }
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    generateReq := &model.CreateImageGenerationRequest{
       Model:          "doubao-seedream-5-0-pro-260628",
       Prompt:         model.NewOptString("将图1的服装换为图2的服装"),
       Image:         model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{
           "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png",
           "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png",
       })),
       Size:           model.NewOptString("2K"),
       OutputFormat: model.NewOptOutputFormat(outputFormat),
       ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
       Watermark:      model.NewOptBool(true),
    }

    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
       fmt.Printf("generate images error: %v\n", err)
       return
    }

    fmt.Printf("%s\n", imagesResponse.Data[0].URL.Or(""))
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    model="doubao-seedream-5-0-pro-260628",
    prompt="将图1的服装换为图2的服装",
    size="2K",
    output_format="png",
    response_format="url",
    extra_body = {
        "image": ["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimage_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imagesToimage_2.png"],
        "watermark": True,
    }
)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-pro-260628",
    "created": 1757323224,
    "data": [
        {
            "url": "https://...",
            "size": "1760x2368"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16280,
        "total_tokens": 16280
    }
}
```

## 多参考图生组图

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-260128",
    "prompt": "生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片，涵盖早晨、中午、晚上",
    "image": ["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_2.png"],
    "sequential_image_generation": "auto",
    "sequential_image_generation_options": {
        "max_images": 3
    },
    "size": "2K",
    "output_format":"png",
    "watermark": true
}'
```

#### Response

```
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark
from arkruntime.types.images import SequentialImageGenerationOptionsParam

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-260128",
    prompt="生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片，涵盖早晨、中午、晚上",
    image=["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_2.png"],
    size="2K",
    sequential_image_generation="auto",
    sequential_image_generation_options=SequentialImageGenerationOptionsParam(max_images=3),
    output_format="png",
    response_format="url",
    watermark=True
)

# Iterate through all image data
for image in imagesResponse.data:
    # Output the current image's URL and size
    print(f"URL: {image.url}, Size: {image.size}")
```
#### Response

```
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        SequentialImageGenerationOptions sequentialImageGenerationOptions = new SequentialImageGenerationOptions();
        sequentialImageGenerationOptions.setMaxImages(3);
        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                 .model("doubao-seedream-5-0-260128") // Replace with Model ID
                 .prompt("生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片，涵盖早晨、中午、晚上")
                 .image(CreateImageGenerationRequestImage.ofList(Arrays.asList(
                     "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_1.png",
                     "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_2.png"
                 )))
                 .outputFormat(OutputFormat.PNG)
                 .size("2K")
                 .sequentialImageGeneration(SequentialImageGenerationMode.AUTO)
                 .sequentialImageGenerationOptions(sequentialImageGenerationOptions)

                 .responseFormat(ResponseFormat.URL)
                 .stream(false)
                 .watermark(true)
                 .build();
        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);

        // Iterate through all image data
        if (imagesResponse != null && imagesResponse.getData() != null) {
            for (int i = 0; i < imagesResponse.getData().size(); i++) {
                // Retrieve image information
                String url = imagesResponse.getData().get(i).getUrl();
                String size = imagesResponse.getData().get(i).getSize();
                System.out.printf("Image %d:%n", i + 1);
                System.out.printf("  URL: %s%n", url);
                System.out.printf("  Size: %s%n", size);
                System.out.println();
            }


            service.shutdownExecutor();
        }
    }
}
```
#### Response

```
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    var sequentialImageGeneration model.SequentialImageGenerationMode = "auto"
    maxImages := 3
    generateReq := &model.CreateImageGenerationRequest{
       Model:          "doubao-seedream-5-0-260128",
       Prompt:         model.NewOptString("生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片，涵盖早晨、中午、晚上"),
       Image:         model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{
           "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_1.png",
           "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_2.png",
       })),

       Size:           model.NewOptString("2K"),
       OutputFormat: model.NewOptOutputFormat(outputFormat),
       ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
       Watermark:      model.NewOptBool(true),
       SequentialImageGeneration: model.NewOptSequentialImageGenerationMode(sequentialImageGeneration),
       SequentialImageGenerationOptions: model.NewOptSequentialImageGenerationOptions(model.SequentialImageGenerationOptions{
          MaxImages: model.NewOptInt32(int32(maxImages)),
       }),
    }

    resp, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
        fmt.Printf("call GenerateImages error: %v\n", err)
        return
    }

    if resp.Error.IsSet() {
        fmt.Printf("API returned error: %s - %s\n", resp.Error.Value.Code, resp.Error.Value.Message)
        return
    }

    // Output the generated image information
    fmt.Printf("Generated %d images:\n", len(resp.Data))
    for i, image := range resp.Data {
        var url string
        if image.URL.IsSet() {
            url = image.URL.Or("")
        } else {
            url = "N/A"
        }
        fmt.Printf("Image %d: Size: %s, URL: %s\n", i+1, image.Size.Or(""), url)
    }
}
```
#### Response

```
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    model="doubao-seedream-5-0-260128",
    prompt="生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片，涵盖早晨、中午、晚上",
    size="2K",
    output_format="png",
    response_format="url",
    extra_body={
        "image": ["https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_1.png", "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imagesToimages_2.png"],
        "watermark": True,
        "sequential_image_generation": "auto",
        "sequential_image_generation_options": {
            "max_images": 3
        },
    }
)

# Iterate through all image data
for image in imagesResponse.data:
    # Output the current image's URL and size
    print(f"URL: {image.url}, Size: {image.size}")
```
#### Response

```
{
  "model": "doubao-seedream-5-0-260128",
  "created": 1757388756,
  "data": [
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    },
    {
      "url": "https://...",
      "size": "2720x1536"
    }
  ],
  "usage": {
    "generated_images": 3,
    "output_tokens": 48960,
    "total_tokens": 48960
  }
}
```

## 流式输出

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-260128",
    "prompt": "参考图1，生成四图片，图中人物分别带着墨镜，骑着摩托，带着帽子，拿着棒棒糖",
    "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages_1.png",
    "sequential_image_generation": "auto",
    "sequential_image_generation_options": {
        "max_images": 4
    },
    "size": "2K",
    "stream": true,
    "output_format":"png",
    "watermark": true
}'
```

#### Response

```
event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396757,
  "image_index": 0,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396785,
  "image_index": 1,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "image_index": 2,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.completed
data: {
  "type": "image_generation.completed",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "usage": {
    "generated_images": 3,
    "output_tokens": 48672,
    "total_tokens": 48672
  }
}

data: [DONE]
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark
from arkruntime.types.images import SequentialImageGenerationOptionsParam

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

if __name__ == "__main__":
    stream = client.images.generate(
        # Replace with Model ID
        model="doubao-seedream-5-0-260128",
        prompt="参考图1，生成四图片，图中人物分别带着墨镜，骑着摩托，带着帽子，拿着棒棒糖",
        image="https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages_1.png",
        size="2K",
        sequential_image_generation="auto",
        sequential_image_generation_options=SequentialImageGenerationOptionsParam(max_images=4),
        output_format="png",
        response_format="url",
        stream=True,
        watermark=True
    )
    for event in stream:
        if event is None:
            continue
        if event.type == "image_generation.partial_failed":
            print(f"Stream generate images error: {event.error}")
            if event.error is not None and event.error.code.equal("InternalServiceError"):
                break
        elif event.type == "image_generation.partial_succeeded":
            if event.error is None and event.url:
                print(f"recv.Size: {event.size}, recv.Url: {event.url}")
        elif event.type == "image_generation.completed":
            if event.error is None:
                print("Final completed event:")
                print("recv.Usage:", event.usage)
        elif event.type == "image_generation.partial_image":
            print(f"Partial image index={event.partial_image_index}, size={len(event.b64_json)}")
```

#### Response

```
event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396757,
  "image_index": 0,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396785,
  "image_index": 1,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "image_index": 2,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.completed
data: {
  "type": "image_generation.completed",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "usage": {
    "generated_images": 3,
    "output_tokens": 48672,
    "total_tokens": 48672
  }
}

data: [DONE]
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        SequentialImageGenerationOptions sequentialImageGenerationOptions = new SequentialImageGenerationOptions();
        sequentialImageGenerationOptions.setMaxImages(4);
        // CreateImageGenerationRequestImage requires ark-runtime 0.6.0 or later.
        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                 .model("doubao-seedream-5-0-260128") //Replace with Model ID .
                 .prompt("参考图1，生成四图片，图中人物分别带着墨镜，骑着摩托，带着帽子，拿着棒棒糖")
                 .image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages_1.png"))
                 .size("2K")
                 .sequentialImageGeneration(SequentialImageGenerationMode.AUTO)
                 .sequentialImageGenerationOptions(sequentialImageGenerationOptions)
                 .outputFormat(OutputFormat.PNG)
                 .responseFormat(ResponseFormat.URL)
                 .stream(true)
                 .watermark(true)
                 .build();
        System.out.println(generateRequest.toString());

        service.streamGenerateImages(generateRequest)
                .doOnError(Throwable::printStackTrace)
                .blockingForEach(
                        choice -> {
                            if (choice == null) return;
                            if (ImageGenerationStreamEventType.IMAGE_GENERATION_PARTIAL_FAILED.equals(choice.getType())) {
                                if (choice.getError() != null) {
                                    System.err.println("Stream generate images error: " + choice.getError());
                                    if (choice.getError().getCode() != null && choice.getError().getCode().equals("InternalServiceError")) {
                                        throw new RuntimeException("Server error, terminating stream.");
                                    }
                                }
                            }
                            else if (ImageGenerationStreamEventType.IMAGE_GENERATION_PARTIAL_SUCCEEDED.equals(choice.getType())) {
                                if (choice.getError() == null && choice.getUrl() != null && !choice.getUrl().isEmpty()) {
                                    System.out.printf("recv.Size: %s, recv.Url: %s%n", choice.getSize(), choice.getUrl());
                                }
                            }
                            else if (ImageGenerationStreamEventType.IMAGE_GENERATION_COMPLETED.equals(choice.getType())) {
                                if (choice.getError() == null && choice.getUsage() != null) {
                                    System.out.println("recv.Usage: " + choice.getUsage().toString());
                                }
                            }
                        }
                );
        service.shutdownExecutor();
    }
}
```
#### Response

```
event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396757,
  "image_index": 0,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396785,
  "image_index": 1,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "image_index": 2,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.completed
data: {
  "type": "image_generation.completed",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "usage": {
    "generated_images": 3,
    "output_tokens": 48672,
    "total_tokens": 48672
  }
}

data: [DONE]
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "io"
    "os"
    "strings"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    var sequentialImageGeneration model.SequentialImageGenerationMode = "auto"
    maxImages := 4
    generateReq := &model.CreateImageGenerationRequest{
       Model:          "doubao-seedream-5-0-260128",
       Prompt:         model.NewOptString("参考图1，生成四图片，图中人物分别带着墨镜，骑着摩托，带着帽子，拿着棒棒糖"),
       Image: model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{"https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages_1.png"})),
       Size:           model.NewOptString("2K"),
       OutputFormat: model.NewOptOutputFormat(outputFormat),
       ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
       Watermark:      model.NewOptBool(true),
       SequentialImageGeneration: model.NewOptSequentialImageGenerationMode(sequentialImageGeneration),
       SequentialImageGenerationOptions: model.NewOptSequentialImageGenerationOptions(model.SequentialImageGenerationOptions{
          MaxImages: model.NewOptInt32(int32(maxImages)),
       }),
    }

    stream, err := client.GenerateImagesStreaming(ctx, generateReq)
    if err != nil {
       fmt.Printf("call GenerateImagesStreaming error: %v\n", err)
       return
    }
    defer stream.Close()
    for {
       recv, err := stream.Recv()
       if err == io.EOF {
          break
       }
       if err != nil {
          fmt.Printf("Stream generate images error: %v\n", err)
          break
       }
       if recv.Type == model.ImageGenerationStreamEventTypeImageGenerationPartialFailed {
          fmt.Printf("Stream generate images error: %v\n", recv.Error)
          if strings.EqualFold(recv.Error.Value.Code, "InternalServiceError") {
             break
          }
       }
       if recv.Type == model.ImageGenerationStreamEventTypeImageGenerationPartialSucceeded {
          if !recv.Error.IsSet() && recv.URL.IsSet() {
             fmt.Printf("recv.Size: %s, recv.Url: %s\n", recv.Size.Or(""), recv.URL.Or(""))
          }
       }
       if recv.Type == model.ImageGenerationStreamEventTypeImageGenerationCompleted {
          if !recv.Error.IsSet() {
             fmt.Printf("recv.Usage: %v\n", recv.Usage.Or(model.Usage{}))
          }
       }
    }
}
```
#### Response

```
event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396757,
  "image_index": 0,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396785,
  "image_index": 1,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "image_index": 2,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.completed
data: {
  "type": "image_generation.completed",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "usage": {
    "generated_images": 3,
    "output_tokens": 48672,
    "total_tokens": 48672
  }
}

data: [DONE]
```

### Python-OpenAI


#### Request

```python
import os
from openai import OpenAI

client = OpenAI(
    # The base URL for model invocation .
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

if __name__ == "__main__":
    stream = client.images.generate(
        model="doubao-seedream-5-0-260128",
        prompt="参考图1，生成四图片，图中人物分别带着墨镜，骑着摩托，带着帽子，拿着棒棒糖",
        size="2K",
        output_format="png",
        response_format="b64_json",
        stream=True,
        extra_body={
            "image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages_1.png",
            "watermark": True,
            "sequential_image_generation": "auto",
            "sequential_image_generation_options": {
                "max_images": 4
            },
        },
    )
    for event in stream:
        if event is None:
            continue
        elif event.type == "image_generation.partial_succeeded":
            if event.b64_json is not None:
                print(f"size={len(event.b64_json)}, base_64={event.b64_json}")
        elif event.type == "image_generation.completed":
            if event.usage is not None:
                print("Final completed event:")
                print("recv.Usage:", event.usage)
```
#### Response

```
event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396757,
  "image_index": 0,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396785,
  "image_index": 1,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.partial_succeeded
data: {
  "type": "image_generation.partial_succeeded",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "image_index": 2,
  "url": "https://...",
  "size": "2496x1664"
}

event: image_generation.completed
data: {
  "type": "image_generation.completed",
  "model": "doubao-seedream-5-0-260128",
  "created": 1757396825,
  "usage": {
    "generated_images": 3,
    "output_tokens": 48672,
    "total_tokens": 48672
  }
}

data: [DONE]
```

## 联网搜索

### cURL


#### Request

```bash
curl https://ark.cn-beijing.volces.com/api/v3/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -d '{
    "model": "doubao-seedream-5-0-260128",
    "prompt": "制作一张上海未来5日的天气预报图，采用现代扁平化插画风格，清晰展示每日天气、温度和穿搭建议。 整体为横向排版，标题为“上海未来5日天气预报”，包含5个等宽的垂直卡片，从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格，线条清晰，色彩柔和。人物形象采用年轻男女的卡通插画，表情自然，姿态放松，服装细节清晰。",
    "size": "2048x2048",
    "tools": [
      {
          "type": "web_search"
      }
  ],
    "output_format":"png",
    "response_format": "url",
    "watermark": true
}'
```

#### Response

```
{
    "model": "doubao-seedream-5-0-260128",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx,
        "tool_usage": {
            "web_search": 1 // 实际搜索次数
        }
    }
}
```

### Python


#### Request

```python
import os
# Install SDK:  python -m pip install --upgrade arkruntime
from arkruntime import Ark
from arkruntime.types.images import ToolParam

client = Ark(
    # The base URL for model invocation
    base_url="https://ark.cn-beijing.volces.com/api/v3",
    # Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
    api_key=os.getenv('ARK_API_KEY'),
)

imagesResponse = client.images.generate(
    # Replace with Model ID
    model="doubao-seedream-5-0-260128",
    prompt="制作一张上海未来5日的天气预报图，采用现代扁平化插画风格，清晰展示每日天气、温度和穿搭建议。 整体为横向排版，标题为“上海未来5日天气预报”，包含5个等宽的垂直卡片，从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格，线条清晰，色彩柔和。人物形象采用年轻男女的卡通插画，表情自然，姿态放松，服装细节清晰。",
    size="2048x2048",
    output_format="png",
    response_format="url",
    tools=[ToolParam(type="web_search")],
    watermark=True,

)

print(imagesResponse.data[0].url)
```
#### Response

```
{
    "model": "doubao-seedream-5-0-260128",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx,
        "tool_usage": {
            "web_search": 1 // 实际搜索次数
        }
    }
}
```

### Java


#### Request

```java
package com.ark.sample;


import com.volcengine.ark.runtime.models.images.*;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ImageGenerationsExample {
    public static void main(String[] args) {
        // Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
        String apiKey = System.getenv("ARK_API_KEY");
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        ArkService service = ArkService.builder()
                .baseUrl("https://ark.cn-beijing.volces.com/api/v3")
                // The base URL for model invocation
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();

        // Create ContentGenerationTool
        Tool contentGenerationTool = new Tool();
        contentGenerationTool.setType(ToolType.WEB_SEARCH);

        // Create list of tools
        List<Tool> tools = Arrays.asList(contentGenerationTool);

        CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
                .model("doubao-seedream-5-0-260128") // Replace with Model ID
                .prompt("制作一张上海未来5日的天气预报图，采用现代扁平化插画风格，清晰展示每日天气、温度和穿搭建议。 整体为横向排版，标题为“上海未来5日天气预报”，包含5个等宽的垂直卡片，从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格，线条清晰，色彩柔和。人物形象采用年轻男女的卡通插画，表情自然，姿态放松，服装细节清晰。")
                .size("2048x2048")
                .outputFormat(OutputFormat.PNG)
                .responseFormat(ResponseFormat.URL)
                .watermark(true)
                .tools(tools)
                .build();

        ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
        System.out.println(imagesResponse.getData().get(0).getUrl());

        service.shutdownExecutor();
    }
}
```

#### Response

```
{
    "model": "doubao-seedream-5-0-260128",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx,
        "tool_usage": {
            "web_search": 1 // 实际搜索次数
        }
    }
}
```

### Go


#### Request

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/volcengine/ark-runtime-go/arkruntime"
    model "github.com/volcengine/ark-runtime-go/arkruntime/model/images"
)

func main() {
    client := arkruntime.NewClientWithApiKey(
        // Get API Key：https://ark.volcengine.com/region:cn-beijing/apikey
        os.Getenv("ARK_API_KEY"),
        // The base URL for model invocation
        arkruntime.WithBaseUrl("https://ark.cn-beijing.volces.com/api/v3"),
    )
    ctx := context.Background()
    outputFormat := model.OutputFormatPNG

    generateReq := &model.CreateImageGenerationRequest{
        Model:          "doubao-seedream-5-0-260128", // Replace with Model ID
        Prompt:         model.NewOptString("制作一张上海未来5日的天气预报图，采用现代扁平化插画风格，清晰展示每日天气、温度和穿搭建议。 整体为横向排版，标题为“上海未来5日天气预报”，包含5个等宽的垂直卡片，从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格，线条清晰，色彩柔和。人物形象采用年轻男女的卡通插画，表情自然，姿态放松，服装细节清晰。"),
        Size:           model.NewOptString("2048x2048"),
        OutputFormat: model.NewOptOutputFormat(outputFormat),
        ResponseFormat: model.NewOptResponseFormat(model.ResponseFormatURL),
        Watermark:      model.NewOptBool(true),
        Tools: []model.Tool{
            {
                Type: model.ToolTypeWebSearch,
            },
        },
    }
    imagesResponse, err := client.GenerateImages(ctx, generateReq)
    if err != nil {
       fmt.Printf("generate images error: %v\n", err)
       return
    }

    fmt.Printf("%s\n", imagesResponse.Data[0].URL.Or(""))
}
```
#### Response

```
{
    "model": "doubao-seedream-5-0-260128",
    "created": 1757321139,
    "data": [
        {
            "url": "https://...",
            "size": "3104x1312"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": xxx,
        "total_tokens": xxx,
        "tool_usage": {
            "web_search": 1 // 实际搜索次数
        }
    }
}
```
