# VectoSolve TypeScript SDK: Integrate AI Image Vectorization in Your App > The official TypeScript SDK for VectoSolve gives you type-safe access to AI vectorization, background removal, upscaling, and logo generation. Install via npm, authenticate with your API key, and ship production integrations in minutes. **Source:** https://vectosolve.com/blog/vectosolve-typescript-sdk-image-vectorization-api **Author:** Robin Monteiro (Founder of VectoSolve) **Published:** 2026-03-16 **Category:** Tutorial **Reading time:** 7 min read **Tags:** sdk, typescript, api, vectorize, npm, developer-tools --- ## Why Use the TypeScript SDK? You can call the VectoSolve REST API with `fetch` or Axios, and it works fine. But raw HTTP calls mean writing boilerplate: constructing FormData, setting headers, parsing responses, handling errors, managing retries. The [official TypeScript SDK](https://www.npmjs.com/package/@vectosolve/sdk) eliminates all of that. Here is what you get out of the box: - **Full type safety** — every method, option, and response is typed - **Automatic authentication** — pass your API key once, forget about headers - **File handling** — accepts file paths, Buffers, ReadableStreams, and URLs - **Error classes** — typed errors for insufficient credits, rate limits, invalid input - **Retries with backoff** — transient failures are retried automatically - **Tree-shakable** — only import what you use, zero bloat in your bundle If you are building a Node.js backend, a Next.js app, or any TypeScript project that needs image processing, the SDK is the fastest path to production. ## Installation Install from npm: ```bash npm install @vectosolve/sdk ``` The package ships with TypeScript declarations included — no separate `@types` package needed. It supports Node.js 18+ and works with ESM and CommonJS. ## Authentication Every API call requires an API key. Create one at [vectosolve.com/developers](https://vectosolve.com/developers): 1. Sign in or create an account 2. Go to the **API Keys** section 3. Click **Create New Key** and copy it immediately (it will not be shown again) 4. Store it in an environment variable — never commit API keys to source control Then initialize the client: ```typescript import { VectoSolve } from '@vectosolve/sdk'; const client = new VectoSolve({ apiKey: process.env.VECTOSOLVE_API_KEY!, }); ``` :::tip Store your API key in `.env` or your secrets manager. The SDK reads from the constructor argument, not from environment variables directly, so you stay in control of how secrets are loaded. ::: ## Vectorize an Image The core feature: convert a raster image (PNG, JPG, WebP) into a clean, scalable SVG. ### From a File Path ```typescript import { VectoSolve } from '@vectosolve/sdk'; const client = new VectoSolve({ apiKey: process.env.VECTOSOLVE_API_KEY! }); const result = await client.vectorize({ file: './logo.png', }); // result.svg — the SVG string // result.creditsUsed — 0.20 // result.metadata — width, height, colors, pathCount await fs.writeFile('logo.svg', result.svg); ``` ### From a URL ```typescript const result = await client.vectorize({ url: 'https://example.com/image.png', }); ``` ### From a Buffer ```typescript const buffer = await fs.readFile('./input.png'); const result = await client.vectorize({ buffer, filename: 'input.png', }); ``` This flexibility means the SDK fits into any pipeline — whether you are reading files from disk, fetching them from S3, or receiving uploads from users. ## Remove Background Strip the background from any image and get back a transparent PNG. ```typescript const result = await client.removeBackground({ file: './product-photo.jpg', }); // result.image — Buffer of the transparent PNG // result.creditsUsed — 0.07 await fs.writeFile('product-no-bg.png', result.image); ``` At $0.07 per image, this is one of the most cost-effective background removal APIs available. It handles hair, fur, transparent objects, and complex edges. ## Upscale Increase image resolution by 2x or 4x using AI upscaling. Great for low-res logos or old graphics. ```typescript const result = await client.upscale({ file: './small-icon.png', scale: 4, // 2 or 4 }); // result.image — Buffer of the upscaled image // result.creditsUsed — 0.15 await fs.writeFile('icon-4x.png', result.image); ``` ## Generate a Logo Create an AI-generated logo from a text prompt, with control over style and colors. ```typescript const result = await client.generateLogo({ prompt: 'A mountain peak with aurora borealis, minimalist geometric style', style: 'geometric', // geometric | hand-drawn | vintage | modern | playful colors: ['#1cb721', '#0090ff', '#ffffff'], }); // result.svg — generated SVG logo // result.creditsUsed — 0.25 await fs.writeFile('logo.svg', result.svg); ``` The `style` parameter guides the visual direction. The `colors` array constrains the palette — useful when you need to match brand guidelines. ## Batch Processing Process multiple images in parallel with concurrency control: ```typescript import { VectoSolve } from '@vectosolve/sdk'; import fs from 'fs/promises'; import path from 'path'; const client = new VectoSolve({ apiKey: process.env.VECTOSOLVE_API_KEY! }); const imageDir = './images'; const files = await fs.readdir(imageDir); const pngFiles = files.filter(f => f.endsWith('.png')); // Process 5 images at a time const results = await client.batch( pngFiles.map(file => ({ method: 'vectorize', params: { file: path.join(imageDir, file) }, })), { concurrency: 5 } ); for (const result of results) { if (result.status === 'fulfilled') { const outPath = result.input.replace('.png', '.svg'); await fs.writeFile(outPath, result.value.svg); console.log(`Converted: ${outPath}`); } else { console.error(`Failed: ${result.input} — ${result.reason.message}`); } } ``` The batch method uses `Promise.allSettled` internally, so one failure does not abort the entire batch. Each result tells you whether it succeeded or failed, and why. ## Pricing Every method costs a fixed amount of credits. No hidden fees, no per-pixel charges. | Method | Cost per call | What you get | |---|---|---| | `vectorize()` | $0.20 | Clean SVG from any raster image | | `removeBackground()` | $0.07 | Transparent PNG, no background | | `upscale()` | $0.15 | 2x or 4x resolution increase | | `generateLogo()` | $0.25+ | AI-generated SVG logo from prompt | Credits never expire. API credits come in lots from $19.99 for 100 conversions — [see the developer page](https://vectosolve.com/developers). ## Error Handling The SDK throws typed errors so you can handle each case explicitly: ```typescript import { VectoSolve, InsufficientCreditsError, RateLimitError, VectoSolveError } from '@vectosolve/sdk'; const client = new VectoSolve({ apiKey: process.env.VECTOSOLVE_API_KEY! }); try { const result = await client.vectorize({ file: './image.png' }); console.log('SVG length:', result.svg.length); } catch (error) { if (error instanceof InsufficientCreditsError) { console.error('Out of credits. Buy more at vectosolve.com/pricing'); console.error('Current balance:', error.balance); } else if (error instanceof RateLimitError) { console.error('Rate limited. Retry after:', error.retryAfter, 'seconds'); } else if (error instanceof VectoSolveError) { console.error('API error:', error.message, 'Status:', error.status); } else { throw error; // unexpected error, re-throw } } ``` Every error extends `VectoSolveError`, so you can catch all API errors with a single `instanceof` check if you prefer a simpler approach. ## TypeScript Types The SDK exports all types you need for building type-safe integrations: ```typescript import type { VectorizeOptions, VectorizeResult, RemoveBackgroundOptions, RemoveBackgroundResult, UpscaleOptions, UpscaleResult, GenerateLogoOptions, GenerateLogoResult, BatchItem, BatchResult, VectoSolveConfig, } from '@vectosolve/sdk'; ``` Key interfaces: ```typescript interface VectorizeOptions { file?: string; // local file path url?: string; // remote image URL buffer?: Buffer; // raw image buffer filename?: string; // required when using buffer } interface VectorizeResult { svg: string; // the SVG markup creditsUsed: number; // credits consumed metadata: { width: number; height: number; colors: number; pathCount: number; fileSizeBytes: number; }; } interface VectoSolveConfig { apiKey: string; baseUrl?: string; // default: https://vectosolve.com/api/v1 timeout?: number; // default: 60000 (ms) retries?: number; // default: 2 } ``` These types work with any IDE that supports TypeScript — you get autocompletion, inline docs, and compile-time checks without reading documentation. ## Next Steps The TypeScript SDK is part of a growing developer ecosystem: - **[VectoSolve CLI](https://www.npmjs.com/package/vectosolve)** — convert images from the command line with `npx vectosolve vectorize image.png` - **[VectoSolve MCP Server](https://www.npmjs.com/package/@vectosolve/mcp)** — use VectoSolve tools inside AI agents (Claude, GPT, Cursor) - **[Developer Portal](https://vectosolve.com/developers)** — API reference, guides, and interactive playground - **[Pricing](https://vectosolve.com/pricing)** — monthly and annual plans The SDK is open-source. Found a bug or want a feature? Open an issue on GitHub. We ship updates weekly and follow semver, so you can update without surprises. --- Ready to integrate? Install the SDK and make your first API call in under 2 minutes: ```bash npm install @vectosolve/sdk ``` Visit [vectosolve.com/developers](https://vectosolve.com/developers) to create your API key and start building. --- *Maintained by VectoSolve. When citing, link to https://vectosolve.com/blog/vectosolve-typescript-sdk-image-vectorization-api.* *VectoSolve — AI-powered SVG platform: image-to-vector conversion, AI animation, brand identity generation, and more. https://vectosolve.com*