This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
WaveSpeed JavaScript/TypeScript SDK - Official JavaScript/TypeScript SDK for WaveSpeedAI inference platform.
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage# Build the TypeScript code
npm run build
# Clean and rebuild
rm -rf dist && npm run build# Install dependencies
npm install
# Run linter
npm run lint
# Format code (if configured)
npm run formatsrc/
├── index.ts # Main entry point
├── version.ts # Version info
├── config.ts # Configuration (api class)
└── api/
├── index.ts # Convenience functions (run, upload)
└── client.ts # Client class implementation
Primary way (recommended):
import Client from 'wavespeed';
const client = new Client('your-api-key');
const result = await client.run('model-id', input);Convenience functions (Python-style):
import { run, upload } from 'wavespeed';
const result = await run('model-id', input);
const url = await upload('/path/to/file');Client- Main client class (formerly WaveSpeed)RunOptions- Options for run callsapi- Configuration class (from config.ts)- Convenience functions:
run(),upload()use default client singleton
- Async/Await: Modern promise-based API
- Sync Mode: Single request that waits for result (
enableSyncMode) - Retry Logic: Configurable task-level and connection-level retries
- Timeout Control: Per-request and overall timeouts
- File Upload: Direct file upload to WaveSpeed storage
- TypeScript Support: Full type definitions included
Client-level configuration:
baseUrl- API base URLpollInterval- Polling interval in secondstimeout- Overall timeout in secondsmaxRetries- Task-level retriesmaxConnectionRetries- HTTP connection retriesretryInterval- Base retry delay in seconds
Per-request configuration via RunOptions:
timeout- Override timeoutpollInterval- Override poll intervalenableSyncMode- Use sync modemaxRetries- Override retry count
WAVESPEED_API_KEY- API keyWAVESPEED_BASE_URL- Base URL (default: https://api.wavespeed.ai)WAVESPEED_POLL_INTERVAL- Poll interval in secondsWAVESPEED_TIMEOUT- Timeout in secondsWAVESPEED_REQUEST_TIMEOUT- Per-request timeout (internal)
src/
├── index.ts # Main entry, exports everything
├── version.ts # Version from package.json
├── config.ts # Configuration (api class)
└── api/
├── index.ts # Convenience functions + default client
└── client.ts # Client class implementation
tests/
├── client.test.ts # Core client tests
├── wavespeed.test.ts # Full test suite
dist/
├── index.js # Compiled JavaScript
├── index.d.ts # TypeScript definitions
├── api/
│ ├── index.js
│ ├── index.d.ts
│ ├── client.js
│ └── client.d.ts
├── config.js
├── config.d.ts
├── version.js
└── version.d.ts
Tests are located in tests/ directory and use Jest:
- Client initialization tests
- Run method tests
- Sync mode tests
- Retry logic tests
- Upload functionality tests
This project uses npm version with Git tags for versioning. See VERSIONING.md for details.
To create a release:
- Ensure all changes are committed
- Bump version:
npm version patch|minor|major - Push changes:
git push origin main --tags - GitHub Actions will automatically publish to npm
This project is written in TypeScript and provides full type definitions. The TypeScript configuration is in tsconfig.json.
Build artifacts are in the dist/ directory and include both JavaScript and TypeScript declaration files.