Skip to content

Doubao Seedream 4.0 图像生成

字节跳动 Doubao Seedream 4.0 模型,支持 1K/2K/4K 多分辨率生图、组图模式和参考图输入,在中文字体和东方美学方面有出色表现。

快速开始

python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="doubao-seedream-4.0",
    prompt="一只橘猫坐在窗台上看雪景,水彩风格",
    size="4096x4096",
    n=1
)

print(response.data[0].url)

请求端点

项目
方法POST
路径/v1/images/generations
Base URLhttps://open.dieyuyun.com
兼容协议OpenAI Images API

认证

Bearer Token: Authorization: Bearer YOUR_API_KEY

标准请求字段

字段类型必填默认值说明
modelstring模型标识: doubao-seedream-4.0
promptstring图像描述文本,支持中英文,建议不超过300个汉字
sizestring4096x4096图像尺寸(宽高像素值)
ninteger1生成数量,>1 时启用组图模式
response_formatstringurl返回格式: urlb64_json

支持的尺寸

以下为各分辨率档位推荐的像素值:

1K 分辨率

尺寸比例
1024x10241:1
1152x8644:3
864x11523:4
1312x73616:9
736x13129:16
1248x8323:2
832x12482:3
1568x67221:9

2K 分辨率

尺寸比例
2048x20481:1
2304x17284:3
1728x23043:4
2848x160016:9
1600x28489:16
2496x16643:2
1664x24962:3
3136x134421:9

4K 分辨率(默认)

尺寸比例
4096x40961:1
4704x35204:3
3520x47043:4
5504x304016:9
3040x55049:16
4992x33283:2
3328x49922:3
6240x265621:9

扩展参数

字段类型必填默认值说明
imagestring/array参考图片 URL 或 Base64,最多14张
watermarkbooleanfalse是否添加 AI 生成水印
sequential_image_generationstringdisabledauto 组图模式 / disabled 单图

请求示例

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-4.0",
    "prompt": "一只橘猫坐在窗台上看雪景,水彩风格",
    "size": "4096x4096",
    "n": 1
  }'
python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="doubao-seedream-4.0",
    prompt="一只橘猫坐在窗台上看雪景,水彩风格",
    size="4096x4096",
    n=1
)

print(response.data[0].url)
javascript
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://open.dieyuyun.com/v1',
  apiKey: 'YOUR_API_KEY',
})

const response = await client.images.generate({
  model: 'doubao-seedream-4.0',
  prompt: '一只橘猫坐在窗台上看雪景,水彩风格',
  size: '4096x4096',
  n: 1,
})

console.log(response.data[0].url)

响应格式

成功响应

json
{
  "created": 1717000000,
  "model": "doubao-seedream-4.0",
  "data": [
    {
      "url": "https://...",
      "size": "2048x2048"
    }
  ],
  "usage": {
    "generated_images": 1,
    "output_tokens": 16384,
    "total_tokens": 16384
  }
}
字段类型说明
createdintegerUnix 时间戳(秒)
modelstring模型 ID
dataarray生成结果数组
data[].urlstring图像 URL(24小时有效)
data[].b64_jsonstringBase64 编码图像
data[].sizestring图像宽高像素值
usageobject用量信息
usage.generated_imagesinteger成功生成图片张数
usage.output_tokensinteger输出 token 数
usage.total_tokensinteger总 token 数

错误响应

详见 错误码

最佳实践

  • 中文提示词: Doubao Seedream 4.0 对中文提示词有优秀的理解能力,可以直接用中文描述图像内容,在中文字体和东方美学方面表现尤为出色。
  • 风格指定: 在提示词中加入明确的风格描述(如"水彩风格"、"油画风格"、"赛博朋克"等)可获得更精准的效果。
  • 多语言支持: 同时支持中英文提示词,建议不超过300个汉字以获得最佳效果。
  • 参考图输入: 通过 image 字段传入参考图片,可引导模型生成风格一致的图像,最多支持14张参考图。
  • 组图模式: 将 n 设为大于1或设置 sequential_image_generationauto,可一次生成多张风格统一的图像。
  • 多分辨率选择: 使用 1K 分辨率像素值快速预览,2K 用于中等精度场景,4096x4096 作为默认输出质量。

速率限制

详见 速率限制

相关文档