Skip to main content
POST
Sử dụng route 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 APIhướ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, size và các tùy chọn điều khiển đầu ra không bắt buộc như response_format, output_formatwatermark.
  • Image to image: thêm image dướ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_generation thành auto và dùng sequential_image_generation_options.max_images là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: true khi bạn muốn yêu cầu tạo trả về data.task_id thay vì giữ kết nối HTTP mở.
Ảnh tham chiếu cộng với ảnh được tạo phải nằm trong giới hạn của nhà cung cấp. Hãy giới hạn các yêu cầu tuần tự bằng max_images.

Chạy một tác vụ ảnh async

Đặt async 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.statussuccess 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ùng data: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

url được trả về là một liên kết object storage có chữ ký và có thể chứa &, % và các ký tự đặc biệt khác. Hãy lấy URL từ JSON đã được parse thay vì sao chép một phần dòng trong terminal. Trong các ví dụ shell, jq -r '.data[]?.url' giữ nguyên đầy đủ URL có chữ ký.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Nội dung

application/json

Parameters for Seedream image generation. Send JSON for text-to-image, image-to-image, and sequential prompt requests.

model
string
mặc định:seedream-5-0-pro-260628
bắt buộc

Seedream model ID to use. Query /v1/models or open the Models page for available model IDs.

prompt
string
mặc định:A clean product-style render of a blue ceramic mug on a white table, soft studio lighting.
bắt buộc

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_format
enum<string>
mặc định:url

Response image format. Use url for a temporary signed image URL, or b64_json when you need base64 image data in the response.

Tùy chọn có sẵn:
url,
b64_json
size
string
mặc định:2K

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.

image
string[]

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.

watermark
boolean
mặc định:false

When true, requests a visible AI-generated watermark on the output image. Set false when your workflow handles disclosure separately.

async
boolean
mặc định:false

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_format
enum<string>
mặc định:png

Output image file format. Use png when you need lossless output, or jpeg for smaller files.

Tùy chọn có sẵn:
png,
jpeg
guidance_scale
number

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.

Phạm vi bắt buộc: 1 <= x <= 10
seed
integer
mặc định:-1

Optional random seed for reproducible attempts on model versions that support seeding. Use -1 or omit the field for a random seed.

Phạm vi bắt buộc: -1 <= x <= 2147483647
sequential_image_generation
enum<string>
mặc định:disabled

Controls 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.

Tùy chọn có sẵn:
auto,
disabled
sequential_image_generation_options
object

Options for sequential prompt handling. This object is only used when sequential_image_generation is auto.

Phản hồi

200 - application/json

Image generation response. Synchronous requests return completed image data. Async requests return a task response with data.task_id.

created
integer
bắt buộc

Unix timestamp in seconds when the image response was created.

data
object[]
bắt buộc

Generated image results. The array can contain one or more images depending on the request and model response.

usage
object

Usage information for the request. Fields vary by model and route.