Expand description
§ElevenLabs Rust SDK
A comprehensive, async Rust SDK for the ElevenLabs API, providing text-to-speech, voice management, audio isolation, speech-to-text, and other audio AI capabilities.
§Quick Start
use elevenlabs_sdk::{ClientConfig, ElevenLabsClient, types::TextToSpeechRequest};
// Create client from environment variable ELEVENLABS_API_KEY
let config = ClientConfig::from_env()?;
let client = ElevenLabsClient::new(config)?;
// Text-to-speech
let request = TextToSpeechRequest::new("Hello from Rust!");
let audio_bytes = client.text_to_speech().convert("voice_id", &request, None, None).await?;
println!("Received {} bytes of audio", audio_bytes.len());
// List available voices
let voices = client.voices().list(None).await?;
for voice in &voices.voices {
println!(" {} ({})", voice.name, voice.voice_id);
}§Features
- Text-to-Speech — Convert text to natural-sounding speech with full and streaming endpoints, including character-level timestamp alignment.
- Voice Management — List, create, edit, and delete voices; manage voice settings and samples.
- WebSocket Streaming — Real-time TTS via input-streaming WebSocket, and conversational AI with bidirectional audio/text.
- Audio Isolation — Remove background noise from audio files.
- Speech-to-Text — Transcribe audio to text.
- Speech-to-Speech — Convert speech with a different voice.
- Sound Generation — Generate sound effects from text prompts.
- Models — Query available synthesis models.
- User & Workspace — Account and workspace management.
- Retry & Error Handling — Automatic retry with exponential backoff, structured error types with status codes and rate-limit info.
§Module Organization
| Module | Description |
|---|---|
auth | API key authentication and secure key handling |
config | Client configuration builder with env-var support |
error | Error types (ElevenLabsError) and Result alias |
client | HTTP client (ElevenLabsClient) with automatic auth |
types | Shared request/response types mirroring the OpenAPI spec |
services | Typed endpoint wrappers (TTS, voices, models, etc.) |
ws | WebSocket streaming (TTS input-streaming, conversational AI) |
Re-exports§
pub use auth::ApiKey;pub use client::ElevenLabsClient;pub use config::ClientConfig;pub use config::ClientConfigBuilder;pub use config::ConfigError;pub use error::ElevenLabsError;pub use error::Result;pub use services::AgentsService;pub use services::AudioIsolationService;pub use services::AudioNativeService;pub use services::ForcedAlignmentService;pub use services::HistoryService;pub use services::ModelsService;pub use services::MusicService;pub use services::PvcVoicesService;pub use services::SingleUseTokenService;pub use services::SoundGenerationService;pub use services::SpeechToSpeechService;pub use services::SpeechToTextService;pub use services::StudioService;pub use services::TextToDialogueService;pub use services::TextToSpeechService;pub use services::TextToVoiceService;pub use services::UserService;pub use services::VoiceGenerationService;pub use services::VoicesService;pub use services::WorkspaceService;pub use ws::conversation::ConversationEvent;pub use ws::conversation::ConversationWebSocket;pub use ws::tts::TtsWebSocket;pub use ws::tts::TtsWsConfig;pub use ws::tts::TtsWsResponse;
Modules§
- auth
- API key authentication for the ElevenLabs API.
- client
- HTTP client core for the ElevenLabs API.
- config
- Client configuration and builder for the ElevenLabs SDK.
- error
- Error types for the ElevenLabs SDK.
- services
- Service modules providing typed access to ElevenLabs API endpoints.
- types
- Shared types used across the ElevenLabs API.
- ws
- WebSocket streaming support for the ElevenLabs API.