> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidjutsu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> A typed client for the VidJutsu Cloud API, in the same package as the CLI.

```sh theme={null}
npm i vidjutsu
```

```ts theme={null}
import { readFileSync } from "node:fs";
import { VidJutsu } from "vidjutsu";

const client = new VidJutsu({ apiKey: process.env.VIDJUTSU_API_KEY });

const take = await client.upload("take1.mov", new Uint8Array(readFileSync("take1.mov")));
await client.init("film");
await client.edit("film", [
  { op: "add_media", media: take.media },
  { op: "insert_clip", track_id: "v1", occurrence: {
    id: "c1", media_id: take.media.id, timeline_start: 0,
    source: { start: 0, end: 20 },
    layout: { x: 0, y: 0, width: 1000, height: 1000 } } },
]);
const job = await client.render("film", { height: 1080 }, "film-1");
const done = await client.waitForRender(job.job_id);
console.log(done.output); // {hash, bytes, url, expires_at}
```

Every method is one API operation, with the same name as the [MCP tool](https://docs.vidjutsu.ai/mcp.md#tools). JSON in and out is snake\_case, exactly as the API sends it. It uses the global `fetch`, so it runs in Node 18+, Bun, Deno and browsers.

## Options

```ts theme={null}
new VidJutsu({
  apiKey: "vj_live_...",               // or an OAuth access token
  baseUrl: "https://api.vidjutsu.ai",  // default
  fetch: customFetch,                  // default: global fetch
  apiVersion: "2026-11-03",            // default: the version this SDK was built for
  clientName: "My Agent",              // the name history and Activity show for your edits
});
```

Every request carries the `VidJutsu-Version` header. See [Versioning](https://docs.vidjutsu.ai/api-reference/introduction.md#versioning).

## Methods

| Method | Operation |
| - | - |
| `signIn(email)`, `verify(attempt, code)` | [Sign up or sign in](https://docs.vidjutsu.ai/authentication.md). `verify` returns `{api_key, account_id, status, checkout_url?}`. No key needed. |
| `account()`, `usage()`, `wallet()`, `entitlements()` | Your account, usage, wallet and limits. |
| `createKey(name)`, `listKeys()`, `revokeKey(keyId)` | API keys. |
| `billingCheckout({amount_usd?, success_url?, cancel_url?})`, `billingTopUp({amount_usd?, success_url?, cancel_url?})`, `billingPortal({return_url?})` | Stripe links to sign up with your first payment, to add credits, or to manage your saved card. |
| `billingAutoTopUp({enabled, threshold_usd?, amount_usd?})` | Turn [auto top-up](https://docs.vidjutsu.ai/pricing.md#auto-top-up) on or off. |
| `upload(name, bytes, {source?, project?})` | A [direct upload](https://docs.vidjutsu.ai/guides/uploads.md#direct-uploads): starts it, PUTs each part, completes it, and aborts on failure. |
| `ingestUrl(url, name?, idempotencyKey?, {source?, project?})` | Add media from a link. |
| `createUpload(name, bytes, sha256)`, `completeUpload(uploadId, parts, {source?, project?})`, `abortUpload(uploadId)` | Direct upload steps, if you want to send parts yourself (in parallel, or from a stream). |
| `mediaInfo(hash)`, `mediaUrl(hash, ttlSeconds?)` | A media item, and a download link for it. |
| `makePreview(hash, {project?})`, `mediaPreview(hash)`, `makeTranscript(hash, {project?})`, `mediaTranscript(hash)` | [Previews and transcripts](https://docs.vidjutsu.ai/guides/uploads.md#previews-and-transcripts). |
| `listProjects({cursor?, limit?})`, `init(project, {template?, idempotencyKey?})`, `show(project, {revision?})`, `head(project)` | List, create and read projects. |
| `edit(project, operations, {expected_head?, summary?, branch?, idempotency_key?})` | [Edit](https://docs.vidjutsu.ai/guides/editing.md) a timeline. |
| `timelineWords(project, {revision?, pause?})` | The words and pauses on the edited timeline. |
| `history(project, {limit?, before?})`, `undo(project, revision, {change?, expected_head?})`, `restore(project, revision, {expected_head?})` | [Undo and history](https://docs.vidjutsu.ai/guides/agents.md#undo-and-history). |
| `shotList(project, {scene?, resolve?})`, `getShot(project, shot)`, `shotListEdit(project, expectedRevision, operations)`, `shotListImport(project, expectedRevision, episode, {replace?})`, `files(project)`, `searchWords(project, words, {limit?})` | The [shot list](https://docs.vidjutsu.ai/guides/shot-list.md), [episode plans](https://docs.vidjutsu.ai/guides/import-descript.md#bring-in-an-episode-plan), the project's files and word search. |
| `templates()`, `saveTemplate({name, columns, id?} or {name, project, id?})`, `deleteTemplate(template)` | [Shot list templates](https://docs.vidjutsu.ai/guides/shot-list-templates.md). |
| `layouts()`, `saveLayout({name, screen, camera})`, `deleteLayout(layoutId)`, `applyLayout(project, preset, {from?, to?})` | [Screen and camera layouts](https://docs.vidjutsu.ai/guides/layouts.md). |
| `studioSound(project, {media?})`, `level(project, body)` | [Studio Sound](https://docs.vidjutsu.ai/guides/studio-sound.md) and [leveling](https://docs.vidjutsu.ai/guides/audio.md). |
| `frame(project, times, {height?, revision?})`, `check(project, {sections?, revision?})` | [Look at and check a cut](https://docs.vidjutsu.ai/guides/look-and-check.md). Both start jobs; read `output` when they succeed. |
| `importTimeline({project, timeline, files, format?})` | Open a [Descript export](https://docs.vidjutsu.ai/guides/import-descript.md) as a new project. |
| `events(project, {after?, limit?})`, `stream(project, {lastEventId?, signal?})` | [Live updates](https://docs.vidjutsu.ai/guides/live-updates.md): notices as JSON, or the live stream as an async iterator. |
| `setPresence(project, {selection?, playhead?})`, `workingOn(project, {text, clips?, range?, scene?})` | Say where you are and what you're doing. |
| `comments(project)`, `addComment(project, body)`, `resolveComment(project, commentId, resolved?)`, `deleteComment(project, commentId)` | Comments. |
| `render(project, body?, idempotencyKey?)` | Start a [render](https://docs.vidjutsu.ai/guides/rendering.md). `body.captions` burns in [captions](https://docs.vidjutsu.ai/guides/captions.md). |
| `captions(project, {format?, revision?, branch?})` | The cut's [captions](https://docs.vidjutsu.ai/guides/captions.md) as SRT or WebVTT. Free. |
| `renderStatus(jobId)`, `cancelRender(jobId)` | Read any job, or cancel a render. |
| `waitForJob(jobId, {intervalMs?, onUpdate?})` | Poll a job until it ends (every 3 seconds by default). `waitForRender` is the same. |
| `connectAccount(platform, {return_to?})`, `socialAccounts()`, `updateSocialAccount(socialAccountId, {approve_before_posting})`, `disconnectAccount(socialAccountId)` | Connect, list and disconnect [social accounts](https://docs.vidjutsu.ai/guides/publishing.md#connect-an-account). |
| `schedulePost({media, accounts, caption?, at?, idempotency_key?})`, `posts({state?, cursor?, limit?})`, `getPost(postId)`, `reschedulePost(postId, at \| null)`, `cancelPost(postId)`, `approvePost(postId)`, `postStats(postId)` | [Publishing](https://docs.vidjutsu.ai/guides/publishing.md): post a render or stored file now or at a time, follow it, approve it, and read its numbers. |
| `request(method, path, body?, idempotencyKey?)` | Any other call. |

## Live updates

```ts theme={null}
const controller = new AbortController();
for await (const { event, id, data } of client.stream("film", { signal: controller.signal })) {
  if (event === "revision") console.log("new revision", data);
}
```

`stream()` yields `{event, id?, data}` for each Server-Sent Event. It reconnects when the server ends the stream (about every five minutes) and resumes from the last notice it saw.

## Errors

Failed calls throw `VidJutsuError` with the API's `status`, `code` and `message`, and the whole error `body`. For a 402, `fixUrl` is the link that fixes it: the checkout link before sign-up, the top-up link when your wallet runs low, or the upgrade link when a feature isn't in your plan.

```ts theme={null}
import { VidJutsuError } from "vidjutsu";

try {
  await client.render("film");
} catch (error) {
  if (error instanceof VidJutsuError && error.code === "payment_required") {
    console.log("Add credits here:", error.fixUrl);
  } else throw error;
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.