The official Rust SDK for Camb.ai provides access to text-to-speech, dubbing, translation, transcription, audio separation, voice cloning, audio generation, stories, translated TTS, translated stories, dictionaries, folders, project setup, and streaming pipelines. The client is async-only and built on Tokio.Documentation Index
Fetch the complete documentation index at: https://docs.camb.ai/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Add the crate and Tokio to yourCargo.toml:
camb_api package name matches the crate defined in the SDK repository.
Authentication
Get your API key from Camb.ai Studio and read it from the environment so it never appears in source control. Build the client withAPIClient::new and ClientConfig.
Quick Start
Streaming TTS returns aByteStream. The SDK does not include a file helper, so write chunks with std::io::Write after each try_next call on the stream.
Models
Streaming TTS acceptsspeech_model as CreateStreamTtsRequestPayloadSpeechModel. The Rust enum serializes to the wire values in the table. If you omit speech_model, the API applies its default.
| Variant | Wire value | Notes |
|---|---|---|
Auto | auto | Server-selected model |
Mars6 | mars-6 | Earlier MARS generation |
Mars7 | mars-7 | MARS 7 generation |
Mars8 | mars-8 | MARS 8 generation |
Mars8Flash | mars-8-flash | Lower-latency MARS 8 |
Mars8Instruct | mars-8-instruct | Instruction-style control via user_instructions and bracketed text |
- Mars8Flash
- Mars8
- Mars8Instruct
Text-to-Speech
Streaming
text_to_speech.tts posts to tts-stream and returns audio chunks as ByteStream, as shown in Quick Start.
Submit, poll, and fetch
Non-streaming TTS usescreate_tts to obtain a task_id, polls get_tts_result until TaskStatus::Success, then reads the run with get_tts_run_info.
Voices
List voices
voice_cloning.list_voices returns a vector of ListVoicesListVoicesGetResponseItem values. Print or deserialize each entry to read fields such as identifiers for use in TTS.
Create a custom voice
create_custom_voice sends multipart form data. Load reference audio into a Vec<u8>. Gender is a numeric newtype: use the value expected by your account and endpoint documentation (for example Gender(1)).
Language support
Dubbing, translation, transcription, and related jobs useLanguages, a newtype around i64 with constants such as Languages::EN_US and Languages::HI_IN.
Streaming TTS uses the separate enum CreateStreamTtsRequestPayloadLanguage (for example CreateStreamTtsRequestPayloadLanguage::EnUs), which serializes to locale strings.
languages.get_source_languages and languages.get_target_languages.
Dubbing
dub.end_to_end_dubbing starts a job. Poll dub.get_end_to_end_dubbing_status until status is TaskStatus::Success, then call get_dubbed_run_info with the run_id from the status payload. Optional get_dubbed_run_transcript returns transcript data for a target language.
target_languages to Some(Some(vec![Languages::FR_FR, Languages::ES_ES])) and set target_language to None.
Translation
translation.create_translation returns serde_json::Value. Read task_id from the JSON, poll get_translation_task_status, then call get_translation_result with the resolved run_id.
For streaming translation over a single string, use
translation.translation_stream with CreateTranslationStreamRequestPayload and inspect the returned serde_json::Value shape for your integration.Transcription
transcription.create_transcription accepts multipart fields including media_url or media_file. Poll get_transcription_task_status, then get_transcription_result with optional word-level timestamps.
media_file to Some(bytes) and clear media_url.
Audio separation
Uploadmedia_file via multipart, poll get_audio_separation_status, then read get_audio_separation_run_info.
Text-to-voice
Create a job withcreate_text_to_voice, poll get_text_to_voice_status, then load previews and identifiers from get_text_to_voice_result.
Inspect
get_text_to_voice_result for preview URLs and the voice_id to pass into text_to_speech.tts for production speech.Text-to-audio
create_text_to_audio starts an asynchronous sound or music generation job. After success, get_text_to_audio_result returns a ByteStream for the audio bytes.
Stories
story.create_story uploads a document as multipart data. The response is CreateStoryStoryPostResponse; the common async path exposes OrchestratorPipelineCallResult with a task_id. Poll get_story_status, then call get_story_run_info.
Translated TTS
translated_tts.create_translated_tts returns CreateTranslatedTtsOut with a task_id. Poll get_translated_tts_task_status until the status is success.
Translated story
Add a target language to an existing story run withcreate_translation_for_existing_story. Poll get_translated_story_status, then read get_translated_story_run_info using the original story run_id and the target Languages value.
Dictionaries
List dictionaries
Create from file
Manage terms
TermTranslationInput pairs a translation string with a Languages value. Dictionary and term identifiers are numeric.
Folders
Project setup
project_setup.create_project accepts a public media_url, a source_language, and a target_languages list. The call returns CreateProjectSetupOut with a task_id. Poll create_project_setup_task_status until the returned vector includes a row, read run_id from that row, then call get_project_setup_result.
Streaming pipelines
Thestreaming client manages long-running stream resources: create_stream, get_stream_result, patch_stream_data, destroy_stream, and get_probe_stream. CreateStreamRequestPayload ties together ConfigStream, SourceStream, and one or more TargetStream values. StreamType is a numeric newtype (StreamType(i64)); use the stream type codes from your deployment or API reference.
Error handling
Failures surface asApiError. Match on ApiError::UnprocessableEntityError for validation-style 422 responses, ApiError::Http for other status codes, and ApiError::Network for transport errors.
RequestOptions as the last argument to tune timeouts and retries for a single call.
Custom provider
Self-hosted MARS on Baseten can call theTtsProvider trait. BasetenProvider::new takes the Baseten API key and an optional deployment URL. See Custom Cloud Providers for deployment details.
Next steps
Voice Agents
Build real-time voice agents with Pipecat
LiveKit Integration
Create voice agents with LiveKit
API Reference
Explore the full TTS API
Voice Library
Browse available voices