Skip to main content
This guide walks you through making your first CAMB.AI API call to generate speech from text.

Prerequisites

  1. A CAMB.AI account (sign up at studio.camb.ai)
  2. Your API key (see Authentication)
1

Install the SDK

pip install camb-sdk
2

Generate Speech

from camb.client import CambAI

client = CambAI(api_key="YOUR_API_KEY")

# Generate speech
audio = client.tts.generate(
    text="Hello! Welcome to CAMB AI.",
    voice_id=147320
)

# Save to file
with open("output.wav", "wb") as f:
    f.write(audio)

print("Audio saved to output.wav")
3

Play the Audio

Open output.wav with any audio player to hear the generated speech.

Option 2: Using cURL

curl -X POST "https://client.camb.ai/apis/tts-stream" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello! Welcome to CAMB AI.",
    "voice_id": 147320,
    "language": "en-us",
    "speech_model": "mars-pro"
  }' \
  --output output.wav

Option 3: Using the API Directly

import requests

response = requests.post(
    "https://client.camb.ai/apis/tts-stream",
    headers={
        "x-api-key": "YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "text": "Hello! Welcome to CAMB AI.",
        "voice_id": 147320,
        "language": "en-us",
        "speech_model": "mars-pro"
    }
)

with open("output.wav", "wb") as f:
    f.write(response.content)

Understanding the Response

The API returns raw audio data by default. Key parameters:
ParameterDescription
textThe text to convert to speech
voice_idID of the voice to use (147320 is a default English voice)
languageLanguage code (e.g., en-us, es-es, fr-fr)
speech_modelModel variant: mars-flash, mars-pro, or mars-instruct

Output Formats

Specify the output format in output_configuration:
{
  "output_configuration": {
    "format": "wav"  // Options: "pcm_s16le", "wav", "mp3"
  }
}

Explore Voices

List available voices to find the right one for your use case:
curl -X GET "https://client.camb.ai/apis/list-voices" \
  -H "x-api-key: YOUR_API_KEY"

Next Steps