Examples & Integrations

SDK Cookbook

Copy-paste ready SDK patterns for common production workflows.

Node.js: Single Video to Transparent WebM

import { RemoveBGVideoClient } from 'removebgvideo-node';

const client = new RemoveBGVideoClient(process.env.REMOVEBGVIDEO_API_KEY!);

const created = await client.createJob({
  video_url: 'https://cdn.removebgvideo.com/uploads/input.mp4',
  model: 'original',
  bg_type: 'transparent',
  output_format: 'webm',
  auto_start: true,
});

const result = await client.waitForCompletion(created.id);
console.log(result.output_url);

Python: Pro Model with text_prompt

from removebgvideo import RemoveBGVideoClient

client = RemoveBGVideoClient(api_key='YOUR_API_KEY')

job = client.create_job(
    video_url='https://cdn.removebgvideo.com/uploads/input.mp4',
    model='pro',
    bg_type='transparent',
    output_format='webm',
    auto_start=False
)

client.start_job(
    job['id'],
    model='pro',
    text_prompt='person, staff, glowing ring, clothing accessories'
)

result = client.wait_for_completion(job['id'])
print(result['output_url'])

Batch Pattern (Queue Worker)

For high volume, enqueue one job per source video and process asynchronously.

  1. Producer writes video URLs to queue with customer context.
  2. Worker creates and starts v1 jobs with model-specific payloads.
  3. Worker polls status and updates internal DB state machine.
  4. On completion, worker stores output_url and emits webhook/event to caller.

SDK Operational Best Practices

  • Set explicit request timeout and retry policy in your HTTP layer.
  • Pin SDK version and upgrade behind staging tests.
  • Log api_key alias (not full key), job_id, model, and output_format.
  • Add fallback model strategy for quality/speed incidents.

Operational Patterns

  • Use queue-based orchestration for sustained throughput.
  • Separate latency-sensitive traffic from bulk processing workloads.
  • Centralize webhook/event consumption through one idempotent handler.
  • Use dead-letter queue for repeated failures and manual replay.

Go-Live Checklist

  1. Load test with realistic clip duration distribution.
  2. Validate alerting for error rate, queue lag, and failed jobs.
  3. Confirm credit accounting and billing UX alignment.
  4. Prepare escalation template containing job_id + payload summary.

Deployment Playbook

  1. Put SDK calls behind an internal service layer, not directly in UI routes.
  2. Implement a queue mode for videos above your sync threshold duration.
  3. Track per-model spend and success rate in BI dashboards.
  4. Add automated integration tests with fixed sample fixtures.

Anti-Patterns to Avoid

  • Calling upstream API directly from browser with secret keys.
  • Blocking HTTP request lifecycle until long jobs finish.
  • Not storing job_id mapping, making support/debug impossible.
  • Switching model defaults without regression testing.