ElevenLabs Rust SDK
Unofficial Rust SDK for the ElevenLabs API. Provides typed access to all REST endpoints and WebSocket streaming.
Features
- Full API Coverage: 220+ endpoints across Text-to-Speech, Speech-to-Text, Voices, Dubbing, Studio, Conversational AI, and more
- WebSocket Streaming: Real-time TTS input-streaming and Conversational AI via WebSocket
- Type-Safe: Strongly typed request/response types generated from the official OpenAPI spec
- Async/Await: Built on
tokioandhpxfor async HTTP - Automatic Retries: Configurable retry with exponential backoff
- Error Handling: Typed errors with status codes and rate-limit info
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use ;
use TextToSpeechRequest;
async
Available Services
| Service | Method | Description |
|---|---|---|
| Text-to-Speech | text_to_speech() |
Convert text to speech (full & streaming) |
| Voices | voices() |
Voice management, library, and settings |
| Speech-to-Speech | speech_to_speech() |
Voice conversion |
| Speech-to-Text | speech_to_text() |
Audio transcription |
| Audio Isolation | audio_isolation() |
Background noise removal |
| Audio Native | audio_native() |
Audio Native project management |
| Sound Generation | sound_generation() |
Generate sound effects from text |
| Text-to-Dialogue | text_to_dialogue() |
Dialogue generation |
| Text-to-Voice | text_to_voice() |
Voice design from text prompts |
| Voice Generation | voice_generation() |
Generate random voices |
| Dubbing | dubbing() |
Video/audio dubbing |
| Studio | studio() |
Studio project management |
| Music | music() |
Music generation |
| Models | models() |
List available models |
| History | history() |
Speech generation history |
| User | user() |
User info and subscription |
| Workspace | workspace() |
Workspace management |
| Forced Alignment | forced_alignment() |
Audio-text alignment |
| Single-Use Token | single_use_token() |
Generate ephemeral tokens |
| Agents | agents() |
Conversational AI agents |
WebSocket Streaming
use ;
async
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
ELEVENLABS_API_KEY |
API key (required) | — |
ELEVENLABS_BASE_URL |
Custom base URL | https://api.elevenlabs.io |
Builder Pattern
use ;
let config = default
.api_key
.base_url
.timeout
.max_retries
.build?;
let client = new?;
Examples
Run the bundled examples with your API key:
ELEVENLABS_API_KEY=your-key
ELEVENLABS_API_KEY=your-key
ELEVENLABS_API_KEY=your-key
ELEVENLABS_API_KEY=your-key
Development
Project Structure
crates/elevenlabs-sdk/
├── src/
│ ├── lib.rs # Public API re-exports
│ ├── client.rs # ElevenLabsClient with HTTP + retry logic
│ ├── config.rs # ClientConfig builder
│ ├── auth.rs # API key handling
│ ├── error.rs # Error types
│ ├── middleware.rs # Request middleware
│ ├── services/ # Typed endpoint wrappers (one module per API group)
│ ├── types/ # Request/response structs from OpenAPI spec
│ └── ws/ # WebSocket streaming (TTS, Conversational AI)
├── examples/ # Runnable examples
└── tests/ # Integration tests
License
Apache-2.0