CLI 和 SDK
@sketchie/sdk TypeScript 客户端和 sketchie 命令行是同一 HTTP API 之上的轻量类型化封装。两者都从 SKETCHIE_API_KEY 读取密钥,默认指向 https://sketchie.ai/api。
TypeScript SDK
创建客户端,用友好字段生成讲解视频,并等待渲染完成。
import { SketchieClient } from '@sketchie/sdk';
const client = new SketchieClient({
apiKey: process.env.SKETCHIE_API_KEY, // Bearer sk_...
// baseUrl defaults to https://sketchie.ai/api
});
// Friendly fields: input (the topic) and length ("M:SS", a multiple of 30).
const created = await client.createExplainer({
input: 'Explain how DNS resolves a domain name',
length: '0:30',
aspect: '16:9',
});
// Poll until the render finishes (or fails).
const done = await client.waitForExplainer(created.id, {
onUpdate: (e) => console.log(e.status),
});
console.log(done.videoUrl); // the rendered MP4
console.log(done.sceneGraph); // the editable scene graph 编辑与重新渲染循环
可编辑性楔子:完成的讲解视频会返回其 sceneGraph。用 editExplainerGraph 提交它以追加一个版本而不消耗另一次免费视频创建名额,或发送一条通俗语言指令。每个视频的第一次重新渲染是免费的。之后的重新渲染使用付费计划的分钟数。
// After a video is ready you get back its editable sceneGraph.
// Edit it, then append a new version to the existing explainer.
const edited = editScenes(done.sceneGraph!); // your UI edits the graph
const rerender = await client.editExplainerGraph(done.id, edited);
await client.waitForVersion(done.id, rerender.id);
// Or apply a plain-language instruction (a targeted re-render):
const version = await client.editExplainer(done.id, 'make scene 2 shorter');
await client.waitForVersion(done.id, version.id); 列出语音
const voices = await client.listVoices();
// [{ id: 'sketchie:sulafat', name: 'Nora', isDefault: true, preview_url, ... }] 其他方法:getExplainer、listExplainers、revertExplainer、duplicateExplainer 和 deleteExplainer。
命令行
# Discover voices
sketchie voices
# Generate (returns the queued record immediately)
sketchie generate "Explain how DNS resolves a domain name" --length 0:30 --aspect 16:9
# Generate and wait for the finished render
sketchie generate "Explain how DNS resolves" --length 1:00 --wait
# Status of an existing explainer
sketchie status <id>
# Conversational edit (a targeted re-render)
sketchie edit <id> "make the title scene shorter" --wait
# List your explainers
sketchie list --limit 20 标志与环境
| 标志 | 含义 |
|---|---|
--length <M:SS|sec> | 目标时长,例如 0:30、1:00 或秒数。30 的正倍数。省略则自动。 |
--aspect <ratio> | 16:9(默认)、9:16 或 1:1。 |
--voice <ref> | 语音引用(见 sketchie voices)。可选;默认 Nora。 |
--limit <n> | list 的最大行数,1 到 100(默认 50)。 |
--wait | 轮询直到渲染完成或失败。 |
--json | 在 stdout 上输出机器可读格式。 |
--api-url <url> | API 基础 URL,包含 /api 前缀。环境变量:SKETCHIE_API_URL。 |
--api-key <key> | 你的 API 密钥。环境变量:SKETCHIE_API_KEY。永不打印在输出中。 |