ClipSDKDOCS
Quickstart (Node.js)

ClipSDK Node.js Quickstart

Integrate ClipSDK into Node.js 20+ using native fetch and crypto. Create ranked 9:16 clips with active-speaker reframing, karaoke captions, idempotent retries, and presigned uploads.

Auth Header
Bearer csdk_live_...
Create keys at clipsdk.com/dashboard/keys
Default Wait
60 seconds
Tune ?wait=0..300 or Prefer: respond-async
Free First Video
$0 up to 60m
Test full output before adding prepaid credit

Get Your ClipSDK API Key

ClipSDK authenticates every /v1/* endpoint with Authorization: Bearer csdk_live_... and gives every new account a $0 free first video up to 60 minutes.

Generate a live key in the dashboard at clipsdk.com/dashboard/keys and export it as CLIPSDK_KEY. Never embed live keys in browser bundles; call https://api.clipsdk.com from your backend or connect AI agents through https://mcp.clipsdk.com/mcp.

Export your API keybash
export CLIPSDK_KEY="csdk_live_replace_with_your_key"

Create Ranked Clips in Node.js

Send one POST https://api.clipsdk.com/v1/clips request in Node.js with an Idempotency-Key header to transcribe, rank, reframe to 9:16, and burn karaoke captions automatically.

clip-video.mjs (Node 20+ ESM)javascript
import crypto from "node:crypto";

const API_KEY = process.env.CLIPSDK_KEY;
if (!API_KEY) throw new Error("Set CLIPSDK_KEY before running");

const BASE = "https://api.clipsdk.com";

async function clipsdk(path, options = {}) {
  const res = await fetch(`${BASE}${path}`, {
    ...options,
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      Accept: "application/json",
      ...options.headers,
    },
  });
  const data = await res.json();
  if (!res.ok) {
    throw new Error(`${res.status} ${data.error?.code}: ${data.error?.message}`);
  }
  const retryAfter = Number(res.headers.get("retry-after") ?? "5");
  return { status: res.status, retryAfter, data };
}

let { retryAfter, data } = await clipsdk("/v1/clips?wait=60", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": `quickstart-${crypto.randomUUID()}`,
  },
  body: JSON.stringify({
    video_url: "https://www.youtube.com/watch?v=VIDEO_ID",
    clips: 5,
    min_seconds: 20,
    max_seconds: 60,
    aspect: "9:16",
    reframe: "auto",
    captions: "karaoke",
    hook: true,
  }),
});

let { job } = data;
while (job.status === "queued" || job.status === "running") {
  await new Promise((r) => setTimeout(r, retryAfter * 1000));
  ({ retryAfter, data } = await clipsdk(`/v1/jobs/${job.id}?wait=60`));
  job = data.job;
}

if (job.status !== "succeeded") {
  throw new Error(`Job failed: ${job.error?.code} - ${job.error?.message}`);
}

for (const clip of job.result.clips) {
  console.log(`#${clip.rank} [${clip.score}/100] ${clip.title} -> ${clip.video}`);
}

Inspect Returned Clips & Scores

ClipSDK returns HTTP 200 once a job finishes, sorting clips best-first with 0-100 standalone scores, MP4 links, JPG posters, SRT/VTT captions, and billing metadata.

Finished JobEnvelope responsejson
{
  "job": {
    "id": "job_3k9x0c2m1q8w7e6r5t4y",
    "op": "clips",
    "status": "succeeded",
    "stage": null,
    "usage": { "source_minutes": 42.5, "clips": 5, "output_seconds": 214.8 },
    "pricing": { "basis": "source_minutes", "reason": null, "quality_multiplier": 1 },
    "result": {
      "source": { "duration_s": 2550, "language": "en", "speakers": null },
      "clips": [
        {
          "rank": 1,
          "score": 92,
          "title": "Why usage-based video APIs beat seat licenses",
          "reason": "Opens with a bold claim and lands a concrete math proof in 41 seconds.",
          "start_s": 412.4,
          "end_s": 453.6,
          "duration_s": 41.2,
          "post_caption": "Flat seat subscriptions punish irregular publishing schedules...",
          "video": "https://api.clipsdk.com/f/clip_1_1080x1920.mp4",
          "poster": "https://api.clipsdk.com/f/clip_1_poster.jpg",
          "srt": "https://api.clipsdk.com/f/clip_1.srt",
          "vtt": "https://api.clipsdk.com/f/clip_1.vtt"
        }
      ],
      "locked": null
    },
    "error": null,
    "poll_url": "https://api.clipsdk.com/v1/jobs/job_3k9x0c2m1q8w7e6r5t4y"
  }
}
Score BandMeaningRecommended Action
80-100Strong standalone hook and payoff for cold viewersAuto-publish or queue straight to Shorts, Reels, and TikTok
50-79Good insight that benefits from a sharper opening titleAdd or tune a hook headline or trim opening filler via /edit
0-49Context-dependent or housekeeping momentFilter out automatically or request extra cuts with from_job

Upload Local Video Files in Node.js

ClipSDK supports local MP4, MOV, WebM, and MKV files up to 5 GB through POST /v1/uploads, returning a 1-hour presigned PUT URL and 7-day video_url.

Do Not Send Authorization on the Presigned PUT

Include Authorization: Bearer csdk_live_... on POST /v1/uploads, then omit Authorization on the direct PUT to upload_url and send the exact Content-Length byte count.

upload-local.mjs (Streaming PUT up to 5 GB)javascript
import fs from "node:fs";
import path from "node:path";

const API_KEY = process.env.CLIPSDK_KEY;
const filePath = "./episode-42.mp4";
const { size } = fs.statSync(filePath);

const ticketRes = await fetch("https://api.clipsdk.com/v1/uploads", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ filename: path.basename(filePath), size }),
});
const ticket = await ticketRes.json();

// PUT raw bytes directly to upload_url with exact Content-Length and no Authorization header
const putRes = await fetch(ticket.upload_url, {
  method: "PUT",
  headers: { "Content-Length": String(size) },
  body: fs.createReadStream(filePath),
  duplex: "half",
});
if (!putRes.ok) throw new Error(`Upload PUT failed: ${putRes.status}`);

console.log("Pass video_url to POST /v1/clips:", ticket.video_url);

Sync Wait vs Async Webhooks

Use ?wait=60 for CLI scripts and short videos, or send Prefer: respond-async with webhook_url in production SaaS backends to avoid tying up HTTP workers.

ModeRequest OptionBest Fit
Long-poll createPOST /v1/clips?wait=60 (max 300)CLI scripts, agent tools, and short 1-10 minute sources
Immediate async?wait=0 or Prefer: respond-asyncWeb apps queueing work and listening on webhook_url
Safe retriesIdempotency-Key: <unique-id> (24h TTL)Network retry loops without duplicating render spend

Next Steps After Your First Clip

Move from quickstart to production with full parameter schemas, custom caption presets, HMAC-SHA256 webhook verification, and AI agent skills.