CambAIClient for common workflows and generated API classes for the rest of the HTTP surface. The SDK is synchronous: call APIs from your PHP process or queue workers and poll until asynchronous jobs finish.
Installation
Requires PHP 8.1 or later and Composer. Add the Camb.ai repository and package to yourcomposer.json:
Authentication
Get your API key from Camb.ai Studio and read it from an environment variable so it never appears in source control.CambAIClient wires TTS (via a provider), Text-to-Voice, Text-to-Audio, and Dubbing. Other endpoints use generated *Api classes with a shared Configuration and Guzzle client. There is no separate async client in PHP: run blocking calls in requests or workers.
$httpClient and $config assume you built them as shown. CambAIClient already applies the same API key and timeout internally.
Quick Start
Streaming TTS returns a readable stream.DefaultTtsProvider::tts() maps to the streaming endpoint. Read the stream in chunks and write them to disk.
Non-streaming TTS
If you need a task-based TTS job instead of streaming, callcreateTts() on the same provider, poll task status, then fetch run metadata.
$ttsRunInfo holds download URLs and metadata for the synthesized audio.
Models
Camb.ai offers MARS models tuned for different quality and latency requirements. Passspeech_model on streaming payloads using CreateStreamTTSRequestPayload constants or string literals. If you omit it, the API applies its default model.
| Model | Sample Rate | Best For |
|---|---|---|
mars-8.1-flash-beta | 48 kHz | Faster MARS 8.1 generation; same quality improvements as mars-8.1-pro-beta |
mars-8.1-pro-beta | 48 kHz | Improved pronunciation, expressiveness, and prosody over mars-pro |
mars-flash | 22.05 kHz | Low-latency real-time applications and conversational AI |
mars-pro | 48 kHz | High-fidelity audio production and long-form content |
mars-instruct | 22.05 kHz | Fine-grained tone and style control via text instructions |
$client from Quick Start.
- MARS Flash
- MARS Pro
- MARS Instruct
TTS Options
Streaming TTS usesCreateStreamTTSRequestPayload. Set the core request fields plus optional controls before calling $client->tts()->tts($payload).
| Setter | Description |
|---|---|
setText(...) | Text to synthesize. For MARS Instruct, you can include inline emotion or pacing tags in the text. |
setLanguage(...) | Locale such as CreateStreamTTSRequestPayload::LANGUAGE_EN_US. |
setVoiceId(...) | Voice profile ID from listVoicesListVoicesGet(). |
setSpeechModel(...) | Model to use, such as SPEECH_MODEL_MARS_FLASH, SPEECH_MODEL_MARS_PRO, or SPEECH_MODEL_MARS_INSTRUCT. |
setUserInstructions(...) | Adds style, tone, pronunciation, or delivery guidance for the request. Available only with MARS Instruct. |
setOutputConfiguration(...) | Output settings such as audio format. |
setVoiceSettings(...) | Voice behavior controls such as speaking rate, reference enhancement, or accent preservation. |
setInferenceOptions(...) | Advanced generation controls for supported models. |
setEnhanceNamedEntitiesPronunciation(...) | Improves pronunciation for names and other named entities when supported. |
Voices
VoiceCloningApi lists voices and creates custom voices. Instantiate it with $httpClient and $config from Authentication.
List voices
CalllistVoicesListVoicesGet() to retrieve voices on your account. The id field is the voice_id you pass to TTS.
Create a custom voice
Upload a reference clip asSplFileObject. Set Gender using the numeric enum values exposed on the model class (for example Gender::NUMBER_1). Optional enhance_audio helps noisy recordings.
Language Support
Camb.ai supports up to 312 languages depending on the MARS model â see Language Support for the full per-model locale list. PreferLanguages enum values on payloads so editors catch invalid codes.
LanguagesApi with the same configuration pattern as voice cloning.
Dubbing
End-to-end dubbing takes a public video URL, translates the track, and synthesizes speech that matches the speaker. Submit the job, poll status, then read URLs from the dubbing result.Get transcript
After a successful dub, fetch the transcript for a target language usinggetDubbedRunTranscriptTranscriptRunIdLanguageGet().
Translation
Translation accepts an ordered list of strings and returns translations in the same order. Submit a job, pollgetTranslationTaskStatusTranslateTaskIdGet(), then load results with getTranslationResultTranslationResultRunIdGet().
createTranslationTranslatePost() processes every string in texts in a single job and preserves ordering in the result. The OpenAPI client types this response as mixed, so the JSON-decoded object exposes task_id as a property rather than getTaskId().Transcription
Send audio or video by URL or as an uploaded file. PollgetTranscriptionTaskStatusTranscribeTaskIdGet(), then call getTranscriptionResultTranscriptionResultRunIdGet() with optional word-level timestamps.
SplFileObject as the file argument (fifth parameter).
Audio Separation
Separation splits a mixed recording into stems. Upload media withcreateAudioSeparationAudioSeparationPost(), poll getAudioSeparationStatusAudioSeparationTaskIdGet(), then read getAudioSeparationRunInfoAudioSeparationResultRunIdGet().
Text-to-Voice
Text-to-Voice generates a new voice from a written description.CambAIClient exposes textToVoice. Poll until TaskStatus::SUCCESS, then inspect previews from getTextToVoiceResultTextToVoiceResultRunIdGet().
Preview URLs let you audition variations. Use the voice ID you choose with streaming TTS when you move to production.
Text-to-Audio
Text-to-Audio turns a descriptive prompt into sound effects or ambience. UsetextToAudio on the client, poll status, then stream the WAV result to disk.
Stories
The Stories API ingests a document, builds narration, and returns audio output. UseStoryApi with createStoryStoryPost(), poll getStoryStatusStoryTaskIdGet(), then load getStoryRunInfoStoryResultRunIdGet().
Translated TTS
Translated TTS runs translation and synthesis together. UseTranslatedTTSApi, poll getTranslatedTtsTaskStatusTranslatedTtsTaskIdGet(), and inspect the orchestrator payload when the job succeeds.
Dictionaries
Dictionaries store term mappings for dubbing and translation workflows.List dictionaries
Create from file
Manage terms
TermTranslationInput pairs localized text with a Languages value. Build AddDictionaryTermPayload and call addTermToDictionaryDictionariesDictionaryIdAddTermPost().
Custom Provider
If you self-host MARS on Baseten or another backend, implementTtsProviderInterface and register it with setTtsProvider(). See Custom Cloud Providers for deployment details.
Baseten
Point the provider at your deployment URL and supply credentials from the environment.BasetenTtsProvider.php from the SDK examples folder into your project (next to the script or on your include path) so the require_once resolves.
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