跳转到主要内容
Seedream 4.0 原生支持文本、单图和多图输入,实现基于主体一致性的多图融合创作、图像编辑、组图生成等多样玩法,让图像创作更加自由可控。本文介绍如何通过API 调用Seedream 4.0模型,实现包括组图生成、多参考图生图等图片生成能力。

模型参数

不支持画图公共 API 中的以下参数:
  • negative_prompt
  • seed
  • strength
  • aspect_ratio
  • quality
  • style_preset
  • output_format
  • mask
  • background
Doubao-Seedream-4.0 不支持设置图片宽高比及分辨率,如需设置可以通过 size 字段实现,该字段支持两种方式传值:
  • 指定生成图像的分辨率:1K2K4K,然后在 prompt 中通过自然语言描述生成图片宽高比
  • 指定生成图像的宽高像素值,默认值是 2048x2048,对应宽高比为 1:1,此外还可以通过如下像素值生成不同宽高比的图片:
宽高比像素值
1:12048x2048
4:32304x1728
3:41728x2304
16:92560x1440
9:161440x2560
3:22496x1664
2:31664x2496
21:93024x1296
宽高像素值的取值范围为 [1280x720, 4096x4096]

文生图

通过文字描述来生成对应图像:
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"doubao-seedream-4.0",
    "prompt":"画一只可爱的小猫在草丛中玩耍"
    "size": "1K"
}'

图生图

单图 基于已有图片,结合文字指令进行图像编辑,生成新的图像:
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"doubao-seedream-4.0",
    "prompt": "生成狗狗趴在草地上的近景画面",
    "image": "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imageToimage.png",
    "size": "2K"
}'
多图 基于多张参考图片,融合它们的风格、元素等特征来生成新图像,如衣裤鞋帽与模特图融合成穿搭图,人物与风景融合为人物风景图等:
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"doubao-seedream-4.0",
    "prompt": "将图1的服装换为图2的服装",
    "image": [
        "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png", 
        "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_2.png"
    ],
    "size": "2K"
}'

组图生成

支持通过一张或者多张图片和文字信息,生成漫画分镜、品牌视觉等一组内容关联的图片:
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"doubao-seedream-4.0",
    "prompt": "生成一组共4张连贯插画,核心为同一庭院一角的四季变迁,以统一风格展现四季独特色彩、元素与氛围",
    "size": "2K",
    "response_format": "url",
    "watermark": true,
    "extra_body": {
        "sequential_image_generation": "auto",
        "sequential_image_generation_options": {
            "max_images": 4
        }
    }
}'
I