npm install wavespeedRun 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 URLOr 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 URLSet 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' });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)
}
);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 }
);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 images, videos, or audio files:
const WaveSpeed = require('wavespeed');
const url = await client.upload('/path/to/image.png');
console.log(url);| Variable | Description |
|---|---|
WAVESPEED_API_KEY |
WaveSpeed API key |
MIT