建立 Kling 文字轉影片任務
透過 CometAPI POST /kling/v1/videos/text2video 使用 Kling 從文字 Prompt 生成影片,然後依 task ID 追蹤任務狀態並取得結果。
第一個可運作的請求
- 先傳送簡短的 Prompt
- 先從
kling-v3範例開始,之後在需要不同模型路線時,再從 OpenAPI enum 中選擇其他model_name - 只有在基本流程可正常運作後,再加入
aspect_ratio、duration、mode或sound - 如果你想使用推送交付而非純輪詢,請設定
callback_url - 當你希望第一次請求是可預測的無音訊結果,且模型支援生成音效時,請使用
sound: off
模型命名
在這個端點上請使用一般的 Kling 影片 model ID。Omni 模型的 model ID 請保留給 Omni Video。時長與長寬比
size 欄位。請求的長寬比會控制輸出影格的形狀。
任務流程
提交生成請求
輪詢任務狀態
保存結果
授權
Bearer token authentication. Use your CometAPI key.
標頭
Must be application/json.
主體
Text prompt describing the video to generate. Maximum 500 characters.
Elements to exclude from the video. Maximum 200 characters.
Aspect ratio request. Typical rendered sizes are 1280x720 for 16:9, 720x1280 for 9:16, and 960x960 for 1:1. This endpoint does not expose an exact size field.
16:9, 9:16, 1:1 Webhook URL to receive task status updates when the task completes.
Model ID for this text-to-video request. Use an ordinary Kling video model ID; use Omni model IDs only with the Omni Video endpoint.
kling-v1, kling-v1-6, kling-v2-master, kling-v2-1-master, kling-v2-5-turbo, kling-v2-6, kling-v3 Prompt adherence strength. Higher values follow the prompt more closely. Range: 0–1.
Generation mode. std for standard (faster), pro for professional (higher quality). The default is std.
std, pro Output video length in seconds. Use 5 or 10; omit to use 5.
Camera motion preset or manual configuration. Omit for automatic camera movement.
Custom task id for your own tracking. Does not replace the system-generated task id but can be used to query tasks. Must be unique per user.
Optional generated-audio switch for models that support video sound. Use on or off, or omit the field for the model default.
on, off