Skip to content

WaveSpeedAI JavaScript/TypeScript SDK — Official JS/TS SDK for WaveSpeedAI inference platform. This library offers a clean, unified, and high-performance API for your applications. Seamlessly connect to all WaveSpeedAI models and inference services, complete with serverless integration and zero infrastructure overhead.

License

Notifications You must be signed in to change notification settings

WaveSpeedAI/wavespeed-javascript

Repository files navigation

WaveSpeedAI logo

WaveSpeedAI JavaScript SDK

Official JavaScript/TypeScript SDK for the WaveSpeedAI inference platform

🌐 Visit wavespeed.ai📖 Documentation💬 Issues


Installation

npm install wavespeed

API Client

Run WaveSpeed AI models with a simple API:

const WaveSpeed = require('wavespeed');

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

const prediction = await client.run('wavespeed-ai/z-image/turbo', {
  prompt: 'Cat'
});

console.log(prediction.outputs[0]);  // Output URL

Or with TypeScript:

import WaveSpeed from 'wavespeed';

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

const prediction = await client.run('wavespeed-ai/z-image/turbo', {
  prompt: 'Cat'
});

console.log(prediction.outputs[0]);  // Output URL

Authentication

Set your API key via environment variable (You can get your API key from https://wavespeed.ai/accesskey):

export WAVESPEED_API_KEY="your-api-key"

Or pass it directly:

const WaveSpeed = require('wavespeed');

const client = new WaveSpeed('your-api-key');
const prediction = await client.run('wavespeed-ai/z-image/turbo', { prompt: 'Cat' });

Options

const prediction = await client.run(
  'wavespeed-ai/z-image/turbo',
  { prompt: 'Cat' },
  {
    timeout: 36000,         // Max wait time in seconds (default: 36000)
    pollInterval: 1,        // Status check interval (default: 1)
    enableSyncMode: false,  // Single request mode, no polling (default: false)
  }
);

Sync Mode

Use enableSyncMode: true for a single request that waits for the result (no polling).

Note: Not all models support sync mode. Check the model documentation for availability.

const prediction = await client.run(
  'wavespeed-ai/z-image/turbo',
  { prompt: 'Cat' },
  { enableSyncMode: true }
);

Retry Configuration

Configure retries at the client level:

const WaveSpeed = require('wavespeed');

const client = new WaveSpeed('your-api-key', {
  maxRetries: 0,            // Task-level retries (default: 0)
  maxConnectionRetries: 3,  // HTTP connection retries (default: 3)
  retryInterval: 1,         // Base delay between retries in seconds (default: 1)
});

Upload Files

Upload images, videos, or audio files:

const WaveSpeed = require('wavespeed');

const url = await client.upload('/path/to/image.png');
console.log(url);

Environment Variables

API Client

Variable Description
WAVESPEED_API_KEY WaveSpeed API key

License

MIT

About

WaveSpeedAI JavaScript/TypeScript SDK — Official JS/TS SDK for WaveSpeedAI inference platform. This library offers a clean, unified, and high-performance API for your applications. Seamlessly connect to all WaveSpeedAI models and inference services, complete with serverless integration and zero infrastructure overhead.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •