elevenlabs/elevenlabs-js

The official JavaScript (Node) library for the ElevenLabs API.

What it solves

This library provides a streamlined way for developers to integrate ElevenLabs' lifelike AI voices into Node.js applications. It eliminates the need to manually handle HTTP requests to the ElevenLabs API, providing a type-safe, structured way to generate speech from text, manage voices, and build interactive voice AI agents.

How it works

The SDK acts as a wrapper around the ElevenLabs HTTP API. It allows developers to specify a voice ID and text, then choose from several specialized models (such as the high-stability Multilingual v2, ultra-low latency Flash v2.5, or the balanced Turbo v2.5) to generate audio. It supports both direct audio conversion and real-time streaming of audio as it is generated.

For more advanced interactive agents, the "Speech Engine" feature allows developers to connect a custom LLM (like GPT-4o) to ElevenLabs via WebSockets. The SDK can either be attached to an existing HTTP server (like Express or Next.js) or run as a standalone server, handling the transcription of user speech and streaming the LLM's response back as speech.

Who it’s for

Node.js developers building voice-powered applications, AI agents, or content creation tools that require high-quality, multilingual AI speech synthesis.

Highlights

  • Multiple Specialized Models: Support for models optimized for different needs, including low latency and wide language diversity (up to 32 languages).
  • Real-time Streaming: Ability to stream audio output in real-time for faster perceived response times.
  • Speech Engine for Agents: Built-in support for creating voice-powered AI agents by connecting LLMs to ElevenLabs via WebSockets.
  • Broad Runtime Compatibility: Works across Node.js, Vercel, Cloudflare Workers, Deno, and Bun.
  • Automatic Retries: Built-in exponential backoff for handling common API errors (408, 409, 429, 5XX).

Related

  • Project
  • Project
  • Project
  • Project
  • Project