Skip to main content
POST
cURL
Sử dụng endpoint này để tạo một tác vụ Kling Omni Image bất đồng bộ thông qua CometAPI. Yêu cầu tạo sẽ trả về một task_id; dùng Lấy một tác vụ hình ảnh Kling Omni để thăm dò tác vụ cho đến khi các URL hình ảnh được tạo sẵn sàng.
Để xem tham chiếu tham số đầy đủ của nhà cung cấp, hãy xem tài liệu Kling Image O1.

Chọn dạng yêu cầu

  • Tạo một hình ảnh: gửi prompt, image_list, resolution, result_type: single, n, và aspect_ratio
  • Đầu ra có watermark: thêm watermark_info.enabled: true khi bạn cần URL kết quả có watermark trong phản hồi truy vấn
  • Model ID: bỏ qua model_name để dùng mặc định của route, hoặc gửi một model ID Omni Image đã được kiểm thử như kling-image-o1 hoặc kling-v3-omni
Hình ảnh tham chiếu sử dụng các phần tử image_list với trường image. Prompt có thể tham chiếu chúng theo chỉ mục, chẳng hạn <<<image_1>>> cho phần tử đầu tiên và <<<image_2>>> cho phần tử thứ hai.

Luồng tác vụ

1

Tạo tác vụ

Gửi POST /kling/v1/images/omni-image và lưu data.task_id được trả về.
2

Truy vấn tác vụ

Thăm dò GET /kling/v1/images/omni-image/ cho đến khi data.task_statussucceed hoặc failed.
3

Lưu trữ hình ảnh

Khi tác vụ thành công, sao chép data.task_result.images[].url vào hệ thống lưu trữ của riêng bạn nếu bạn cần quyền truy cập bền vững.
Để xem schema phản hồi đầy đủ và ví dụ thăm dò, hãy xem Lấy một tác vụ hình ảnh Kling Omni. Ví dụ ngắn sau đây thăm dò một tác vụ cho đến khi nó đạt trạng thái kết thúc:

Các trường kết quả

Phản hồi truy vấn thành công trả về các hình ảnh đã tạo trong data.task_result.images. Mỗi phần tử có thể bao gồm: URL của tài nguyên được tạo có thể hết hạn hoặc bị dịch vụ nhà cung cấp xóa. Hãy lưu các hình ảnh hoàn chỉnh vào lớp lưu trữ của riêng bạn khi quy trình làm việc của bạn cần lưu giữ lâu dài.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI API key.

Tiêu đề

Content-Type
string

Must be application/json.

Nội dung

application/json
prompt
string
bắt buộc

Text prompt for the generated image. The prompt can reference images with <<<image_1>>>, <<<image_2>>>, and matching indexes from image_list. Maximum length is 2,500 characters.

model_name
string

Optional model ID for this Omni Image request. Omit this field to use the route default.

image_list
object[]

Reference images that the prompt can cite with <<<image_1>>>, <<<image_2>>>, and so on. Keep the total number of reference images within the provider limits for the selected model.

resolution
enum<string>
mặc định:1k

Requested output resolution. Use 1k, 2k, or 4k; omitted requests use 1k.

Tùy chọn có sẵn:
1k,
2k,
4k
result_type
enum<string>
mặc định:single

Use single for a single-image task.

Tùy chọn có sẵn:
single
n
integer
mặc định:1

Number of single-image results to generate. Range: 1 to 9.

Phạm vi bắt buộc: 1 <= x <= 9
aspect_ratio
enum<string>
mặc định:auto

Requested output aspect ratio in width:height format. Use auto to let the provider choose from the prompt and references.

Tùy chọn có sẵn:
16:9,
9:16,
1:1,
4:3,
3:4,
3:2,
2:3,
21:9,
auto
watermark_info
object

Watermark options. When enabled is true, the task can return watermarked result URLs in addition to the original result URLs.

callback_url
string<uri>

Webhook URL that receives task status notifications when the task status changes. Omit this field to poll manually.

external_task_id
string

User-defined task ID for your own tracking. It does not replace the system-generated task_id and must be unique per account.

Phản hồi

200 - application/json

Task accepted.

code
integer
bắt buộc

Response code. 0 means the task request was accepted.

message
string
bắt buộc

Response message.

data
object
bắt buộc
request_id
string

Request identifier returned by CometAPI when present.