Skip to main content
The official TypeScript SDK for Camb.ai provides convenient access to text-to-speech, dubbing, translation, transcription, audio separation, voice cloning, and audio generation. Every method returns a promise, the package ships as ES modules, and saveStreamToFile handles audio output in one call.

Installation

Requires Node.js 18 or higher. The package is published as @camb-ai/sdk and ships as ES modules.

Authentication

Get your API key from Camb.ai Studio and read it from process.env.CAMB_API_KEY so it never appears in source control. Every API call on CambClient returns a promise. There is no synchronous client: wrap usage in async functions and use await throughout.
Use dotenv to load CAMB_API_KEY from a .env file during local development.

Quick Start

Streaming TTS returns binary data that saveStreamToFile writes to disk. await client.textToSpeech.tts(...) resolves to a stream object the helper understands.

Models

Camb.ai offers MARS models tuned for different quality and latency requirements. Pass speech_model using CambApi.CreateStreamTtsRequestPayload.SpeechModel. If you omit it, the API applies its default model. The tab snippets below assume the same client and CambApi imports as in Quick Start.
Best for: Voice agents, real-time applicationsSample rate: 22.05 kHz

TTS Options

The client.textToSpeech.tts(...) method accepts the core request fields plus optional controls for model behavior and output format.

Voices

List voices

listVoices() returns every voice available to your account, including library voices and custom clones. Use the returned id (or equivalent field from the typed response) as voice_id in TTS calls.

Create a custom voice

Upload a short reference clip with a display name and gender. Set enhance_audio when the recording may contain noise so the API can preprocess the clip before cloning.

Language support

TTS requests use string locale values through CambApi.CreateStreamTtsRequestPayload.Language (for example Language.EnUs maps to "en-us"). See Language Support for the full per-model locale list. Dubbing, translation, transcription, and several other endpoints use the numeric CambApi.Languages enum so the wire format matches the REST API exactly.
Fetch the canonical list of supported languages from the API when you need to populate UI or validate user input.
Languages supported per model are listed at MARS Models.

Dubbing

The dubbing client translates the audio track of a remote video and resynthesizes speech with cloned voices. In TypeScript the entry point is endToEndDubbing, not the Python name create_dub. You submit a job, poll getEndToEndDubbingStatus until status is success, then read URLs from getDubbedRunInfo.
To dub into several targets in one job, pass target_languages instead of target_language.

Get transcript

After a successful run, getDubbedRunTranscript returns transcript text keyed by field name for the requested target language.

Translation

createTranslation accepts an array of strings and returns translations in the same order. The workflow matches dubbing: create a task, poll getTranslationTaskStatus, then call getTranslationResult with the run_id from the status payload.
For streaming translation over a single string, see client.translation.translationStream in the generated client types.

Transcription

Send either media_url or a local media_file. Poll until the task succeeds, then request structured text (optionally with word-level timestamps) from getTranscriptionResult.
To transcribe a local file, pass a stream or buffer-compatible upload as media_file instead of media_url.

Audio separation

Audio separation splits a mixed recording into stems. Upload media_file, poll getAudioSeparationStatus, then read stem metadata from getAudioSeparationRunInfo.

Text-to-voice

Text-to-voice synthesizes a new voice timbre from a written description and sample line. The pipeline is asynchronous: create the job, poll status, then inspect getTextToVoiceResult for preview URLs and identifiers you can feed back into TTS.
Inspect the getTextToVoiceResult payload for preview URLs and the voice_id you should pass into textToSpeech.tts for production speech.

Text-to-audio

Text-to-audio generates sound effects or ambient beds from a prompt. The create call returns a task_id. After polling succeeds, getTextToAudioResult returns streaming audio that saveStreamToFile can persist.

Stories

The story endpoint ingests a text or Word document, builds narration, and returns run metadata when processing completes. Pass source_language as CambApi.Languages and stream the document as file.

Translated TTS

Translated TTS translates text and renders speech in the target language in one pipeline. The TypeScript client exposes createTranslatedTts and getTranslatedTtsTaskStatus. When the status reports success, inspect the status object and the API reference for URLs or identifiers your integration should download.

Dictionaries

Dictionaries store glossary rows that dubbing and translation jobs can consume automatically. Upload bulk CSV files or manage individual terms through the JSON endpoints.

List dictionaries

Create from file

Manage terms

Each translation row pairs a string with a CambApi.Languages value. Use numeric dictionary and term identifiers returned by previous API calls.

Folders

List or create folders with client.folders.listFolders({}) and client.folders.createFolder({ folder_name: "..." }) when you need to organize runs in Studio.

Error handling

Failed HTTP responses throw CambApiError. Validation failures surface as CambApi.UnprocessableEntityError, which extends CambApiError and carries the parsed body.
Pass requestOptions on any call to override timeouts or retries for that request.

Custom provider

Self-hosted MARS on Baseten reuses textToSpeech.tts, but you must construct CambClient with ttsProvider: "baseten" and supply providerParams. Baseten also requires base64 reference_audio and a reference_language entry inside additional_body_parameters on each TTS request. See Custom Cloud Providers for deployment details.

Baseten

Baseten validates reference_audio and reference_language. You can supply only ttsProvider and providerParams if you never call the default Camb.ai API, or include apiKey when you use both hosted and Baseten routes in one process.

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

Resources