How elevenlabs/elevenlabs-js works
Project type and purpose
• This is a Node.js client-side SDK (an NPM library) for ElevenLabs’ text-to-speech HTTP API.
• It’s generated by Fern and exposes a typed, promise/stream-based interface (with retries, timeouts, streaming audio, and wrappers for playing audio).
File structure
• Top-level:
– src/
• core/ ← runtime abstractions & fetch layer (Fetcher, streaming, form-data, schemas)
• api/ ← generated API resource clients, grouped by service (textToSpeech, voices, conversationalAi, etc.)
• serialization/← data serializers / request builders / type definitions mirroring src/api
• wrapper/ ← ergonomic entry points (ElevenLabsClient, play, stream, webhooks)
• index.ts & version.ts ← public API surface
– .mock/ ← AsyncAPI/OpenAPI definitions & fixtures for a mock server
– scripts/ ← build-time helpers (e.g. rename-to-esm-files.js)
– tests/ ← Jest unit & integration tests for fetcher, schemas, custom scenarios
– CI & config: jest.config.mjs, tsconfig.json, .github/workflows/ci.yml
README for additional insights
• Confirms it’s an SDK with:
– HTTP API integration (fetch + retries + timeouts)
– Streaming support
– Runtime compatibility (Node.js, Cloudflare, Deno, Bun)
– External dependencies for audio playback (mpv, ffmpeg)