Tạo hình ảnh với Kling
Tạo hình ảnh với Kling qua CometAPI: POST /kling/v1/images/generations hỗ trợ tạo hình ảnh từ prompt và tạo hình ảnh bằng ảnh tham chiếu.
Tạo hình ảnh
Yêu cầu đầu tiên
Bắt đầu vớimodel_name: kling-v3, prompt, n và aspect_ratio. Chỉ thêm ảnh tham chiếu, các thiết lập độ trung thực hoặc các trường nâng cao sau khi yêu cầu đầu tiên trả về một tác vụ có thể sử dụng được. Nếu bỏ qua model_name, hệ thống sẽ dùng một giá trị mặc định tương thích cũ, vì vậy hãy gửi rõ ràng kling-v3 cho các tích hợp mới.
Đọc phản hồi
Lưutask_id được trả về, sau đó poll route truy vấn hình ảnh Kling tương ứng cho đến khi task_status đạt trạng thái kết thúc. Nếu quy trình của bạn cần lưu trữ bền vững, hãy sao chép asset cuối cùng vào lớp lưu trữ của riêng bạn sau khi quá trình tạo hoàn tất.Ủy quyền
Bearer token authentication. Use your CometAPI key.
Tiêu đề
Must be application/json.
Nội dung
Text prompt describing the image to generate. Maximum 2500 characters.
Kling image model variant. Use kling-v3 for new requests. Omitting model_name uses the legacy CometAPI route default.
kling-v1, kling-v1-5, kling-v2, kling-v2-1, kling-v3 Elements to exclude from the image. Maximum 2500 characters. Not supported when image is provided.
Reference image as a raw Base64 string without a data: prefix, or a public URL. Accepted formats: JPG, JPEG, PNG. Maximum 10 MB, minimum 300x300 px, aspect ratio between 1:2.5 and 2.5:1.
Reference mode for legacy image-to-image requests when image is provided.
subject, face How closely the output follows the reference image. Range: 0-1. Used by legacy image-reference models.
0 <= x <= 1Human-subject fidelity control. Range: 0-1. Used only by legacy subject-reference requests.
0 <= x <= 1Optional Kling element references. The total count of element references and input images must not exceed 10.
Output resolution. Defaults to 1k.
1k, 2k Number of images to generate. Range: 1-9.
1 <= x <= 9Output aspect ratio (width:height).
16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9 Watermark options.
Webhook URL to receive task status updates when the task completes.
Optional user-defined task ID for your own tracking. Must be unique per account.