Skip to main content
POST
cURL

إنشاء الصور

للاطلاع على المرجع الكامل للمعلمات، راجع توثيق Kling الرسمي.
استخدم نقطة النهاية هذه لإنشاء صور ثابتة من خلال واجهة برمجة تطبيقات إنشاء الصور في Kling. وهي تدعم الطلبات النصية فقط والطلبات المعتمدة على الصور المرجعية عبر نفس تدفق المهام غير المتزامن.

الطلب الأول

ابدأ باستخدام model_name: kling-v3 وprompt وn وaspect_ratio. أضف الصور المرجعية أو عناصر التحكم في fidelity أو الحقول المتقدمة فقط بعد أن يعيد الطلب الأول مهمة قابلة للاستخدام. يؤدي حذف model_name إلى استخدام إعداد افتراضي قديم للتوافق، لذا أرسل kling-v3 صراحةً في عمليات التكامل الجديدة.

قراءة الاستجابة

احفظ task_id المُعاد، ثم أجرِ poll لمسار استعلام صور Kling المطابق حتى تصل task_status إلى حالة نهائية. إذا كان سير العمل لديك يحتاج إلى تخزين دائم، فانقل الأصل النهائي إلى طبقة التخزين الخاصة بك بعد اكتمال الإنشاء.

التفويضات

Authorization
string
header
مطلوب

Bearer token authentication. Use your CometAPI key.

الترويسات

Content-Type
string
افتراضي:application/json

Must be application/json.

الجسم

application/json
prompt
string
مطلوب

Text prompt describing the image to generate. Maximum 2500 characters.

model_name
enum<string>
افتراضي:kling-v1

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
negative_prompt
string

Elements to exclude from the image. Maximum 2500 characters. Not supported when image is provided.

image
string

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.

image_reference
enum<string>

Reference mode for legacy image-to-image requests when image is provided.

الخيارات المتاحة:
subject,
face
image_fidelity
number
افتراضي:0.5

How closely the output follows the reference image. Range: 0-1. Used by legacy image-reference models.

النطاق المطلوب: 0 <= x <= 1
human_fidelity
number
افتراضي:0.45

Human-subject fidelity control. Range: 0-1. Used only by legacy subject-reference requests.

النطاق المطلوب: 0 <= x <= 1
element_list
object[]

Optional Kling element references. The total count of element references and input images must not exceed 10.

resolution
enum<string>
افتراضي:1k

Output resolution. Defaults to 1k.

الخيارات المتاحة:
1k,
2k
n
integer
افتراضي:1

Number of images to generate. Range: 1-9.

النطاق المطلوب: 1 <= x <= 9
aspect_ratio
enum<string>
افتراضي:16:9

Output aspect ratio (width:height).

الخيارات المتاحة:
16:9,
9:16,
1:1,
4:3,
3:4,
3:2,
2:3,
21:9
watermark_info
object

Watermark options.

callback_url
string

Webhook URL to receive task status updates when the task completes.

external_task_id
string

Optional user-defined task ID for your own tracking. Must be unique per account.

الاستجابة

200 - application/json

Task request accepted or an error response returned by the API.

code
مطلوب

Response code. 0 means the task request was accepted.

message
string
مطلوب

Response message.

data
object
مطلوب
request_id
string

Request identifier returned when present.