Kling
Kling アバタービデオを作成する
CometAPI の Kling Avatar API を使用して、画像からアバター駆動の動画を生成します。高速な image-to-video アバターには POST /kling/v1/videos/avatar/image2video を使用します。
POST
/
kling
/
v1
/
videos
/
avatar
/
image2video
cURL
curl https://api.cometapi.com/kling/v1/videos/avatar/image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/avatar/image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/avatar/image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/avatar/image2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://your-image-host/avatar.jpg',
'prompt' => 'The speaker talks naturally to camera',
'sound_file' => 'https://your-audio-host/speech.wav'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/avatar/image2video"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/avatar/image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/avatar/image2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"created_at": 123,
"updated_at": 123,
"task_info": {}
}
}このエンドポイントを使用すると、1 枚の元画像と 1 つの音声ソースから、話すアバターのクリップを作成できます。
呼び出す前に
- 1 つのアバター
imageを公開 URL または生の base64 文字列として提供します - Kling のピクセル要件を満たすアバター画像を使用してください。小さすぎるサムネイルは生成タスクで拒否されます
audio_idまたはsound_fileのいずれか一方のみを送信します- 最初のリクエストはシンプルにしてください。顔画像 1 枚、音声クリップ 1 つ、そして必要に応じて短いプロンプト(Prompt)を指定します
- 参照する音声が、関連付ける必要のある以前のタスクに属している場合は
task_idを含めます - より高品質なパスが明確に必要でない限り、
mode: stdから始めてください
音声ソースのルール
audio_idは、Kling TTS ルート経由ですでに音声を生成している場合に最も簡単な方法ですsound_fileは、独自の MP3、WAV、M4A、または AAC アセットをすでに持っている場合に使用できます- アバター音声の長さは 2 ~ 60 秒と文書化されています
タスクの流れ
1
アバタータスクを作成する
画像と 1 つの音声ソースを送信し、返された task id を保存します。
2
タスクをポーリングする
タスクが終了状態に達するまで、Kling タスクを取得する を続けます。
3
完了した結果を保存する
プロバイダーの配信 URL を超えて保持する必要がある場合は、最終アセットを自分のストレージにコピーします。
完全なパラメータリファレンスについては、Kling Avatar の公式ドキュメント を参照してください。
ボディ
application/json
- Option 1
- Option 2
最終更新日 2026年6月25日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/avatar/image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/avatar/image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/avatar/image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/avatar.jpg",
"prompt": "The speaker talks naturally to camera",
"sound_file": "https://your-audio-host/speech.wav",
"mode": "std"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/avatar/image2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://your-image-host/avatar.jpg',
'prompt' => 'The speaker talks naturally to camera',
'sound_file' => 'https://your-audio-host/speech.wav'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/avatar/image2video"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/avatar/image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/avatar/image2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://your-image-host/avatar.jpg\",\n \"prompt\": \"The speaker talks naturally to camera\",\n \"sound_file\": \"https://your-audio-host/speech.wav\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"created_at": 123,
"updated_at": 123,
"task_info": {}
}
}