Skip to main content
The official TypeScript SDK for Poof works in Node.js, Deno, Bun and the browser, with full type definitions. It ships as both ESM and CommonJS.

Installation

Requirements: Node.js 18+ (or Deno/Bun/browser)

Quick Start

Authentication

apiKey is required. The SDK does not read an environment variable for you, so pass it in yourself:
Never ship your API key in browser code. Call the SDK from your server (see the framework examples below).

Usage Examples

removeBackground(input, options?) accepts a File, Blob, ArrayBuffer, Buffer, Uint8Array, or a string file path (Node.js only).

From File Path (Node.js)

From Buffer

From File or Blob (browser / server upload)

From URL

Download the image first, then pass the bytes:

With Options

channels: 'alpha', padding, aspect-ratio crop, the matte metadata fields and the width / height / fit output-size options are on the SDK’s main branch and ship in the next release (@poof-bg/js 1.1.0). The currently published 1.0.0 passes size and channels through unchanged but does not expose padding, the matte fields or the output-size options.
Every successful call costs 1 credit regardless of options. Failed calls are not billed.

Result and Metadata

removeBackground() resolves to a RemoveBackgroundResult:

Flagging Results for Review

matteConfidence (0–1) is how decisive the alpha mask is; matteAmbiguousRatio (0–1) is the fraction of pixels with alpha between 0.1 and 0.9. Both are heuristics, not calibrated probabilities. The dashboard playground flags a result for review when the ambiguous ratio is above 0.15:

Parallel Processing

Account Info

me() returns the /me response. It is free and not rate limited.

Error Handling

All errors extend PoofError, which exposes .code, .status, .requestId, .details and .message. Subclasses are chosen by the API error code:

Retry with Backoff

Configuration

TypeScript Types

Full type definitions are included:

Framework Examples

Express.js

Next.js API Route