import { createClient } from "vidjutsu";
const vj = createClient();
// 1. Create a reusable character (returns { id: "char_...", imageUrl, model }).
const { data: character } = await vj.createCharacter({
prompt: "A friendly host in their late 20s, casual streetwear",
});
// 2. Stage the source video, then score it.
const { data: source } = await vj.downloadTikTokVideo({
url: "https://www.tiktok.com/@creator/video/123456789",
});
const { data: check } = await vj.cloneCheck({ videoUrl: source.url });
console.log(check.verdict, check.score);
// 3. Compose a starting frame, generate the clone, and poll for the result.
const { data: extracted } = await vj.extractMedia({ mediaUrl: source.url, frames: [0] });
const { data: starting } = await vj.cloneStartingImage({
characterId: character.id,
firstFrame: extracted.frames[0].url,
prompt: "Match the framing and pose of the source's opening frame",
});
const { data: task } = await vj.cloneVideo({
startingImageUrl: starting.imageUrl,
sourceVideoUrl: source.url,
model: "kling",
});
let result;
do {
await new Promise((resolve) => setTimeout(resolve, 3000));
({ data: result } = await vj.getCloneVideo(task.id));
} while (result.status === "processing");
if (result.status === "failed") throw new Error(result.error);
console.log(result.videoUrl);