Official Node.js SDK for the SVGMaker API, providing a clean, type-safe interface for generating, editing, and converting SVG graphics using AI.
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.convertrestructured — oldclient.convert.configure(...)is nowclient.convert.aiVectorize.configure(...), plus new sub-clients for tracing, format conversion, and batch operationsstyleParamsredesigned — new style values (flat,line_art,engraving,ghibli, ...),advancedblock removed, newtextfield added- Aspect ratio
wide/tallremoved — onlyauto,portrait,landscape,squareremain modelparameter: New option on generate and edit — mutually exclusive withquality- Cloud storage no longer default — generate, edit, and AI vectorize no longer store results to cloud by default; pass
storage: trueto persist
- 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
npm install @genwave/svgmaker-sdkRequires Node.js 18.0.0 or higher.
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);
}| 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()).
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.
- Migration Guide - Upgrading from v0.x to v1.0.0
- SDK Documentation - Full SDK reference with detailed examples for every client
- API Documentation - REST API reference with endpoint details and credit costs
- Legacy API Documentation - Pre-v1 API reference
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Repository: GitHub Repository