डॉक्स / CLI और SDK

टूल

CLI और SDK

API के ऊपर दो पतली, टाइप्ड परतें। वीडियो बनाने वाले कोड के लिए SDK; आपके टर्मिनल, स्क्रिप्ट और CI के लिए chasca CLI।

बेस URL https://app.trychasca.com/api

कॉन्फ़िगर करें

CLI और SDK, दोनों को npm से इंस्टॉल करें (Node 20 या उससे नया वर्ज़न चाहिए):

टर्मिनल
# the chasca command
npm install -g @chasca/cli

# the SDK, in your project
npm install @chasca/sdk

CLI और SDK, दोनों यही दो एनवायरनमेंट वेरिएबल पढ़ते हैं:

टर्मिनल
export CHASCA_API_URL=https://app.trychasca.com/api
export CHASCA_API_KEY=chk_live_...

CHASCA_API_URL देना ज़रूरी नहीं है, इसका डिफ़ॉल्ट https://app.trychasca.com/api है। API key ऐप के Settings → API keys में बनती है (Plus और उससे ऊपर के प्लान में)।

chasca CLI

टर्मिनल
# list voices (no key needed)
chasca voices

# create a 30-second vertical video and wait for it
chasca generate "How does a heat pump work?" --length 0:30 --aspect 9:16 --wait

# check on a video
chasca status 0b9c6f2e-5d1a-4c3e-9a47-2f8e1c7d4b60

# change one thing and wait for it: subtitles, style, reveal, music, logo, credit, voice or format
chasca change 0b9c6f2e-5d1a-4c3e-9a47-2f8e1c7d4b60 subtitles off --wait

# a new voice or format makes a separate video, charged like one
chasca change 0b9c6f2e-5d1a-4c3e-9a47-2f8e1c7d4b60 format 9:16 --wait

# your latest videos
chasca list --limit 20
  • --length में M:SS दें, 30-30 सेकंड के स्टेप में, 30:00 तक।
  • --aspect की वैल्यू 16:9, 9:16 या 1:1 होती है।
  • --wait देने पर कमांड तब तक चलती रहती है, जब तक वीडियो (या नया वर्ज़न) तैयार न हो जाए।
  • chasca change <id> <what> <value> एक चीज़ बदलता है: subtitles, style, reveal, music, watermark, logo, credit, voice या format। नई आवाज़ या नया फ़ॉर्मेट एक अलग वीडियो बनाता है, जिसका खर्च नए वीडियो जितना ही होता है।
  • --json API का रिस्पॉन्स जैसा का तैसा प्रिंट करता है, जिसे jq में पाइप करना आसान रहता है।

TypeScript SDK

@chasca/sdk हर उस जगह चलता है, जहां fetch मौजूद हो (Bun, Node 20+)। हर रिस्पॉन्स को उन्हीं कॉन्ट्रैक्ट से जांचा जाता है, जिन्हें API इस्तेमाल करता है, और हर गड़बड़ी पर एक ही तरह का ChascaError throw होता है, जिसका code तय रहता है। आपकी key निजी रहती है और एरर मैसेज में कभी नहीं दिखती।

make-a-video.ts
import { ChascaClient, ChascaError } from '@chasca/sdk';

const chasca = new ChascaClient({
  apiKey: process.env.CHASCA_API_KEY!,
  baseUrl: process.env.CHASCA_API_URL ?? 'https://app.trychasca.com/api',
});

// 1. queue a video (202) and wait until it is ready
const job = await chasca.createExplainer({
  input: 'How vaccines train the immune system',
  length: '1:30',
  aspect: '16:9',
  preset: 'chalkboard',
});
const video = await chasca.waitForExplainer(job.id, {
  onUpdate: (e) => console.log(e.status, e.stage, Math.round(e.progress * 100) + '%'),
});
console.log(video.videoUrl);

// 2. change one thing: a free new version of the same video, with the same narration
const change = await chasca.changeExplainer(video.id, { kind: 'style', preset: 'pencil' });
if (change.made === 'version') {
  const updated = await chasca.waitForVersion(video.id, change.version.id);
  console.log(updated.videoUrl);
}

// 3. errors are typed
try {
  await chasca.getExplainer('not-a-real-id');
} catch (err) {
  if (err instanceof ChascaError) console.error(err.status, err.code, err.message);
}

आप सीन ग्राफ़ को खुद भी एडिट कर सकते हैं, और उसे नए वर्ज़न के रूप में सेव कर सकते हैं:

edit-graph.ts
// edit the scene graph directly: rename a heading, then commit it as a new version
const current = await chasca.getExplainer(video.id);
const graph = structuredClone(current.sceneGraph!);
graph.scenes[0]!.heading = 'THE SNOWBALL EFFECT';
const v3 = await chasca.editExplainerGraph(video.id, graph);
await chasca.waitForVersion(video.id, v3.id);

मेथड

ChascaClient के मेथड
मेथड क्या करता है
createExplainer(params) POST /v1/explainer। वीडियो को कतार में डालता है; कतार में डाला गया रिकॉर्ड लौटाता है।
waitForExplainer(id, options?) ready या failed होने तक poll करता है: ready पर resolve होता है, failed पर एरर throw करता है। ऑप्शन: intervalMs, timeoutMs, onUpdate।
getExplainer(id) GET /v1/explainer/:id, सीन ग्राफ़, सीन और वर्ज़न के साथ।
listExplainers({ limit }) GET /v1/explainer, सबसे नए पहले (limit 1–100)।
changeExplainer(id, change) POST …/change, एक बदलाव के साथ। { made: "version", version } लौटाता है, या नई आवाज़ या नए फ़ॉर्मेट पर { made: "video", explainer }।
editExplainerGraph(id, sceneGraph) POST …/edit, एडिट किए गए सीन ग्राफ़ के साथ; कतार में डाला गया वर्ज़न लौटाता है।
waitForVersion(id, versionId, options?) उस वर्ज़न के ready होने तक poll करता है; अपडेट हुए एक्सप्लेनर के साथ resolve होता है।
revertExplainer(id, versionId) POST …/revert। किसी पुराने, तैयार वर्ज़न को फिर से मौजूदा वर्ज़न बनाता है।
duplicateExplainer(id) POST …/duplicate। कॉपी लौटाता है।
deleteExplainer(id) DELETE /v1/explainer/:id।
listVoices({ language }) GET /v1/voices। सभी नैरेटर, हर एक के प्रीव्यू के साथ।
listLanguages() GET /v1/languages।

कंस्ट्रक्टर new ChascaClient({ apiKey, baseUrl }) है। सभी मेथड एक वैकल्पिक { signal } भी लेते हैं, ताकि आप AbortController से रिक्वेस्ट कैंसल कर सकें।