Kling 图生视频

使用 Kling 模型从图片生成视频。

支持通过 image 参数传入图片 URL 或 Base64 编码的图片数据。

POST/kling/v1/videos/image2video

Kling 图生视频

使用 Kling 模型从图片生成视频。 支持通过 image 参数传入图片 URL 或 Base64 编码的图片数据。

鉴权: 使用 Bearer Token 认证。 格式: `Authorization: Bearer sk-xxxxxx`

请求体

Content-Type: application/json

字段类型必填说明
modelstring模型/风格 ID
示例: "kling-v1"
promptstring文本描述提示词
示例: "宇航员站起身走了"
imagestring图片输入 (URL 或 Base64)
示例: "https://example.com/image.jpg"
durationnumber视频时长(秒)
示例: 5
widthinteger视频宽度
示例: 1280
heightinteger视频高度
示例: 720
fpsinteger视频帧率
示例: 30
seedinteger随机种子
示例: 20231234
ninteger生成视频数量
示例: 1
response_formatstring响应格式
示例: "url"
userstring用户标识
示例: "user-1234"
metadataobject扩展参数 (如 negative_prompt, style, quality_level 等)

示例代码

curl -X POST "https://api.nodeprice.com/kling/v1/videos/image2video" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
  "model": "string",
  "prompt": "string",
  "image": "string",
  "duration": 0,
  "width": 0,
  "height": 0,
  "fps": 0,
  "seed": 0,
  "n": 0,
  "response_format": "string",
  "user": "string",
  "metadata": {}
}'
const url = "https://api.nodeprice.com/kling/v1/videos/image2video";
const body = {
  "model": "string",
  "prompt": "string",
  "image": "string",
  "duration": 0,
  "width": 0,
  "height": 0,
  "fps": 0,
  "seed": 0,
  "n": 0,
  "response_format": "string",
  "user": "string",
  "metadata": {}
};

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
  },
  body: JSON.stringify(body)
});

console.log(await response.text());
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	url := "https://api.nodeprice.com/kling/v1/videos/image2video"
	body := strings.NewReader(`{
  "model": "string",
  "prompt": "string",
  "image": "string",
  "duration": 0,
  "width": 0,
  "height": 0,
  "fps": 0,
  "seed": 0,
  "n": 0,
  "response_format": "string",
  "user": "string",
  "metadata": {}
}`)
	req, err := http.NewRequest("POST", url, body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer <token>")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	data, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))
}
import requests

url = "https://api.nodeprice.com/kling/v1/videos/image2video"

body = """{
  "model": "string",
  "prompt": "string",
  "image": "string",
  "duration": 0,
  "width": 0,
  "height": 0,
  "fps": 0,
  "seed": 0,
  "n": 0,
  "response_format": "string",
  "user": "string",
  "metadata": {}
}"""

response = requests.request("POST", url, data=body, headers={
  "Content-Type": "application/json",
  "Authorization": "Bearer <token>"
})

print(response.text)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n"
    + "  \"model\": \"string\",\n"
    + "  \"prompt\": \"string\",\n"
    + "  \"image\": \"string\",\n"
    + "  \"duration\": 0,\n"
    + "  \"width\": 0,\n"
    + "  \"height\": 0,\n"
    + "  \"fps\": 0,\n"
    + "  \"seed\": 0,\n"
    + "  \"n\": 0,\n"
    + "  \"response_format\": \"string\",\n"
    + "  \"user\": \"string\",\n"
    + "  \"metadata\": {}\n"
    + "}");
Request request = new Request.Builder()
    .url("https://api.nodeprice.com/kling/v1/videos/image2video")
    .method("POST", body)
    .addHeader("Content-Type", "application/json")
    .addHeader("Authorization", "Bearer <token>")
    .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());
#include <stdio.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl == NULL) {
        return 1;
    }

    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "Authorization: Bearer <token>");

    curl_easy_setopt(curl, CURLOPT_URL, "https://api.nodeprice.com/kling/v1/videos/image2video");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\n"
        + "  \"model\": \"string\",\n"
        + "  \"prompt\": \"string\",\n"
        + "  \"image\": \"string\",\n"
        + "  \"duration\": 0,\n"
        + "  \"width\": 0,\n"
        + "  \"height\": 0,\n"
        + "  \"fps\": 0,\n"
        + "  \"seed\": 0,\n"
        + "  \"n\": 0,\n"
        + "  \"response_format\": \"string\",\n"
        + "  \"user\": \"string\",\n"
        + "  \"metadata\": {}\n"
        + "}");
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

    CURLcode code = curl_easy_perform(curl);
    if (code != CURLE_OK) {
        fprintf(stderr, "%s\n", curl_easy_strerror(code));
    }

    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nodeprice.com/kling/v1/videos/image2video");
        request.Headers.Add("Authorization", "Bearer <token>");
        request.Content = new StringContent("{\n"
            + "  \"model\": \"string\",\n"
            + "  \"prompt\": \"string\",\n"
            + "  \"image\": \"string\",\n"
            + "  \"duration\": 0,\n"
            + "  \"width\": 0,\n"
            + "  \"height\": 0,\n"
            + "  \"fps\": 0,\n"
            + "  \"seed\": 0,\n"
            + "  \"n\": 0,\n"
            + "  \"response_format\": \"string\",\n"
            + "  \"user\": \"string\",\n"
            + "  \"metadata\": {}\n"
            + "}", Encoding.UTF8, "application/json");

        var response = await client.SendAsync(request);
        Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
}

响应

200 成功创建视频生成任务

Content-Type: application/json

字段类型必填说明
task_idstring任务 ID
示例: "abcd1234efgh"
statusstring任务状态
示例: "queued"

400 请求参数错误

Content-Type: application/json

字段类型必填说明
errorobject
messagestring错误信息
typestring错误类型
paramstring | null相关参数
codestring | null错误代码