Skip to content

GenWaveLLC/svgmaker-sdk-node

Repository files navigation

SVGMaker SDK for Node.js

Official Node.js SDK for the SVGMaker API, providing a clean, type-safe interface for generating, editing, and converting SVG graphics using AI.

npm version License

Upgrading to v1.0.0

v1.0.0 includes breaking changes. If you're upgrading from v0.x, see the Migration Guide for full details. Top breaking changes:

  • Base URL changed — now targets api.svgmaker.io (automatic if using defaults)
  • client.convert restructured — old client.convert.configure(...) is now client.convert.aiVectorize.configure(...), plus new sub-clients for tracing, format conversion, and batch operations
  • styleParams redesigned — new style values (flat, line_art, engraving, ghibli, ...), advanced block removed, new text field added
  • Aspect ratio wide/tall removed — only auto, portrait, landscape, square remain
  • model parameter: New option on generate and edit — mutually exclusive with quality
  • Cloud storage no longer default — generate, edit, and AI vectorize no longer store results to cloud by default; pass storage: true to persist

Features

  • Complete API Coverage: Generate, edit, convert, optimize, and manage SVGs
  • TypeScript Native: Full type safety with comprehensive type definitions
  • Automatic Retries: Built-in retry logic with exponential backoff
  • Streaming Support: Real-time progress updates via Server-Sent Events
  • Input Validation: Zod-based schema validation for all requests
  • Dual Package: ESM and CommonJS support

Installation

npm install @genwave/svgmaker-sdk

Requires Node.js 18.0.0 or higher.

Quick Start

import { SVGMakerClient } from '@genwave/svgmaker-sdk';

const client = new SVGMakerClient('your-api-key');

// Generate an SVG
const result = await client.generate
  .configure({
    prompt: 'A minimalist mountain landscape',
    quality: 'high',
    svgText: true,
  })
  .execute();

console.log('SVG URL:', result.svgUrl);
console.log('Credits used:', result.creditCost);

// Edit an existing image
const edited = await client.edit
  .configure({
    image: './input.png',
    prompt: 'Add a red border',
    quality: 'medium',
  })
  .execute();

// AI-powered vectorization
const vectorized = await client.convert.aiVectorize
  .configure({ file: './photo.jpg', svgText: true })
  .execute();

// Stream progress for long operations
const stream = client.generate
  .configure({ prompt: 'A detailed cityscape', quality: 'high' })
  .stream();

for await (const event of stream) {
  if (event.status === 'complete') console.log('Done:', event.svgUrl);
}

Available Clients

Client Access Description
generate client.generate Create SVGs from text prompts
edit client.edit Modify existing images/SVGs with AI
convert.aiVectorize client.convert.aiVectorize AI-powered raster to SVG conversion
convert.trace client.convert.trace Algorithmic raster to SVG tracing
convert.svgToVector client.convert.svgToVector SVG to vector formats (PDF, EPS, DXF, AI, PS)
convert.rasterToRaster client.convert.rasterToRaster Convert between raster formats
convert.batch client.convert.batch Batch convert up to 10 files
enhancePrompt client.enhancePrompt Improve text prompts using AI
optimizeSvg client.optimizeSvg Optimize SVG files using SVGO
generations client.generations Manage your generations (list, download, share, delete)
gallery client.gallery Browse and download public gallery items
account client.account Account info and usage statistics

Most clients use the configure().execute() pattern. generations, gallery, and account use direct methods (e.g., client.generations.list(), client.account.getInfo()).

Error Handling

import { SVGMakerClient, Errors } from '@genwave/svgmaker-sdk';

try {
  const result = await client.generate
    .configure({ prompt: 'A landscape' })
    .execute();
} catch (error) {
  if (error instanceof Errors.RateLimitError) {
    console.error('Rate limited. Retry after:', error.retryAfter, 'seconds');
  } else if (error instanceof Errors.InsufficientCreditsError) {
    console.error('Insufficient credits. Required:', error.creditsRequired);
  } else if (error instanceof Errors.AuthError) {
    console.error('Authentication failed:', error.message);
  } else if (error instanceof Errors.APIError) {
    console.error('API error:', error.message, error.statusCode);
  }
}

See the SDK Documentation for the full list of error types.

Documentation

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see the LICENSE file for details.

Support

About

Official NodeJS SDK for SVGMaker - AI powered SVG creation and manipulation API client.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors