@transform-kit/sdk
v0.6.0
Published
TransformKit TypeScript SDK — media transforms as an API
Readme
@transform-kit/sdk
TypeScript client for TransformKit — media transforms as an API.
Upload a file, describe the output, get a signed URL. Images, video, audio, and documents. One SDK. Zero runtime dependencies. Node.js 20+.
Docs: transform-kit.com/docs · Changelog
Install
npm install @transform-kit/sdkGet a key at Credentials. Keep it server-side.
import { readFile } from 'node:fs/promises';
import { TransformKit } from '@transform-kit/sdk';
const tk = new TransformKit({ apiKey: process.env.API_KEY! });
const [photo] = await tk
.runQueue([{ bytes: await readFile('photo.jpg'), filename: 'photo.jpg' }], 'image')
.maxSize(1600)
.convert({ format: 'webp', quality: 82 });
if (!photo.ok) throw new Error(photo.error);
console.log(photo.outputs[0]!.media.url); // signed URL, valid ~24hSame shape for video, audio, and documents — swap the media kind and the chain:
await tk
.runQueue([{ bytes, filename: 'clip.mp4' }], 'video')
.maxSize(720)
.convert({ format: 'mp4' });
await tk.runQueue([{ bytes, filename: 'tone.wav' }], 'audio').convert({ format: 'mp3', bitrate: 192 });
await tk.runQueue([{ bytes, filename: 'brief.pdf' }], 'document').convert({ format: 'md' });runQueue is the linear path (one output per file). runPipeline runs a graph when one input needs several outputs. See the docs for batching, fan-out, BYOS, and Next.js.
License
MIT
