建立 Seedream 圖像
使用 CometAPI 的 POST /v1/images/generations 來執行 Seedream 圖像生成,支援文字 Prompt、參考圖像、序列式圖像輸出與非同步任務。
POST /v1/images/generations 路由來執行 Seedream 圖像生成。當所選 model 支援這些控制項時,此端點支援文字轉圖像 Prompt、參考圖像請求,以及具上限的序列式圖像輸出。
本頁涵蓋用於 Pro 文字轉圖像請求的 seedream-5-0-pro-260628,以及用於 Seedream 5.0 參考圖像、序列式與非同步範例的 seedream-5-0-260128。如需確認帳戶可用性,請參閱模型頁面或查詢 /v1/models。如需 provider 參數詳細資訊,請參閱 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 而異,因此在提交非同步任務前,請先選擇該 model 支援的尺寸。
傳送參考圖像
對於內嵌圖像資料,請使用data:image/png;base64,YOUR_BASE64_IMAGE,或使用 provider 可擷取的公開 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