Kling 4.0 APIドキュメント
コードからKling 4.0を呼び出すために必要な情報をすべて掲載しています。ベースURLはhttps://cheapergen.com/api/v1です。まずプレイグラウンドでお試しください。
コーディングエージェントを使いますか?
これをClaude Code、Cursor、Codex、または任意のコーディングエージェントに貼り付けてください。プロジェクトにAPIを追加し、キーをCHEAPERGEN_API_KEYに保存して、支払いが発生する前に無料見積もりでテストします。
Add Kling 4.0 (CheaperGen endpoint kuaishou/ kling-4.0/ text-to-video) to this project by following https:/ / cheapergen.com/ agents/ integrate.md認証
ダッシュボード → APIキーでキーを作成し、Bearerトークンとして送信してください。キーはサーバー側で管理してください。
export CHEAPERGEN_API_KEY="cg_live_…"
# every request
Authorization: Bearer $CHEAPERGEN_API_KEYKling 4.0 テキストから動画を生成 API
/api/v1/run/kuaishou/kling-4.0/text-to-video非同期ジョブを送信すると、生成IDを含む202が返されます。GET /api/v1/generations/{id}をポーリングするか、webhook_urlを指定してください。詳細はジョブのライフサイクルをご覧ください。
入力パラメーター
| 名前 | 種類 | 説明 | 料金に影響 |
|---|---|---|---|
prompt必須 | string | ショットを説明してください:被写体、動き、カメラワーク、照明、スタイル。 | いいえ |
aspect_ratio | string (enum) | 出力フレームの形状。 値:16:9 · 9:16 · 1:1 · 21:9 デフォルト:16:9 | はい |
resolution | string (enum) | 出力解像度。高解像度では秒単価が上がります。 値:720p · 1080p デフォルト:720p | はい |
duration | integer | 生成クリップの長さ(3〜30秒)。秒単位で課金されます。 範囲:3~30s デフォルト:5 | はい |
webhook_url | string (URL) | 任意。生成が完了すると、Webhookシークレットで署名してここにPOSTします。Webhook | いいえ |
リクエスト
const API = "https://cheapergen.com/api/v1";
const headers = {
Authorization: `Bearer ${process.env.CHEAPERGEN_API_KEY}`,
"Content-Type": "application/json",
};
// 1. Submit the job
let job = await fetch(`${API}/run/kuaishou/kling-4.0/text-to-video`, {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "夜、雨水のたまった側溝を紙の舟が流れていく。ネオンの映り込み、やさしい雨音",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5
}),
}).then((r) => r.json());
// 2. Poll until it finishes (or pass webhook_url and skip polling)
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 3000));
job = await fetch(`${API}/generations/${job.id}`, { headers }).then((r) => r.json());
}
console.log(job.status === "succeeded" ? job.output.video.url : job.error);レスポンス
{
"id": "gen_8c2QmX1nq0k4",
"object": "generation",
"model": "kuaishou/kling-4.0",
"endpoint": "kuaishou/kling-4.0/text-to-video",
"mode": "text-to-video",
"status": "queued",
"input": {
"prompt": "夜、雨水のたまった側溝を紙の舟が流れていく。ネオンの映り込み、やさしい雨音",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.2255,
"currency": "usd",
"estimated": true,
"official_usd": null,
"list_price_source": "official",
"list_price_label": "Official",
"saved_usd": null
},
"source": "api",
"started_at": null,
"completed_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4/cancel"
},
"created_at": "2026-10-15T09:21:04Z"
}Kling 4.0 画像から動画を生成 API
/api/v1/run/kuaishou/kling-4.0/image-to-video非同期ジョブを送信すると、生成IDを含む202が返されます。GET /api/v1/generations/{id}をポーリングするか、webhook_urlを指定してください。詳細はジョブのライフサイクルをご覧ください。
入力パラメーター
| 名前 | 種類 | 説明 | 料金に影響 |
|---|---|---|---|
prompt必須 | string | ショットを説明してください:被写体、動き、カメラワーク、照明、スタイル。 | いいえ |
image_url必須 | string (URL) | 開始フレームに使う画像。JPG/PNG/WebP、URLまたはアップロード。 | いいえ |
end_image_url | string (URL) | 任意の終了フレーム。モデルが2つのフレームの間を動画にします。 | いいえ |
resolution | string (enum) | 出力解像度。高解像度では秒単価が上がります。 値:720p · 1080p デフォルト:720p | はい |
duration | integer | 生成クリップの長さ(3〜30秒)。秒単位で課金されます。 範囲:3~30s デフォルト:5 | はい |
webhook_url | string (URL) | 任意。生成が完了すると、Webhookシークレットで署名してここにPOSTします。Webhook | いいえ |
リクエスト
const API = "https://cheapergen.com/api/v1";
const headers = {
Authorization: `Bearer ${process.env.CHEAPERGEN_API_KEY}`,
"Content-Type": "application/json",
};
// 1. Submit the job
let job = await fetch(`${API}/run/kuaishou/kling-4.0/image-to-video`, {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "カーテンが揺れる中、彼女が窓の方を向いて微笑む。ゆっくり寄るカメラ。",
"image_url": "https://cdn.cheapergen.com/samples/portrait.jpg",
"resolution": "720p",
"duration": 5
}),
}).then((r) => r.json());
// 2. Poll until it finishes (or pass webhook_url and skip polling)
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 3000));
job = await fetch(`${API}/generations/${job.id}`, { headers }).then((r) => r.json());
}
console.log(job.status === "succeeded" ? job.output.video.url : job.error);レスポンス
{
"id": "gen_8c2QmX1nq0k4",
"object": "generation",
"model": "kuaishou/kling-4.0",
"endpoint": "kuaishou/kling-4.0/image-to-video",
"mode": "image-to-video",
"status": "queued",
"input": {
"prompt": "カーテンが揺れる中、彼女が窓の方を向いて微笑む。ゆっくり寄るカメラ。",
"image_url": "https://cdn.cheapergen.com/samples/portrait.jpg",
"resolution": "720p",
"duration": 5
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.2255,
"currency": "usd",
"estimated": true,
"official_usd": null,
"list_price_source": "official",
"list_price_label": "Official",
"saved_usd": null
},
"source": "api",
"started_at": null,
"completed_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4/cancel"
},
"created_at": "2026-10-15T09:21:04Z"
}Kling 4.0 参照素材から動画を生成 API
/api/v1/run/kuaishou/kling-4.0/reference-to-video非同期ジョブを送信すると、生成IDを含む202が返されます。GET /api/v1/generations/{id}をポーリングするか、webhook_urlを指定してください。詳細はジョブのライフサイクルをご覧ください。
入力パラメーター
| 名前 | 種類 | 説明 | 料金に影響 |
|---|---|---|---|
prompt必須 | string | ショットを説明してください:被写体、動き、カメラワーク、照明、スタイル。 | いいえ |
reference_image_urls | string[] (URLs) | 人物、商品、スタイル、シーン用の画像は最大10枚です。@Image1、@Image2…とプロンプト内で指定してください。 最大項目数:10 | いいえ |
reference_video_urls | string[] (video URLs) | 動き、カメラワーク、効果用のMP4/MOVクリップは最大5本です(1本あたり3〜30秒、合計30秒、1ファイルあたり200 MB以下)。@Video1、@Video2…とプロンプト内で指定してください。参照動画を使う場合は、出力秒数に、出力と参照動画のうち長い方の秒数を加えた時間が、より低い秒単価で課金されます。 最大項目数:5 | はい |
aspect_ratio | string (enum) | 出力フレームの形状。 値:16:9 · 9:16 · 1:1 · 21:9 デフォルト:16:9 | はい |
resolution | string (enum) | 出力解像度。高解像度では秒単価が上がります。 値:720p · 1080p デフォルト:720p | はい |
duration | integer | 生成クリップの長さ(3〜30秒)。秒単位で課金されます。 範囲:3~30s デフォルト:5 | はい |
webhook_url | string (URL) | 任意。生成が完了すると、Webhookシークレットで署名してここにPOSTします。Webhook | いいえ |
リクエスト
const API = "https://cheapergen.com/api/v1";
const headers = {
Authorization: `Bearer ${process.env.CHEAPERGEN_API_KEY}`,
"Content-Type": "application/json",
};
// 1. Submit the job
let job = await fetch(`${API}/run/kuaishou/kling-4.0/reference-to-video`, {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "夕暮れの浜辺を@Image1が歩く。@Video1のカメラワークを再現。",
"reference_image_urls": [
"https://cdn.cheapergen.com/samples/reference-1.jpg"
],
"reference_video_urls": [
"https://cdn.cheapergen.com/samples/reference-1.mp4"
],
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5
}),
}).then((r) => r.json());
// 2. Poll until it finishes (or pass webhook_url and skip polling)
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 3000));
job = await fetch(`${API}/generations/${job.id}`, { headers }).then((r) => r.json());
}
console.log(job.status === "succeeded" ? job.output.video.url : job.error);レスポンス
{
"id": "gen_8c2QmX1nq0k4",
"object": "generation",
"model": "kuaishou/kling-4.0",
"endpoint": "kuaishou/kling-4.0/reference-to-video",
"mode": "reference-to-video",
"status": "queued",
"input": {
"prompt": "夕暮れの浜辺を@Image1が歩く。@Video1のカメラワークを再現。",
"reference_image_urls": [
"https://cdn.cheapergen.com/samples/reference-1.jpg"
],
"reference_video_urls": [
"https://cdn.cheapergen.com/samples/reference-1.mp4"
],
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.2255,
"currency": "usd",
"estimated": true,
"official_usd": null,
"list_price_source": "official",
"list_price_label": "Official",
"saved_usd": null
},
"source": "api",
"started_at": null,
"completed_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4/cancel"
},
"created_at": "2026-10-15T09:21:04Z"
}結果を取得する
生成処理は非同期です。statusがsucceeded、failed、またはcanceledになるまでポーリングしてください。送信時にwebhook_urlを指定する方法もあります。失敗した生成は自動返金されます。
curl https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4 \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY"{
"status": "succeeded",
"output": {
"video": {
"url": "https://cdn.cheapergen.com/outputs/gen_8c2Q.mp4",
"content_type": "video/mp4"
}
}
}その他:ジョブのライフサイクル · Webhook · エラー
Kling 4.0の料金
従量課金: 動画1秒あたりを使った分だけ支払えます。サブスクリプションは不要です (月額プランは任意)。生成に失敗した場合は自動で返金されます。
| プラン | 公式価格 | CheaperGen | 節約額 |
|---|---|---|---|
720p 音声付き | $0.1486/s | −5% | |
1080p 音声付き | $0.2226/s | −5% |
- 公式価格:Kling開発者APIのKling 4.0定価、kling.ai/dev/pricing(720pは1ユニット = $0.157/秒、1080pは1.5ユニット = $0.235/秒。動画入力ありの場合は$0.094/$0.141で、出力秒数に出力と入力動画のうち長い方の秒数を加えて課金。音声は常に有効)。価格確認日:2026年10月18日。
- 音声は常に生成され、料金に含まれます。
- 参照動画を使う場合は、出力秒数に、出力と参照動画のうち長い方の秒数を加えた時間が、より低い秒単価で課金されます。