Tạo ảnh Seedream
Sử dụng CometAPI POST /v1/images/generations để tạo ảnh Seedream với Prompt văn bản, ảnh tham chiếu, đầu ra ảnh tuần tự và tác vụ async.
POST /v1/images/generations tương thích OpenAI của CometAPI để chạy tác vụ tạo ảnh Seedream. Endpoint này hỗ trợ Prompt văn bản sang ảnh, yêu cầu dùng ảnh tham chiếu, và đầu ra ảnh tuần tự có giới hạn khi model được chọn hỗ trợ các tùy chọn đó.
Trang này đề cập đến seedream-5-0-pro-260628 cho các yêu cầu Pro text-to-image và seedream-5-0-260128 cho các ví dụ Seedream 5.0 về ảnh tham chiếu, tuần tự và async. Để biết khả năng khả dụng trên tài khoản, xem trang Models hoặc truy vấn /v1/models. Để biết chi tiết tham số của nhà cung cấp, xem image generation API và hướng dẫn Seedream 4.0-5.0 của BytePlus.
Chọn dạng yêu cầu
- Text to image: gửi
model,prompt,sizevà các tùy chọn điều khiển đầu ra không bắt buộc nhưresponse_format,output_formatvàwatermark. - Image to image: thêm
imagedưới dạng một mảng URL HTTPS công khai hoặc data URI. Hãy dùng mảng ngay cả khi bạn chỉ gửi một ảnh tham chiếu. - Sequential prompt: đặt
sequential_image_generationthànhautovà dùngsequential_image_generation_options.max_imageslàm giới hạn trên. Model có thể trả về ít ảnh hơn số lượng tối đa. - Async task: thêm
async: truekhi bạn muốn yêu cầu tạo trả vềdata.task_idthay vì giữ kết nối HTTP mở.
max_images.Chạy một tác vụ ảnh async
Đặtasync thành true cho các job ảnh mà client của bạn nên gửi và poll. Yêu cầu tạo sẽ trả về data.task_id; dùng giá trị đó với Truy xuất một tác vụ ảnh Seedream cho đến khi data.status là success hoặc failure.
Sử dụng 2K trong các ví dụ async cho yêu cầu Seedream 5.0. Khả năng hỗ trợ kích thước khác nhau tùy theo model ID, vì vậy hãy chọn kích thước được model hỗ trợ trước khi gửi một tác vụ async.
Gửi ảnh tham chiếu
Dùngdata:image/png;base64,YOUR_BASE64_IMAGE cho dữ liệu ảnh nội tuyến, hoặc dùng một URL HTTPS công khai mà nhà cung cấp có thể truy xuất. Các ví dụ trong tài liệu tham khảo API hiển thị đầy đủ cấu trúc JSON cho từng loại yêu cầu.
Đọc URL đầu ra
Ủy quyền
Bearer token authentication. Use your CometAPI key.
Nội dung
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.
Phản hồi
Image generation response. Synchronous requests return completed image data. Async requests return a task response with data.task_id.
- Option 1
- Async task response