An unofficial Rust crate for ElevenLabs.
MSRV: Rust 1.85.
Features
Default features are intentionally slim for 0.7: only native TLS is enabled.
Opt into the product areas you use:
= { = "0.7", = ["genai"] }
= { = "0.7", = ["convai"] }
= { = "0.7", = ["admin"] }
= { = "0.7", = ["genai", "ws"] }
= { = "0.7", = ["genai", "playback"] }
TLS choices are native-tls, native-tls-vendored, rustls, and
rustls-webpki-roots. Disable default features when selecting a non-default TLS
stack.
Text To Speech
use ;
use ;
async
Enable playback if you want to use elevenlabs_rs::utils::play.
Errors And Metadata
The crate returns a typed Error. Non-success HTTP responses are reported as
Error::ApiError with the status, raw body, parsed JSON error metadata, headers,
request or trace IDs, and character cost when ElevenLabs returns those values.
Use hit_with_metadata when response headers matter:
let response = client.hit_with_metadata.await?;
println!;
println!;
Raw Endpoints
Use the raw builder when ElevenLabs ships an endpoint before this crate models it:
use ;
use ;
async
Raw requests still use this crate's auth, base URL, query handling, body encoding, typed errors, and metadata support.
WebSockets
Enable genai and ws for realtime TTS, multi-context TTS, and realtime STT.
The connect_* methods return a WebSocketSession<T>, which is both a stream of
inbound messages and a lifecycle handle with close, abort, is_closed, and
join.
Prefer explicit close().await when a session is finished. Dropping a session is
safe and aborts background tasks as a fallback.
Uploads
Upload-heavy endpoints accept FilePart, which can be backed by either a path or
in-memory bytes. Most upload request bodies also expose from_bytes constructors
for tests, services, and non-filesystem inputs.