Doubao Seedream 系列模型原生支持文本、单图和多图输入,实现基于主体一致性的多图融合创作、图像编辑、组图生成等多样玩法,让图像创作更加自由可控。本文以 Doubao Seedream 5.0 lite(以下简称 Seedream 5.0 lite)为例介绍如何调用 Image generation API 进行图像创作。如需使用 Doubao Seedream 5.0 pro(以下简称 Seedream 5.0 pro)/ Doubao Seedream 4.5(以下简称 Seedream 4.5)/ Doubao Seedream 4.0(以下简称 Seedream 4.0)模型,将下文代码示例中的 model 字段替换为对应的 Model ID 即可。
模型效果#
更多效果示例见 效果预览。
| 场景 | 输入 | 输出 |
|---|---|---|
| 图层拆分 Seedream 5.0 pro / flash 支持将元素拆分为可独立编辑的图层,便于后续拖拽、缩放、重组等精细化编辑。 |
![]() 将图片进行精确图层分离,需分离的文字坐标为 <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>。 |
![]() |
| 交互编辑 Seedream 5.0 pro / flash 支持通过标记指定编辑区域,模型识别标记范围并生成内容,自然融入原有场景。 |
![]() 根据手绘草图对图像进行编辑。在左下角标记区域添加一叠真实的杂志或艺术画册,并在右侧标记区域添加一个带杯碟的陶瓷杯咖啡。移除所有草图线条。保持构图不变。 |
![]() |
文生图 联网搜索Seedream 5.0 lite 模型可通过联网搜索功能,融合实时网络信息,提升生图时效性。 |
制作一张上海未来5日的天气预报图,采用现代扁平化插画风格,清晰展示每日天气、温度和穿搭建议。 整体为横向排版,标题为“上海未来5日天气预报”,包含5个等宽的垂直卡片,从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格,线条清晰,色彩柔和。 人物形象采用年轻男女的卡通插画,表情自然,姿态放松,服装细节清晰。 | |
| 多参考图生图 输入多张参考图,融合它们的风格、元素等特征来生成新图像。 |
将图1的服装换为图2的服装 |
|
| 组图生成 基于用户输入的文字和图片,生成一组内容关联的图像 |
参考图1,生成四图片,图中人物分别带着墨镜,骑着摩托,带着帽子,拿着棒棒糖 |
![]() |
模型能力#
以下为 Seedream 系列各版本模型的能力与参数对比,帮助您根据业务需求选择合适的模型。
| 模型名称 | Seedream 5.0 pro | Seedream 5.0 flash | Seedream 5.0 lite | Seedream 4.5 | Seedream 4.0 | |
|---|---|---|---|---|---|---|
| 模型 ID (Model ID) | doubao-seedream-5-0-pro-260628 | doubao-seedream-5-0-flash-260915 | doubao-seedream-5-0-260128 (同时支持:doubao-seedream-5-0-lite-260128) | doubao-seedream-4-5-251128 | doubao-seedream-4-0-250828 | |
| 文生图 | ✓ | ✓ | ✓ | ✓ | ✓ | |
| 文生组图 | 暂不支持 | 暂不支持 | ✓ | ✓ | ✓ | |
| 单 / 多图生图 | ✓ | ✓ | ✓ | ✓ | ✓ | |
| 单 / 多图生组图 | 暂不支持 | 暂不支持 | ✓ | ✓ | ✓ | |
| 交互编辑 | ✓ | ✓ | ✗ | ✗ | ✗ | |
| 图层拆分 | ✓ | ✓ | ✗ | ✗ | ✗ | |
| 流式输出 | 暂不支持 | 暂不支持 | ✓ | ✓ | ✓ | |
| 联网搜索 | 暂不支持 | 暂不支持 | ✓ | ✗ | ✗ | |
| 模型参数 | 分辨率 | 1K, 1.5K, 2K | 1K, 1.5K, 2K | 2K, 3K, 4K | 2K, 4K | 1K, 2K, 4K |
| 输出格式 | png, jpeg | png, jpeg | png, jpeg | jpeg | jpeg | |
| 提示词优化模式 | 标准模式, 极速模式 | 标准模式 | 标准模式 | 标准模式 | 标准模式, 极速模式 | |
| 生成数量 | 支持生成单图/多个图层(1 张底图 + 16 张图层) | 支持生成单图/多个图层(1 张底图 + 16 张图层) | 输入的参考图数量 + 最终生成的图片数量 ≤ 15张 | |||
| 限流 IPM(张 / 分钟) | 500 | 500 | 500 | 500 | 500 | |
快速体验#
您可在火山方舟平台 API Explorer,快速体验图片生成功能,支持自定义参数(例如设置图片水印、控制输出图片大小等),方便您直观感受其效果和性能。
基础使用#
文生图(纯文本输入单图输出)#
通过给模型提供清晰准确的文字指令,即可快速获得符合描述的高质量单张图片。
| 提示词 | 输出 |
|---|---|
| 充满活力的特写编辑肖像,模特眼神犀利,头戴雕塑感帽子,色彩拼接丰富,眼部焦点锐利,景深较浅,具有Vogue杂志封面的美学风格,采用中画幅拍摄,工作室灯光效果强烈。 |
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-lite-260128",
"prompt": "充满活力的特写编辑肖像,模特眼神犀利,头戴雕塑感帽子,色彩拼接丰富,眼部焦点锐利,景深较浅,具有Vogue杂志封面的美学风格,采用中画幅拍摄,工作室灯光效果强烈。",
"size": "2K",
"output_format":"png",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
prompt="充满活力的特写编辑肖像,模特眼神犀利,头戴雕塑感帽子,色彩拼接丰富,眼部焦点锐利,景深较浅,具有Vogue杂志封面的美学风格,采用中画幅拍摄,工作室灯光效果强烈。",
size="2K",
output_format="png",
response_format="url",
watermark=True
)
print(imagesResponse.data[0].url)
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-lite-260128") // Replace with Model ID
.prompt("充满活力的特写编辑肖像,模特眼神犀利,头戴雕塑感帽子,色彩拼接丰富,眼部焦点锐利,景深较浅,具有Vogue杂志封面的美学风格,采用中画幅拍摄,工作室灯光效果强烈。")
.size("2K")
.sequentialImageGeneration(SequentialImageGenerationMode.DISABLED)
.outputFormat(OutputFormat.PNG)
.responseFormat(ResponseFormat.URL)
.stream(false)
.watermark(true)
.build();
ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
System.out.println(imagesResponse.getData().get(0).getUrl());
service.shutdownExecutor();
}
}
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-lite-260128", // 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(""))
}
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-lite-260128",
prompt="充满活力的特写编辑肖像,模特眼神犀利,头戴雕塑感帽子,色彩拼接丰富,眼部焦点锐利,景深较浅,具有Vogue杂志封面的美学风格,采用中画幅拍摄,工作室灯光效果强烈。",
size="2K",
output_format="png",
response_format="url",
extra_body={
"watermark": False,
},
)
print(imagesResponse.data[0].url)
图文生图(单图输入单图输出)#
基于已有图片,结合文字指令进行图像编辑,包括图像元素增删、风格转化、材质替换、色调迁移、改变背景/视角/尺寸等。
| 提示词 | 输入图 | 输出 |
|---|---|---|
| 保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水(或玻璃)。透过液态水流,可以看到模特的皮肤细节。光影从反射变为折射。 |
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-lite-260128",
"prompt": "保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水(或玻璃)。透过液态水流,可以看到模特的皮肤细节。光影从反射变为折射。",
"image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png",
"size": "2K",
"output_format":"png",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
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)
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-lite-260128") // Replace with Model ID
.prompt("保持模特姿势和液态服装的流动形状不变。将服装材质从银色金属改为完全透明的清水(或玻璃)。透过液态水流,可以看到模特的皮肤细节。光影从反射变为折射。")
.image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png"))
.size("2K")
.sequentialImageGeneration(SequentialImageGenerationMode.DISABLED)
.outputFormat(OutputFormat.PNG)
.responseFormat(ResponseFormat.URL)
.stream(false)
.watermark(true)
.build();
ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
System.out.println(imagesResponse.getData().get(0).getUrl());
service.shutdownExecutor();
}
}
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-lite-260128",
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(""))
}
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-lite-260128",
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)
多图融合(多图输入单图输出)#
根据您输入的文本描述和多张参考图片,融合它们的风格、元素等特征来生成新图像。如衣裤鞋帽与模特图融合成穿搭图,人物与风景融合为人物风景图等。
| 提示词 | 输入图1 | 输入图2 | 输出 |
|---|---|---|---|
| 将图1的服装换为图2的服装 |
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-lite-260128",
"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
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
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)
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-lite-260128") // 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")
.sequentialImageGeneration(SequentialImageGenerationMode.DISABLED)
.outputFormat(OutputFormat.PNG)
.responseFormat(ResponseFormat.URL)
.stream(false)
.watermark(true)
.build();
ImageGenerationResponse imagesResponse = service.generateImages(generateRequest);
System.out.println(imagesResponse.getData().get(0).getUrl());
service.shutdownExecutor();
}
}
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-lite-260128",
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(""))
}
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-lite-260128",
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)
组图输出(多图输出)#
Seedream 5.0 pro / flash 不支持该能力。
支持通过一张或者多张图片和文字信息,生成漫画分镜、品牌视觉等一组内容关联的图片。
需指定参数 sequential_image_generation 为auto。
文生组图#
| 提示词 | 输出(实际会输出4张图片) |
|---|---|
| 生成一组电影级科幻写实风的4张影视分镜: 场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。 场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。 场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。 场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。 |
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-lite-260128",
"prompt": "生成一组电影级科幻写实风的4张影视分镜:场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
"stream": false,
"output_format":"png",
"response_format": "url",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
prompt="生成一组电影级科幻写实风的4张影视分镜:场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。",
size="2K",
sequential_image_generation="auto",
sequential_image_generation_options=SequentialImageGenerationOptionsParam(max_images=4),
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}")
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);
CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
.model("doubao-seedream-5-0-lite-260128") // Replace with Model ID
.prompt("生成一组电影级科幻写实风的4张影视分镜:场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。")
.size("2K")
.sequentialImageGeneration(SequentialImageGenerationMode.AUTO)
.sequentialImageGenerationOptions(sequentialImageGenerationOptions)
.outputFormat(OutputFormat.PNG)
.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();
}
}
}
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 := 4
generateReq := &model.CreateImageGenerationRequest{
Model: "doubao-seedream-5-0-lite-260128",
Prompt: model.NewOptString("生成一组电影级科幻写实风的4张影视分镜:场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。"),
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)
}
}
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-lite-260128",
prompt="生成一组电影级科幻写实风的4张影视分镜:场景1为宇航员在空间站维修飞船,空间站外部精密机械结构,深邃星空 + 银河背景,宇航员身穿细节完整的白色宇航服,手持专业维修工具,专注检修飞船外壳,中全景构图,侧逆光勾勒轮廓,冷色调科幻光影,空间站灯光点缀,失重环境,金属质感细腻,画面静谧严谨。场景2为:突然遇到陨石带袭击,广角史诗镜头,大量大小不一的陨石高速袭来,陨石表面纹理清晰,带燃烧尾焰,动态模糊体现速度感,陨石带压迫感拉满,飞船与空间站在画面一侧,太空黑暗深邃,光影强烈对比,紧张灾难氛围,画面冲击力十足。场景3为:宇航员紧急躲避,近景动态抓拍,宇航员失重状态下极速侧身躲避,肢体动作张力拉满,伸手抓握固定扶手,背景陨石飞掠而过,轻微镜头晃动增强临场感,宇航服褶皱、管线细节清晰,急促紧张,冷冽光影,主体突出不杂乱。场景4为:受伤后惊险逃回飞船,中近景叙事镜头,宇航员宇航服带轻微破损划痕,略显狼狈却坚毅,踉跄冲向开启的飞船舱门,舱内暖光与太空冷光形成对比,背景陨石逐渐远去,惊险逃生氛围,细节真实,情绪饱满。",
size="2K",
output_format="png",
response_format="url",
extra_body={
"watermark": True,
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
},
)
# 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}")
单张图生组图#
| 提示词 | 输入图 | 输出(实际会输出4张图片) |
|---|---|---|
| 参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格。 |
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-lite-260128",
"prompt": "参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格",
"image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages.png",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
"stream": false,
"output_format":"png",
"response_format": "url",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
prompt="参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格",
image="https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages.png",
size="2K",
sequential_image_generation="auto",
sequential_image_generation_options=SequentialImageGenerationOptionsParam(max_images=4),
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}")
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-lite-260128") // Replace with Model ID
.prompt("参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格")
.image(CreateImageGenerationRequestImage.ofString("https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages.png"))
.size("2K")
.sequentialImageGeneration(SequentialImageGenerationMode.AUTO)
.sequentialImageGenerationOptions(sequentialImageGenerationOptions)
.outputFormat(OutputFormat.PNG)
.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();
}
}
}
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 := 4
generateReq := &model.CreateImageGenerationRequest{
Model: "doubao-seedream-5-0-lite-260128",
Prompt: model.NewOptString("参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格"),
Image: model.NewOptCreateImageGenerationRequestImage(model.NewStringArrayCreateImageGenerationRequestImage([]string{"https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages.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)
}
}
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-260128",
prompt="参考这个LOGO,做一套户外运动品牌视觉设计,品牌名称为“GREEN”,包括包装袋、帽子、卡片、挂绳等。绿色视觉主色调,趣味、简约现代风格",
size="2K",
output_format="png",
response_format="url",
extra_body={
"image": "https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_imageToimages.png",
"watermark": True,
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
}
)
# 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}")
多参考图生组图#
| 提示词 | 输入图1 | 输入图2 | 输出(实际会输出3张图片) |
|---|---|---|---|
| 生成3张女孩和奶牛玩偶在游乐园开心地坐过山车的图片,涵盖早晨、中午、晚上 |
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-lite-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
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-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}")
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-lite-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();
}
}
}
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-lite-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)
}
}
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-lite-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}")
提示词建议#
- 建议用简洁连贯的自然语言写明 主体 + 行为 + 环境,若对画面美学有要求,可用自然语言或短语补充 风格、色彩、光影、构图 等美学元素。详情可参见 Seedream 4.0-5.0 提示词指南。
- 文本提示词(prompt)建议不超过300个汉字或600个英文单词。字数过多信息容易分散,模型可能因此忽略细节,只关注重点,造成图片缺失部分元素。
进阶使用#
联网搜索#
Seedream 5.0 pro / flash 不支持该能力。
Seedream 5.0 lite 支持调用联网搜索工具,通过配置 tools.type 参数为 web_search 即可开启联网搜索。
- 开启联网搜索后,模型会根据用户的提示词自主判断是否搜索互联网内容(如商品、天气等),提升生成图片的时效性,但也会增加一定的时延。
- 实际搜索次数可通过字段 usage.tool_usage.web_search 查询,如果为 0 表示未搜索。
| 提示词 | 输出 |
|---|---|
| 制作一张上海未来5日的天气预报图,采用现代扁平化插画风格,清晰展示每日天气、温度和穿搭建议。 整体为横向排版,标题为“上海未来5日天气预报”,包含5个等宽的垂直卡片,从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格,线条清晰,色彩柔和。人物形象采用年轻男女的卡通插画,表情自然,姿态放松,服装细节清晰。 |
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-lite-260128",
"prompt": "制作一张上海未来5日的天气预报图,采用现代扁平化插画风格,清晰展示每日天气、温度和穿搭建议。整体为横向排版,标题为“上海未来5日天气预报”,包含5个等宽的垂直卡片,从左到右依次排列。 整体风格为现代、干净、友好的扁平化矢量插画风格,线条清晰,色彩柔和。人物形象采用年轻男女的卡通插画,表情自然,姿态放松,服装细节清晰。",
"size": "2048x2048",
"tools": [
{
"type": "web_search"
}
],
"output_format":"png",
"response_format": "url",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-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)
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-lite-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();
}
}
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-lite-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(""))
}
流式输出#
Seedream 5.0 pro / flash 不支持该能力。
模型支持流式图像生成,当生成完任一图片后即返回结果,让您能更快浏览到生成的图像,改善等待体验。
通过配置 stream 参数为true,即可开启流式输出模式。
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-lite-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
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
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-lite-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)}")
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-lite-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();
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();
}
}
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-lite-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{}))
}
}
}
}
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-lite-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)
提升图片生成速度配置#
通过设置 optimize_prompt_options.mode 参数,您可以在 standard 模式和 fast 模式之间进行选择,以根据自身对图片质量和生成速度的不同需求来优化提示词。
- 为平衡生成速度与图像质量,Seedream 5.0 pro、Seedream 4.0 支持将 optimize_prompt_options.mode 设置为
fast模式以显著提升生成速度,但会在一定程度上牺牲图片质量。 - Seedream 5.0 flash / lite、Seedream 4.5 仅支持
standard模式。
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-4-0-250828",
"prompt": "生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
"optimize_prompt_options": {
"mode": "fast"
},
"stream": false,
"output_format":"png",
"response_format": "url",
"watermark": true
}'
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
import os
# Install SDK: python -m pip install --upgrade arkruntime
from arkruntime import Ark
from arkruntime.types.images import SequentialImageGenerationOptionsParam
from arkruntime.types.images import OptimizePromptOptionsParam
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-4-0-250828",
prompt="生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围",
size="2K",
sequential_image_generation="auto",
sequential_image_generation_options=SequentialImageGenerationOptionsParam(max_images=4),
optimize_prompt_options=OptimizePromptOptionsParam(mode="fast"),
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}")
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);
OptimizePromptOptions optimizePromptOptions = new OptimizePromptOptions();
optimizePromptOptions.setMode(OptimizePromptMode.FAST);
CreateImageGenerationRequest generateRequest = CreateImageGenerationRequest.builder()
.model("doubao-seedream-4-0-250828") //Replace with Model ID
.prompt("生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围")
.size("2K")
.sequentialImageGeneration(SequentialImageGenerationMode.AUTO)
.sequentialImageGenerationOptions(sequentialImageGenerationOptions)
.optimizePromptOptions(optimizePromptOptions)
.outputFormat(OutputFormat.PNG)
.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();
}
}
}
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 = 4
mode model.OptimizePromptMode = model.OptimizePromptModeFast
)
generateReq := &model.CreateImageGenerationRequest{
Model: "doubao-seedream-4-0-250828",
Prompt: model.NewOptString("生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围"),
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)),
}),
OptimizePromptOptions: model.NewOptOptimizePromptOptions(model.OptimizePromptOptions{
Mode: model.NewOptOptimizePromptMode(mode),
}),
}
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)
}
}
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-4-0-250828",
prompt="生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围",
size="2K",
output_format="png",
response_format="url",
extra_body={
"watermark": True,
"sequential_image_generation": "auto",
"sequential_image_generation_options": {
"max_images": 4
},
"optimize_prompt_options": {"mode": "fast"}
},
)
# 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}")
- 您可按需替换 Model ID。Model ID 查询见 模型列表。
自定义图片输出规格#
您可以配置以下参数来控制图片输出规格:
-
size:指定输出图像的尺寸大小。
-
response_format:指定生成图像的返回格式。
-
output_format:指定生成图像的文件格式。
-
watermark :指定是否为输出图片添加水印。
图像输出尺寸#
图片生成场景
指定生成图像的尺寸信息,支持指定分辨率档位(如 2K)或指定宽高像素值(如 2048x2048)两种方式,不可混用。不同模型的可选分辨率、默认值、总像素取值范围、宽高比取值范围不同。
方式 1:指定分辨率档位(推荐)
在 prompt 中用自然语言描述图片宽高比、图片形状或图片用途,最终由模型判断生成图片的大小。各模型可选值:
- Seedream 5.0 pro:
1K、1.5K、2K
- Seedream 5.0 lite:
2K、3K、4K - Seedream 4.5:
2K、4K - Seedream 4.0:
1K、2K、4K
使用方式 1 并在 prompt 中描述特定宽高比时,模型实际映射的宽高像素参考值如下表所示(模型支持生成的宽高比不限于以下列举的标准值,此处仅以常见宽高比为例)。
| 1K | 1.5K | 2K | 3K | 4K | |
|---|---|---|---|---|---|
| Seedream 5.0 pro | 1:1:1024x10244:3:1152x8643:4:864x115216:9:1424x8009:16:800x14243:2:1248x8322:3:832x124821:9:1568x672 |
1:1:1536x15364:3:1792x13443:4:1344x179216:9:2048x11529:16:1152x20483:2:1872x12482:3:1248x187221:9:2352x1008 |
1:1:2048x20484:3:2368x17763:4:1776x236816:9:2816x15849:16:1584x28163:2:2496x16642:3:1664x249621:9:3136x1344 |
— | — |
| Seedream 5.0 lite | — | — | 1:1:2048x20484:3:2304x17283:4:1728x230416:9:2848x16009:16:1600x28483:2:2496x16642:3:1664x249621:9:3136x1344 |
1:1:3072x30724:3:3456x25923:4:2592x345616:9:4096x23049:16:2304x40963:2:3744x24962:3:2496x374421:9:4704x2016 |
1:1:4096x40964:3:4704x35203:4:3520x470416:9:5504x30409:16:3040x55043:2:4992x33282:3:3328x499221:9:6240x2656 |
| Seedream 4.5 | — | — | 1:1:2048x20484:3:2304x17283:4:1728x230416:9:2848x16009:16:1600x28483:2:2496x16642:3:1664x249621:9:3136x1344 |
— | 1:1:4096x40964:3:4704x35203:4:3520x470416:9:5504x30409:16:3040x55043:2:4992x33282:3:3328x499221:9:6240x2656 |
| Seedream 4.0 | 1:1:1024x10244:3:1152x8643:4:864x115216:9:1312x7369:16:736x13123:2:1248x8322:3:832x124821:9:1568x672 |
— | 1:1:2048x20484:3:2304x17283:4:1728x230416:9:2848x16009:16:1600x28483:2:2496x16642:3:1664x249621:9:3136x1344 |
— | 1:1:4096x40964:3:4704x35203:4:3520x470416:9:5504x30409:16:3040x55043:2:4992x33282:3:3328x499221:9:6240x2656 |
方式 2:指定宽高像素值(宽x高)
各模型参数约束:
| Seedream 5.0 pro | Seedream 5.0 lite | Seedream 4.5 | Seedream 4.0 | |
|---|---|---|---|---|
| 总像素取值范围 | [1280x720(921600), 2048x2048x1.1025(4624220)] |
[2560x1440(3686400), 4096x4096(16777216)] |
[2560x1440(3686400), 4096x4096(16777216)] |
[1280x720(921600), 4096x4096(16777216)] |
| 宽高比范围 | [1/16, 16] | [1/16, 16] | [1/16, 16] | [1/16, 16] |
| 方式1 | 方式2 |
|---|---|
|
|
图层拆分场景
仅支持通过指定分辨率档位的方式设置。输出图的分辨率规则如下:
- 底图:输出底图的分辨率和
size指定的分辨率一致;输出底图和原待拆分图的宽高比一致。 - 各图层:输出图层的分辨率和
size指定的分辨率接近;每个输出图层和其在原图中的宽高比一致。
size 的默认值与可选值:
- 默认值:
auto - 可选值:
1K、1.5K、2K、auto(根据输入图的尺寸和宽高比进行输出)
图像输出方式#
通过设置 response_format 参数,可以指定生成图像的返回方式:
-
url:返回图片下载链接。 -
b64_json:以 Base64 编码字符串的 JSON 格式返回图像数据。{ "response_format": "url" }
图像文件格式#
Seedream 4.5/4.0 生成的图像格式默认为 jpeg,不支持自定义设置。
Seedream 5.0 pro / 5.0 lite 可通过设置 output_format 参数,指定生成图像文件的格式:
pngjpeg
{
"output_format": "png"
}
图像中添加水印#
通过设置 watermark 参数,来控制是否在生成的图片中添加水印。
false:不添加水印。true:在图片右下角添加“AI生成”字样的水印标识。
{
"watermark": true
}
使用限制#
SDK 版本升级
为保证模型功能的正常使用,请务必升级至最新 SDK 版本。相关步骤可参考 安装及升级 SDK。
图片传入限制
图片传入方式(两种场景通用):
-
图片 URL:请确保图片 URL 可被访问。
示例:
https://arkdocs.tos-cn-beijing.volces.com/images/image-generation/seedream4_5_imageToimage.png -
Base64 编码:请遵循格式
data:image/<图片格式>;base64,<Base64编码>。注意:<图片格式>必须采用小写字母,例如data:image/png;base64,<base64_image>。如需获得图片的 Base64 编码,可使用第三方工具,例如 https://base64.guru/converter/encode/image。
不同场景对输入图的约束不同,详见下表:
| 约束项 | 图片生成场景 | 图层拆分场景 |
|---|---|---|
| 图片格式 | jpeg、png、webp、bmp、tiff、gif、heic、heif | png、jpeg |
| 总像素(宽×高) | [196, 6000×6000(3600万)] |
[512×512(262144), 6000×6000(3600万)] |
| 宽高长度(px) | 大于14 | — |
| 宽高比(宽/高) | [1/16, 16] | [1/16, 16] |
| 大小 | 不超过 30 MB | 不超过 30 MB |
| 传入张数 | Seedream 5.0 pro / flash,最多 10 张;Seedream 5.0 lite / 4.5 / 4.0,最多 14 张 | 仅支持单张图片 |
保存时间
图片URL仅保留24小时,超时后会被自动清除。请您务必及时保存生成的图片。
推荐配置火山引擎 TOS 提供的数据订阅功能,将您的模型推理产物自动转存到自己的 TOS 桶中,便于长期备份或二次加工。详细介绍请参见 TOS 数据订阅。
限流说明
- IPM 限流:账号下同模型(区分模型版本)每分钟生成图片数量上限。若超过该限制,生成图片时会报错。
- 图层拆分场景下,每次请求预扣减 17 IPM(按最多输出 1 张底图和 16 张图层预留配额);全部图片生成后,按实际生成数量返还多扣减的额度。
- 不同模型的限制值不同,详见 图片生成能力。
附:故事书/连环画制作#
火山方舟大模型体验中心 提供了故事书和连环画功能,该功能结合了 Doubao Seed 2.1 Lite 模型和 Seedream 4.0 模型,可实现一句话生成动漫、连环画、故事书,满足用户多样化的创作需求。
连环画的实现过程与故事书类似,本文以故事书为例,为您介绍生成故事书的工作流和技术实现步骤,方便您在本地快速复现。
工作流#
故事书生成的工作流如下:
技术实现#
- 根据用户提供的提示词和参考图,调用 doubao-seed-2.1-lite 模型,进行故事创作 > 故事分镜拆解 > 生成分镜的文案和画面描述 > 生成书名 > 生成故事总结,并汇总成 JSON 格式输出。
System Prompt 如下:
# 角色
你是一位**绘本创作大师**。
## 任务
贴合用户指定的**读者群(儿童/青少年/成人/全年龄)**,创作**情节线性连贯的、生动有趣的、充满情绪价值和温度的、有情感共鸣的、分镜-文案-画面严格顺序对应的绘本内容**:
- 核心约束:**分镜拆分→文案(scenes)→画面描述(scenes_detail)必须1:1顺序绑定**,从故事开头到结尾,像「放电影」一样按时间线推进,绝无错位。
## 工作流程
1. 充分理解用户诉求。 优先按照用户的创作细节要求执行(如果有)
2. **故事构思:** 创作一个能够精准回应用户诉求、提供情感慰藉的故事脉络。整个故事必须围绕“共情”和“情绪价值”展开。
3. **分镜结构与数量:**
* 将故事浓缩成 **5~10** 个关键分镜,最多10个(不能超过10个)。
* 必须遵循清晰的叙事弧线:开端 → 发展 → 高潮 → 结局。
4. **文案与画面 (一一对应):**
* **文案 ("scenes"字段):** 为每个分镜创作具备情感穿透力的文案。文案必须与画面描述紧密贴合,共同服务于情绪的传递。**禁止在文案中使用任何英文引号 ("")**。不能超过10个。
* **画面 ("scenes_detail"字段):** 为每个分镜构思详细的画面。画风必须贴合用户诉求和故事氛围。描述需包含构图、光影、色彩、角色神态等关键视觉要素,达到可直接用于图片生成的标准。
5. **书名 ("title"字段):**
* 构思一个简洁、好记、有创意的书名。
* 书名必须能巧妙地概括故事精髓,并能瞬间“戳中”目标用户的情绪共鸣点。
6. **故事总结 ("summary"字段):**
* 创作一句**不超过30个汉字**的总结。
* 总结需高度凝练故事的核心思想与情感价值。
7. 整合输出:将所有内容按指定 JSON 格式整理输出。
## 安全限制
生成的内容必须严格遵守以下规定:
1. **禁止暴力与血腥:** 不得包含任何详细的暴力、伤害、血腥或令人不适的画面描述。
2. **禁止色情内容:** 不得包含任何色情、性暗示或不适宜的裸露内容。
3. **禁止仇恨与歧视:** 不得包含针对任何群体(基于种族、宗教、性别、性取向等)的仇恨、歧视或攻击性言论。
4. **禁止违法与危险行为:** 不得描绘或鼓励任何非法活动、自残或危险行为。
5. **确保普遍适宜性:** 整体内容应保持在社会普遍接受的艺术创作范围内,避免极端争议性话题。
## 输出格式要求
整理成以下JSON格式,scenes 和 scenes_detail 要与分镜保持顺序一致,一一对应,最多10个(不能超过10个):
{
"title": "书名",
"summary": "30字内的总结",
"scenes": [
"分镜1的文案,用50字篇幅传递情绪和情感,引发读者共鸣,语言风格需符合设定。",
"分镜2的文案"
],
"scenes_detail": [
"图片1:这是第一页的画面描述。必须以'图片'+序号开头。要有强烈的视觉感,详细描述构图(如特写、远景)、光影、色彩、角色表情、动作和环境细节,符合生图提示词的要求。",
"图片2:"
]
}
-
提取返回结果 JSON 中的 scenes_detail 字段,作为图片生成的 Prompt 。
-
处理图片生成的 Prompt:
-
将数组转化成字符串
-
在 prompt 末尾补充"最后,为故事书创作一个封面。 再检查所有图片,去除图片中的文字"。
-
在 prompt 开头添加用户输入的提示词。
-
-
根据图片生成的 Prompt 和用户提供的参考图,调用 doubao-seedream-4.0 模型的生成组图能力,为故事的所有分镜文案生成配图。
-
按照顺序拼装图片和文字即可得到故事书内容 ,用户按需进行展示即可。




