Cartesia-compatible API
The cartesia Python SDK works against Revolab with a base_url swap — bytes,
SSE, the generation websocket, and batch speech-to-text, at Cartesia’s real
paths.
Endpoints
POST https://api.revolab.ai/tts/bytes
POST https://api.revolab.ai/tts/sse
WS wss://api.revolab.ai/tts/websocket
POST https://api.revolab.ai/sttBytes & SSE
Python
from cartesia import Cartesia
client = Cartesia(api_key="rvl_live_...", base_url="https://api.revolab.ai")
fmt_wav = {"container": "wav", "encoding": "pcm_s16le", "sample_rate": 24000}
fmt_raw = {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 24000}
# Buffered WAV
audio = b"".join(client.tts.generate( # v2 SDKs: client.tts.bytes(
model_id="nada-1.0-flash",
transcript="Hello from Revolab.",
voice={"mode": "id", "id": "<your-voice-id>"},
output_format=fmt_wav,
))
# Server-sent events — base64 PCM chunk events + done
for event in client.tts.generate_sse( # v2 SDKs: client.tts.sse(
model_id="nada-1.0-flash",
transcript="Streaming starts before synthesis finishes.",
voice={"mode": "id", "id": "<your-voice-id>"},
output_format=fmt_raw,
):
if event.type == "chunk":
play(event.audio)Websocket & speech to text
from cartesia import Cartesia
client = Cartesia(
api_key="rvl_live_...",
base_url="https://api.revolab.ai",
websocket_base_url="wss://api.revolab.ai",
)
with client.tts.websocket_connect() as ws:
ws.send({
"context_id": "turn-1",
"model_id": "nada-1.0-flash",
"transcript": "Hello over the websocket.",
"voice": {"mode": "id", "id": "<your-voice-id>"},
"output_format": {"container": "raw", "encoding": "pcm_s16le",
"sample_rate": 24000},
})
for msg in ws:
if msg.type == "chunk":
play(msg.audio)
elif msg.type == "done":
break
# STT (batch)
result = client.stt.transcribe(
file=open("speech.wav", "rb"), model="aisyah-1.0-flash"
)
print(result.text)Support matrix
| Area | Support |
|---|---|
| Auth | Both SDK generations work: v3 (Authorization: Bearer + cartesia-version header), v2 (X-API-Key), and ?api_key= on the websocket — all carrying a normal rvl_live_ key. The version header is accepted and ignored. |
| Output formats | container "wav" (buffered) or "raw" (chunked / streamed) with encoding pcm_s16le at 24000 Hz only. mp3, other encodings, and other sample rates return a 400 naming the supported combination. |
| Websocket contexts | Multiple contexts per connection; each context synthesizes per request. continue:true pieces follow Cartesia’s max_buffer_delay_ms contract — 0 synthesizes each piece as it arrives (what the LiveKit plugin sends), otherwise pieces buffer until the final piece. Whitespace-only final pieces close the context with done. |
| Timestamps | add_timestamps is accepted but no word/phoneme timestamp events are produced (engines return whole-utterance audio/text). |
| Streaming STT | /stt/websocket is not supported — the socket closes with a pointer to POST /stt (batch). No honest emulation preserves incremental transcription semantics. |
| Models | Revolab names only. sonic-* and ink-* return a 400 listing valid models. |
Building a voice agent with LiveKit? See the LiveKit agents guide — the plugin drives this websocket for you.