@vectali/sdk is the official Forge-generated client for Node.js 20+ and TypeScript 5.9+. It has zero external runtime dependencies.
Install
Install @vectali/sdk (v0.4.1) from npm.
npm install @vectali/sdkConvert and download
Set VECTALI_API_KEY in your server environment. The client returns a typed result with camelCase fields. Save result.svg as UTF-8 and keep result.conversionId with your upload record.
import { readFile, writeFile } from "node:fs/promises";
import { Vectali } from "@vectali/sdk";
const client = new Vectali({ apiKey: process.env.VECTALI_API_KEY! });
const result = await client.convert(await readFile("logo.png"), { filename: "logo.png" });
await writeFile("logo.svg", result.svg, "utf8");
await writeFile("logo.pdf", (await client.download(result.conversionId, "pdf")).bytes);convert accepts a Uint8Array, ArrayBuffer, File or Blob. Set filename and, if needed, contentType for raw bytes. download returns { bytes, contentType } for svg, pdf, eps or dxf. Each format comes from the same saved conversion.
Check allowance and health
const allowance = await client.getAllowance();
console.log(allowance.freeApiConversions.remaining);
await new Vectali().health();
getAllowance() reads account credits through GET /api/v1/billing. health() calls public GET /health without sending an API key. The constructor accepts apiKey, baseUrl and timeoutMs, which defaults to 260,000 milliseconds.
Handle errors and retries
Save one idempotencyKey per job before calling convert. If a timeout or interrupted response makes the result uncertain, send the same bytes and key again. Omitting the option generates a new UUID for that call.
import { ApiError } from "@vectali/sdk";
try {
const result = await client.convert(bytes, {
filename: "logo.png",
idempotencyKey: jobId,
});
await writeFile("logo.svg", result.svg, "utf8");
} catch (error) {
if (error instanceof ApiError) {
console.error(error.status, error.response.headers.get("X-Vectali-Request-Id"));
if (error.status === 429) {
console.error("Retry after", error.response.headers.get("Retry-After"), "seconds");
}
}
throw error;
}
ApiError.details contains the decoded response when available. Handle local validation and transport failures separately. Follow the retry contract and error reference when deciding whether to reschedule the job.