Example: Half-cascade with Cartesia
Example: Half-cascade with Cartesia
For the complete documentation index, see llms.txt.
Overview
This half-cascade example uses OpenAI Realtime for speech‑to‑text and reasoning, then sends OpenAI text responses to Cartesia Realtime TTS.
⬇️ Jump to the Full VoxEngine scenario.
Demo video
OpenAI + Cartesia demo:
Video link: OpenAI + Cartesia demo
Prerequisites
- Store your OpenAI API key in Voximplant Secrets under
OPENAI_API_KEY. - (Optional) Update the
CARTESIA_VOICE_IDconstant in the example to your preferred voice. - (Optional) Store your Cartesia API key in Voximplant Secrets under
CARTESIA_API_KEYif you want to use your own Cartesia account.
How it works
- OpenAI runs
gpt-realtime-2.1in text mode (output_modalities: ["text"]). - Caller audio is sent to OpenAI:
call.sendMediaTo(voiceAIClient). - The first completed OpenAI text response initializes the Cartesia player; later responses use
generationRequest(...). Cartesia streams the generated speech to the call. - When OpenAI detects caller speech, the scenario clears both the OpenAI and Cartesia output buffers.
Developer notes
- Do not set audio format parameters in half-cascade connector requests. VoxEngine’s WebSocket gateway handles media format negotiation automatically.
- If no Cartesia API key is provided, Voximplant’s default account and billing are used.
- Custom or cloned voices are only available when using your own API key.
- Cartesia TTS requires real text when initializing the player; do not pass
""or" ". - Subsequent turns use
generationRequest(...)with the samevoice,model_id, andlanguage.
Full VoxEngine scenario
Notes
- The example uses the
sonic-2model. Adjust the voice or output settings to match your telephony requirements.
This example runs gpt-realtime-2.1 using the Realtime 2.x session shape, with input settings nested under session.audio.input.
voxeengine-openai-half-cascade-cartesia.js