typetext
{
"duration": 5,
"end_image": "https://replicate.delivery/pbxt/NtYxE82ZGMlmmYb0l0eZd8LjFLRi0jQjoriINMxuEOwTjSPF/replicate-prediction-2n6h9ke4s9rmc0csxpaag876tm%20%281%29.jpeg",
"mode": "pro",
"negative_prompt": "",
"prompt": "Slow motion. pirates ride the boat through a turbulent swell as they pause at the end to appreciate the view. They make slight movements",
"start_image": "https://replicate.delivery/pbxt/NtYxEX0uDBQ4pNJ5C9oyMZQIUrXmgvmTVRWeEtg9KEg8JUtK/replicate-prediction-8hah38wndsrmc0csxp7t5eszx8.jpeg"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_0eP**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
import fs from "node:fs";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run kwaivgi/kling-v2.1 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
duration: 5,
end_image: "https://replicate.delivery/pbxt/NtYxE82ZGMlmmYb0l0eZd8LjFLRi0jQjoriINMxuEOwTjSPF/replicate-prediction-2n6h9ke4s9rmc0csxpaag876tm%20%281%29.jpeg",
mode: "pro",
negative_prompt: "",
prompt: "Slow motion. pirates ride the boat through a turbulent swell as they pause at the end to appreciate the view. They make slight movements",
start_image: "https://replicate.delivery/pbxt/NtYxEX0uDBQ4pNJ5C9oyMZQIUrXmgvmTVRWeEtg9KEg8JUtK/replicate-prediction-8hah38wndsrmc0csxp7t5eszx8.jpeg"
};
const output = await replicate.run("kwaivgi/kling-v2.1", { input });
// To access the file URL:
console.log(output.url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_0eP**********************************
This is your API token. Keep it to yourself.
import replicate
Run kwaivgi/kling-v2.1 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"kwaivgi/kling-v2.1",
input={
"duration": 5,
"end_image": "https://replicate.delivery/pbxt/NtYxE82ZGMlmmYb0l0eZd8LjFLRi0jQjoriINMxuEOwTjSPF/replicate-prediction-2n6h9ke4s9rmc0csxpaag876tm%20%281%29.jpeg",
"mode": "pro",
"negative_prompt": "",
"prompt": "Slow motion. pirates ride the boat through a turbulent swell as they pause at the end to appreciate the view. They make slight movements",
"start_image": "https://replicate.delivery/pbxt/NtYxEX0uDBQ4pNJ5C9oyMZQIUrXmgvmTVRWeEtg9KEg8JUtK/replicate-prediction-8hah38wndsrmc0csxp7t5eszx8.jpeg"
}
)
# To access the file URL:
print(output.url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output.read())
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_0eP**********************************
This is your API token. Keep it to yourself.
Run kwaivgi/kling-v2.1 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"input": {
"duration": 5,
"end_image": "https://replicate.delivery/pbxt/NtYxE82ZGMlmmYb0l0eZd8LjFLRi0jQjoriINMxuEOwTjSPF/replicate-prediction-2n6h9ke4s9rmc0csxpaag876tm%20%281%29.jpeg",
"mode": "pro",
"negative_prompt": "",
"prompt": "Slow motion. pirates ride the boat through a turbulent swell as they pause at the end to appreciate the view. They make slight movements",
"start_image": "https://replicate.delivery/pbxt/NtYxEX0uDBQ4pNJ5C9oyMZQIUrXmgvmTVRWeEtg9KEg8JUtK/replicate-prediction-8hah38wndsrmc0csxp7t5eszx8.jpeg"
}
}' \
https://api.replicate.com/v1/models/kwaivgi/kling-v2.1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "kz0cqt8051rma0csxpc9905wwc",
"model": "kwaivgi/kling-v2.1",
"version": "hidden",
"input": {
"duration": 5,
"end_image": "https://replicate.delivery/pbxt/NtYxE82ZGMlmmYb0l0eZd8LjFLRi0jQjoriINMxuEOwTjSPF/replicate-prediction-2n6h9ke4s9rmc0csxpaag876tm%20%281%29.jpeg",
"mode": "pro",
"negative_prompt": "",
"prompt": "Slow motion. pirates ride the boat through a turbulent swell as they pause at the end to appreciate the view. They make slight movements",
"start_image": "https://replicate.delivery/pbxt/NtYxEX0uDBQ4pNJ5C9oyMZQIUrXmgvmTVRWeEtg9KEg8JUtK/replicate-prediction-8hah38wndsrmc0csxp7t5eszx8.jpeg"
},
"logs": "Using model: kling-v2-1 in pro mode\nGenerating video...\nGenerated video in 126.1sec\nGenerated video ID: 807819897522356246\nDownloading 17644863 bytes\nDownloaded 16.83MB in 2.45sec",
"output": "https://replicate.delivery/xezq/OnNc0uYCoJITLd9MZflkQYuNE3TmmQG0Ff3BewROrMKX2XfVB/tmpjkmnbjgo.mp4",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-10-16T15:16:25.768Z",
"started_at": "2025-10-16T15:16:25.777992Z",
"completed_at": "2025-10-16T15:18:35.462307Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/kz0cqt8051rma0csxpc9905wwc/cancel",
"get": "https://api.replicate.com/v1/predictions/kz0cqt8051rma0csxpc9905wwc",
"stream": "https://stream.replicate.com/v1/files/bcwr-le6hvt7sfp7eqmziaj5uch4cc6qn72zcu5shneuz5sexniuq4ufa",
"web": "https://replicate.com/p/kz0cqt8051rma0csxpc9905wwc"
},
"metrics": {
"predict_time": 129.684314928,
"total_time": 129.694307
}
}
