🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@zvid/sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zvid/sdk

Official TypeScript/JavaScript SDK for the Zvid JSON-to-video/image rendering API

latest
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

@zvid/sdk — official TypeScript SDK

Typed TypeScript/JavaScript client for the Zvid JSON-to-video/image rendering API. Fetch-based with zero runtime dependencies, ESM + CJS, strict types derived from the maintained API contract, automatic transient-failure retries, polling helpers, media uploads, and timing-safe webhook signature verification.

npm install @zvid/sdk

Requires Node 18+ (native fetch). The API client itself is runtime-agnostic; the webhook helpers use node:crypto.

Quickstart

import { ZvidClient, outputUrl } from "@zvid/sdk";

const zvid = new ZvidClient(); // reads ZVID_API_KEY; create one at https://app.zvid.io/api-keys

const job = await zvid.renders.createImage({
  payload: {
    type: "image",
    width: 1200,
    height: 630,
    visuals: [{ type: "TEXT", text: "Hello Zvid", position: "center-center" }],
  },
});
const done = await zvid.waitForRender(job.jobId, { timeoutMs: 120_000 });
console.log(outputUrl(done)); // https://cdn.zvid.io/...

Configuration

OptionEnv varDefault
apiKeyZVID_API_KEY— (required)
baseUrlZVID_BASE_URLhttps://api.zvid.io
fetchglobal fetch
maxRetries3
retryBaseDelayMs1000
retryMaxDelayMs30000

Network failures and HTTP 429, 502, 503, and 504 responses are retried with exponential backoff and jitter. Retry-After is honored up to retryMaxDelayMs. Set maxRetries: 0 when the caller must never repeat a request. onRetry can feed application logs or metrics without replacing the retry implementation.

Surface

NamespaceMethods
zvid.accountprofile
zvid.apiKeyslist, create, update, stats, revoke / delete
zvid.authoringgetSchema, listElements, getElementDocs, getExamples, creativePlan, repair, validate (plan-aware; no render credits)
zvid.renderscreate, createImage, createBulk, createImageBulk, listBulk, getBulk
zvid.jobsget, list, wait
zvid.templateslist, get, create, update, duplicate, preview, archive / delete
zvid.projectslist, get, create, update, delete
zvid.uploadslist, create, delete
zvid.webhookslist, get, create, update, delete, test, deliveries
zvid.creditsbalance, transactions, usageStats

Renders are asynchronous: every renders.create* call returns { jobId }. Poll zvid.jobs.get(jobId) yourself, or block with zvid.waitForRender(jobId, { timeoutMs, pollIntervalMs, signal }) — it resolves with the terminal JobStatus (use the outputUrl() / thumbnailUrl() helpers on it), rejects with RenderFailedError on failure and WaitTimeoutError on timeout, and supports AbortSignal.

Every render call takes exactly one of payload (inline project JSON, typed as RenderPayload) or template (stored tpl_… id), plus optional variables, overrides, and a one-off webhookUrl. The authoritative payload schema is published at docs.zvid.io (render-payload.schema.json).

zvid.authoring.validate() always resolves for schema validation: check its valid field. Invalid payloads return { valid: false, errors, warnings }; authentication, network, and other API failures still throw.

Uploads

Upload a browser File or a Blob created in Node.js. The returned CDN URL can be used directly as an image, video, GIF, or audio element source.

import { readFile } from "node:fs/promises";

const bytes = await readFile("./poster.png");
const poster = await zvid.uploads.create(
  new Blob([bytes], { type: "image/png" }),
  { fileName: "poster.png", width: 1200, height: 630 },
);
console.log(poster.url);

Errors

For AI generation, read zvid.authoring.getSchema() and the relevant element docs, start from a validated example, then repair and validate before calling zvid.renders.create*.

All API errors extend ZvidAPIError (with .status, .error, .details, .body):

ClassWhen
AuthenticationError401
InsufficientCreditsError402 — has .creditsRequired / .creditsAvailable
NotFoundError404
RateLimitError429 — has .retryAfter (seconds)
RenderFailedErrorthrown by waitForRender when the job fails (.job)
WaitTimeoutErrorthrown by waitForRender on timeout

Webhooks

Deliveries to registered endpoints are signed: X-Zvid-Signature: sha256=hex(HMAC_SHA256(secret, "<X-Zvid-Timestamp>.<raw body>")).

import { verifyWebhookSignature } from "@zvid/sdk";

// Express example — use the RAW body (express.raw / rawBody), not re-serialized JSON
app.post("/hooks/zvid", express.raw({ type: "application/json" }), (req, res) => {
  if (!verifyWebhookSignature(req.body, req.headers, process.env.ZVID_WEBHOOK_SECRET!)) {
    return res.status(400).end();
  }
  const event = JSON.parse(req.body.toString());
  // event.event === "render.completed" | "render.failed", event.data.url, …
  res.status(200).end();
});

verifyWebhookSignature uses crypto.timingSafeEqual and rejects deliveries older than 5 minutes ({ toleranceSeconds: null } disables the freshness check). It accepts fetch Headers, Node request headers, or plain objects. Per-request webhookUrl deliveries are not signed — only account endpoints are.

Development

npm install
npm run typecheck && npm test && npm run build

Live smoke test against a running orchestrator (spends ~1 credit):

ZVID_API_KEY=zvid_… ZVID_BASE_URL=http://localhost:4000 node examples/e2e.mjs

Publishing (manual)

Not published yet. To release version 0.2.0:

npm run prepublishOnly   # typecheck + tests + build
npm publish              # publish the public `@zvid/sdk` package to npm

Keywords

zvid

FAQs

Package last updated on 06 Aug 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts