创建 Seedream 图像
使用 CometAPI 的 POST /v1/images/generations 为 Seedream 进行图像生成,支持文本 Prompt、参考图像、顺序图像输出和异步任务。
POST /v1/images/generations 路由来运行 Seedream 图像生成。该端点支持文生图 Prompt、参考图像请求,以及在所选模型支持这些控制项时的有界顺序图像输出。
本页涵盖用于 Pro 文生图请求的 seedream-5-0-pro-260628,以及用于 Seedream 5.0 参考图像、顺序和异步示例的 seedream-5-0-260128。关于账户可用性,请参阅模型页面或查询 /v1/models。关于提供商参数的详细信息,请参阅 BytePlus 的图像生成 API和Seedream 4.0-5.0 教程。
选择请求形式
- 文生图:发送
model、prompt、size,以及可选的输出控制项,例如response_format、output_format和watermark。 - 图生图:添加
image,其值为公共 HTTPS URL 或 data URI 组成的数组。即使只发送一张参考图像,也要使用数组。 - 顺序 Prompt:将
sequential_image_generation设置为auto,并使用sequential_image_generation_options.max_images作为上限。模型返回的图像数量可能少于最大值。 - 异步任务:当你希望创建请求返回
data.task_id而不是保持 HTTP 连接打开时,添加async: true。
max_images 为顺序请求设置上限。运行异步图像任务
对于需要由客户端提交并轮询的图像任务,将async 设置为 true。创建请求会返回 data.task_id;将该值与检索 Seedream 图像任务一起使用,直到 data.status 变为 success 或 failure。
在异步示例中,对 Seedream 5.0 请求使用 2K。不同 model ID 支持的尺寸各不相同,因此在提交异步任务前,请先选择模型支持的尺寸。
发送参考图像
对于内联图像数据,请使用data:image/png;base64,YOUR_BASE64_IMAGE,或者使用提供商可抓取的公共 HTTPS URL。API 参考示例展示了每种请求类型的完整 JSON 结构。
读取输出 URL
授权
Bearer token authentication. Use your CometAPI key.
请求体
Parameters for Seedream image generation. Send JSON for text-to-image, image-to-image, and sequential prompt requests.
Seedream model ID to use. Query /v1/models or open the Models page for available model IDs.
Text prompt describing the image or edit goal. Use a concrete visual request, such as a blue ceramic mug on a white table, soft studio lighting.
Response image format. Use url for a temporary signed image URL, or b64_json when you need base64 image data in the response.
url, b64_json Output resolution. Use a model-supported tier such as 2K or a model-supported WIDTHxHEIGHT value such as 2048x2048. Not every model ID accepts every tier.
Optional reference images for image-to-image generation. Each item can be a public HTTPS URL or a data URI such as data:image/png;base64,YOUR_BASE64_IMAGE. Use an array even for one image. Reference images plus generated images must not exceed the provider limit.
When true, requests a visible AI-generated watermark on the output image. Set false when your workflow handles disclosure separately.
CometAPI asynchronous task mode. Set this to true to return immediately with data.task_id, then poll the Seedream image task endpoint GET /v1/images/generations/{task_id} for the final image data.
Output image file format. Use png when you need lossless output, or jpeg for smaller files.
png, jpeg Optional prompt-adherence control for model versions that support it. Higher values can follow the prompt more closely but may reduce naturalness. Omit this field when you do not need model-specific tuning.
1 <= x <= 10Optional random seed for reproducible attempts on model versions that support seeding. Use -1 or omit the field for a random seed.
-1 <= x <= 2147483647Controls sequential prompt handling. Use auto to let the model return a sequence when the prompt calls for one. Use disabled for ordinary single-image requests.
auto, disabled Options for sequential prompt handling. This object is only used when sequential_image_generation is auto.
响应
Image generation response. Synchronous requests return completed image data. Async requests return a task response with data.task_id.
- Option 1
- Async task response