Skip to main content

Overview

While SDKs and frameworks provide convenience, sometimes you need direct control over API calls. This tutorial shows how to call the Camb.ai TTS API directly using HTTP requests.

When to Use Direct API

  • Building integrations in languages without an SDK
  • Need fine-grained control over request/response handling
  • Debugging or testing API behavior
  • Building custom streaming implementations

Listen to an Example

Prerequisites

1

Create an account

Sign up at CAMB.AI Studio if you haven’t already.
2

Get your API key

Go to Settings → API Keys in Studio and copy your key. See Authentication for details.

Basic TTS Request

POST /tts-stream returns a binary audio byte stream (for example audio/wav or audio/mpeg), not Server-Sent Events or JSON chunks. The server sends the Content-Type that matches your output_configuration.format. You can buffer the full body for short clips, or read in chunks for lower latency—see Stream Text-to-Speech Audio.

Streaming Response

For real-time playback, iterate over the raw response body as chunks arrive. Always validate the status before reading the stream—non-success responses may return JSON (for example validation errors), not audio. Responses can include the X-Credits-Required header for usage tracking (see the API reference).

Request Parameters

These fields match Stream Text-to-Speech Audio and the OpenAPI schema for POST /tts-stream.

Required Parameters

Optional Parameters

More details available in the API Reference. mars-instruct does not support mp3 or pcm_s16be (see Output format support by model in the API reference).

Expressive and pronunciation controls

  • mars-8.1-flash-beta / mars-8.1-pro-beta: English CMU phoneme overrides (e.g. [B EY1 S]) and non-verbal tags such as [laughter]—see MARS 8.1 Beta Text Controls in the API reference.
  • mars-instruct: Emotion and pacing tags and SSML-style pauses in text, plus optional user_instructions for broader delivery guidance—examples below.
When you use speech_model: "mars-instruct", you can encode expression directly in the text field and use user_instructions for the overall style. English examples:
  • [speaking slowly] This is very important. Please pay close attention.
  • [excited] We shipped the feature, and the response has been fantastic!
  • Let's pause for a moment <break time="400ms"/> and continue clearly.
For a comprehensive guide on emotional expression, pauses, and prosody control, see the Emotional Voice Control tutorial.

Listing Voices

Get available voices:

Playing Audio


Next Steps

Python SDK

Use the SDK for simpler integration

API Reference

Complete API documentation
https://mintcdn.com/cambai/2LvnefIkletroPxv/images/pipecat-orange.svg?fit=max&auto=format&n=2LvnefIkletroPxv&q=85&s=40cf8e001b8cadc8a4c3c557dea603d5

Voice Agents

Build real-time voice applications

Voice Library

Browse available voices