Kling のテキストから動画へのタスクを作成する
CometAPI の POST /kling/v1/videos/text2video を使用して、Kling でテキストプロンプトから動画を生成し、その後 task ID でタスク状態を追跡して結果を取得します。
最初に動かすリクエスト
- まずは短いプロンプトを送信します
- 最初は
kling-v3の例から始め、別のモデル系統が必要になったら OpenAPI の enum から別のmodel_nameを選択します - 基本のフローが動作してから
aspect_ratio、duration、mode、soundを追加します - 純粋なポーリングではなくプッシュ配信を使いたい場合は
callback_urlを設定します - 生成音声をサポートするモデルで、音声なしの決定的な初回リクエストにしたい場合は
sound: offを使用します
モデル命名
このエンドポイントでは通常の Kling 動画 model ID を使用します。Omni model ID は Omni Video 用にしてください。再生時間とアスペクト比
size フィールドは公開されていません。指定したアスペクト比によって、出力フレームの形状が制御されます。
タスクフロー
Submit the generation request
Poll the task state
Persist the result
承認
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