Quick Start
Get your first job running in under 5 minutes.
1. Install the SDK
Install the @offload-run/sdk package using your preferred package manager.
npm install @offload-run/sdk # or pnpm add @offload-run/sdk # or yarn add @offload-run/sdk
2. Initialize the Client
Import the SDK and initialize it with your API key. You can find your API key in the dashboard.
import { OffloadClient } from '@offload-run/sdk';
const offload = new OffloadClient({
apiKey: process.env.OFFLOAD_API_KEY!,
});3. Enqueue a Job
Submit a job to the processing queue. Here's an example of compressing a video.
const { jobId } = await offload.enqueueJob({
type: 'compressVideo',
params: {
url: 'https://example.com/my-video.mp4',
quality: 'high',
}
});
console.log('Job ID:', jobId);4. Wait for Completion
Use waitForJob() to poll for the job result, or enqueueAndWait() to do both in one call.
// Option 1: Poll for result
const result = await offload.waitForJob(jobId);
// Option 2: Enqueue and wait in one call
const result = await offload.enqueueAndWait({
type: 'compressVideo',
params: {
url: 'https://example.com/my-video.mp4',
quality: 'high',
}
});
console.log('Compressed URL:', result.url);
console.log('Compression ratio:', result.compressionRatio);