November 27, 2026 · 11 min · api · engineering
.mdCustom voice webhook: ElevenLabs or any TTS on a talking avatar
Yes. Tavus and LiveAvatar take ElevenLabs voices, face-only renderers take any audio, and Realtime Avatar's voice webhook takes any HTTPS TTS, lip-synced.
Yes, on several platforms, in different ways. Tavus lets a PAL speak with a voice from your own ElevenLabs or Cartesia account through its TTS layer, with Azure as a language fallback. HeyGen's LiveAvatar FULL mode imports your own ElevenLabs, Fish Audio or Cartesia voice. Face-only renderers such as LiveAvatar LITE lip-sync whatever audio your own agent sends. Realtime Avatar's voice webhook POSTs each sentence the character is about to say to your HTTPS endpoint, so any text-to-speech your server can reach, including ElevenLabs, OpenAI or a voice model you host on a public address, becomes the character's voice, lip-synced in video calls and spoken in voice-only calls, while the platform keeps handling listening, turn-taking, interruption, the reply and the video.
Below: each vendor's own-voice option as its docs read on 16 November 2026, then Realtime Avatar's exact webhook contract, an ElevenLabs handler, a local test, the error codes, and the one thing the webhook cannot do: put a face on audio from an ElevenLabs agent or any other voice agent you run.
Own-voice options by vendor, as of November 2026
- Tavus: set layers.tts on the PAL. tts_engine takes tavus-auto (the default), cartesia or elevenlabs, with azure only as a language fallback. external_voice_id names a voice in your own Cartesia, ElevenLabs or Azure account; public ElevenLabs and Cartesia voices need no provider key, private ones need api_key; tts_model_name picks the model, for example eleven_turbo_v2_5.
- HeyGen LiveAvatar, FULL mode: custom TTS supports three providers, ElevenLabs, Fish Audio and Cartesia. You store your provider key with POST /v1/secrets, bind the voice with POST /v1/voices/third_party, and pass the returned voice_id in avatar_persona. ElevenLabs free-tier keys are not supported.
- HeyGen LiveAvatar, LITE mode: a face-only renderer. You run speech recognition, the LLM and TTS; LiveAvatar turns your audio into synchronized avatar video, at 1 credit per minute against 2 for FULL. Connectors bridge hosted agents from ElevenLabs, Cartesia, OpenAI Realtime and Gemini Live.
- ElevenLabs: its Avatars feature, on all paid plans, pairs an avatar with any voice in your library, including cloned voices, and generates talking-head videos with lip sync from a script you enter. The page describes no live mode and lists API access as not available at launch. For live calls, its ElevenAgents docs include a LiveAvatar LITE integration guide: an ElevenLabs agent handles the audio and LiveAvatar renders the video; the agent's input and output formats must be PCM at 24000 Hz, and the API key needs the convai_read, user_read and voices_read permissions.
- Realtime Avatar: voice_webhook on the session your server mints. Any HTTPS endpoint that returns audio becomes the voice. Without a webhook, calls use the platform's built-in Fish voices, which are included in the per-second rate.
Choose by what you already run and what you want the platform to do:
- You already run a voice agent (an ElevenLabs agent, LiveKit Agents, Pipecat or OpenAI Realtime) and want a face on its audio: use a face-only renderer such as LiveAvatar LITE. Realtime Avatar does not offer that mode.
- You want a hosted avatar that runs the conversation, with your voice at ElevenLabs or Cartesia: Tavus's TTS layer fits. With your voice at ElevenLabs, Fish Audio or Cartesia: LiveAvatar FULL fits, with a paid key if the voice is at ElevenLabs.
- You want a hosted avatar that runs the conversation with any TTS, including OpenAI, a provider neither lists, or a voice model you host: Realtime Avatar's voice webhook fits.
- You want a recorded talking-head video from a script rather than a live call: ElevenLabs' own Avatars feature makes those with any voice in your library.
- Plan prices for the hosted options are on our pricing and comparison pages; the Realtime Avatar plans are summarized below.
How Realtime Avatar's voice webhook works
Your server adds the webhook when it mints the session: voiceWebhook on the session policy in the realtime-avatar SDK, version 0.28.0 or later, or voice_webhook over raw HTTP. It is server-only: a browser-minted request has the field removed. From then on, each time the character is about to speak, the platform POSTs that sentence to your url, signed with your secret, and she speaks the audio you stream back, lip-synced, in both avatar and voice mode.
- url: must start with https://, up to 500 characters. Redirects are never followed, and a host that resolves to a private address ends the call, so a voice model you host needs a public HTTPS address.
- secret: 16 to 200 characters, the HMAC-SHA256 key for the x-rta-signature header. It is the same scheme as the transcript webhook.
- voice_id and language: optional, your own voice identifier and a BCP-47 hint, echoed in every request. Put an ElevenLabs voice ID in voice_id and one handler can voice every character.
- sample_rate: optional, one of 8000, 16000, 22050, 24000 (the default), 44100 or 48000. It is the rate of raw audio/pcm replies.
- timeout_ms: optional, 1000 to 15000, default 5000. It bounds the first audio byte of each attempt and every later gap between chunks.
Each POST is JSON: type voice.synthesize, version 1, request_id, session_id, text, voice_id, language, an output object of encoding pcm_s16le, sample_rate and channels 1, and client_metadata. The headers are x-rta-signature (v1= followed by a hex HMAC over the timestamp, a dot and the raw body), x-rta-timestamp and x-rta-request-id. The webhook replaces the built-in voice, so a session that also sends a top-level voice or voice_id is refused with a 422 (the voice_id inside voice_webhook is yours to set), and without a webhook a session speaks with Fish voices only: a voice override naming another provider is not an error, the call simply speaks with a Fish voice, so ElevenLabs goes through the webhook. Here is the mint half in a Next.js route:
// app/api/realtime-avatar/[...path]/route.ts: the mint half.
import { createRealtimeAvatarRoute } from "realtime-avatar/nextjs";
export const { GET, POST } = createRealtimeAvatarRoute({
apiKey: process.env.REALTIME_AVATAR_API_KEY!, // no NEXT_PUBLIC_ prefix
// Add authorize() from the Next.js guide before you ship.
session: async () => ({
instructions: "You are the onboarding guide for a billing dashboard. Keep replies short.",
voiceWebhook: {
url: "https://your.app/api/rta/voice", // https only, no redirects, public host
secret: process.env.RTA_VOICE_SECRET!, // 16 to 200 characters
voiceId: "YOUR_ELEVENLABS_VOICE_ID", // voice_id on the wire, echoed in every POST
language: "en-US", // BCP-47 hint, echoed in every POST
},
}),
});
What to stream back
Answer 200 and stream audio as soon as you have it: the first byte is what the user waits for. A body labelled audio/pcm (or audio/raw) is read as raw signed 16-bit little-endian mono at output.sample_rate, and a label such as audio/pcm;rate=16000 names a different rate, so any rate works if the label is true. WAV, MP3 and Ogg bodies are decoded too, but the docs recommend PCM. The text is plain words, with no markup, and when the user interrupts, the connection is closed mid-body; that is normal.
A size check catches most bugs: raw PCM at 24 kHz, 16-bit, mono is 24,000 samples times 2 bytes, or 48,000 bytes per second of speech, so a three-second sentence comes back as about 144,000 bytes.
An ElevenLabs handler
ElevenLabs' streaming endpoint, POST https://api.elevenlabs.io/v1/text-to-speech/{voice_id}/stream with your key in the xi-api-key header, returns MP3 by default (mp3_44100_128). Ask for output_format=pcm_24000 instead. ElevenLabs documents its PCM output as S16LE at 16-bit depth, which is the raw format the webhook defaults to, so the bytes pass straight through. pcm_16000, pcm_22050 and pcm_48000 work the same way if you change the rate in the content type; ElevenLabs reserves 44.1 kHz PCM for its Pro tier and above. For a live call, ElevenLabs' text-to-speech overview recommends its low-latency Flash models, eleven_flash_v2 or eleven_flash_v2_5, over the endpoint's default model, eleven_multilingual_v2, so the handler uses eleven_flash_v2_5. This is the Calls docs' handler with the upstream call swapped:
// app/api/rta/voice/route.ts: one POST per sentence, ElevenLabs PCM streamed back.
import { createHmac, timingSafeEqual } from "node:crypto";
const MAX_SKEW_SECONDS = 300;
function verify(raw: string, signature: string, timestamp: string, secret: string): boolean {
if (!/^\d+$/.test(timestamp) || Math.abs(Date.now() / 1000 - Number(timestamp)) > MAX_SKEW_SECONDS) {
return false; // missing, malformed or stale: refuse replays
}
const digest = createHmac("sha256", secret).update(`${timestamp}.${raw}`).digest("hex");
const expected = Buffer.from(`v1=${digest}`);
const given = Buffer.from(signature);
return given.length === expected.length && timingSafeEqual(given, expected);
}
export async function POST(request: Request): Promise<Response> {
const raw = await request.text(); // the RAW body, before any parsing
const signature = request.headers.get("x-rta-signature") ?? "";
const timestamp = request.headers.get("x-rta-timestamp") ?? "";
if (!verify(raw, signature, timestamp, process.env.RTA_VOICE_SECRET ?? "")) {
return new Response(null, { status: 401 }); // a 401 ends the call
}
const job: unknown = JSON.parse(raw);
if (typeof job !== "object" || job === null || !("text" in job) || typeof job.text !== "string") {
return new Response(null, { status: 422 });
}
const voiceId =
"voice_id" in job && typeof job.voice_id === "string" ? job.voice_id : process.env.ELEVENLABS_VOICE_ID ?? "";
const upstream = await fetch(
`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(voiceId)}/stream?output_format=pcm_24000`,
{
method: "POST",
headers: { "xi-api-key": process.env.ELEVENLABS_API_KEY ?? "", "content-type": "application/json" },
body: JSON.stringify({ text: job.text, model_id: "eleven_flash_v2_5" }),
},
);
// Never pass an upstream 401 through: from your endpoint it ends the call. A 502 is retried once.
if (!upstream.ok || !upstream.body) return new Response(null, { status: 502 });
// pcm_24000 is 24 kHz signed 16-bit little-endian mono: stream it straight through.
return new Response(upstream.body, { headers: { "content-type": "audio/pcm;rate=24000" } });
}
Three details matter. The signature is checked over the raw body before anything is parsed, and a timestamp more than 300 seconds off is refused, which bounds replays. An ElevenLabs failure is answered with a 502, never passed through: a 401 or 403 from your endpoint is voice_webhook_unauthorized and ends the call, while a 5xx is retried once before any audio. And the upstream body is returned as a stream rather than awaited, so each PCM chunk reaches the platform as soon as ElevenLabs sends it.
Each POST is one sentence. ElevenLabs accepts previous_text, the text that came before, to improve continuity across requests; keep the last sentence per session_id in a shared store if you want to pass it along. It also takes language_code, an ISO 639-1 code that enforces a language; ElevenLabs notes that multilingual_v2 models do not support it and that a model which does not support the code ignores it. Map the echoed language (en-US to en, zh-CN to zh) if you want to pass it.
Using OpenAI gpt-4o-mini-tts instead
The handler on the Calls docs page does exactly this: it calls OpenAI's speech endpoint with model gpt-4o-mini-tts and response_format pcm, which OpenAI's guide describes as raw 24 kHz, 16-bit signed samples without a header, and passes it through as audio/pcm;rate=24000. One date to plan around: OpenAI's text-to-speech guide, read on 16 November 2026, says tts-1, tts-1-hd and gpt-4o-mini-tts are deprecated and shut down on January 6, 2027, and that the replacement, gpt-realtime-2.1-mini, is not supported on the speech endpoint. The handler shape stays the same when you move it to ElevenLabs or any other HTTP TTS.
Test the endpoint before you start a call
Sign one request yourself and measure what comes back:
// scripts/test-voice-webhook.ts: sign one request the way the platform does, then measure the reply.
import { createHmac, randomUUID } from "node:crypto";
const url = "http://localhost:3000/api/rta/voice";
const body = JSON.stringify({
type: "voice.synthesize",
version: 1,
request_id: randomUUID(),
session_id: "local-test",
text: "Hi! Want a quick tour of your billing dashboard?",
voice_id: null,
language: "en-US",
output: { encoding: "pcm_s16le", sample_rate: 24000, channels: 1 },
client_metadata: {},
});
const timestamp = String(Math.floor(Date.now() / 1000));
const digest = createHmac("sha256", process.env.RTA_VOICE_SECRET ?? "").update(`${timestamp}.${body}`).digest("hex");
const started = Date.now();
const response = await fetch(url, {
method: "POST",
headers: {
"content-type": "application/json",
"x-rta-signature": `v1=${digest}`,
"x-rta-timestamp": timestamp,
"x-rta-request-id": randomUUID(),
},
body,
});
let bytes = 0;
let firstByteMs: number | null = null;
const reader = response.body?.getReader();
while (reader) {
const { done, value } = await reader.read();
if (done) break;
firstByteMs ??= Date.now() - started;
bytes += value.byteLength;
}
// 24 kHz x 2 bytes x 1 channel = 48,000 bytes per second of speech.
console.log(response.status, response.headers.get("content-type"), { firstByteMs, bytes, seconds: bytes / 48_000 });
Expect 200, audio/pcm;rate=24000, a first byte well inside timeout_ms, and a seconds figure that matches the sentence. An empty body, a JSON content type or a first byte after five seconds is the bug, found without starting a call.
Errors you will see
When your endpoint fails, the client gets a voice_error event with one of these codes and a message for you, which never contains your URL, secret or response body:
- voice_webhook_url_not_allowed: the host does not resolve, or resolves to a private address. Ends the call at the start.
- voice_webhook_unauthorized: your endpoint answered 401 or 403. Ends the call.
- voice_webhook_unreachable: a DNS, connection or TLS failure, after one retry.
- voice_webhook_timeout: no first audio byte, or no next chunk, within timeout_ms; retried once if no audio has arrived.
- voice_webhook_http_error: any other non-2xx, including a redirect; 408, 429 and 5xx are retried once.
- voice_webhook_unsupported_audio: a 2xx whose body is not a supported audio type, or does not decode.
- voice_webhook_empty_audio: a 2xx with no body, meaning a 204, Content-Length: 0 or an empty first chunk, whatever its content type.
Retries happen only before any audio has arrived, as a new POST with a new request_id. The last five codes do not end the call on their own: they drop the rest of that reply, its later sentences are not sent, and the next reply tries again. Repeated unrecoverable failures do end it, with a fatal voice_error followed by failed.
What this does not do
- It cannot play audio from your own voice agent. There is no renderer-only mode that lip-syncs audio streamed from an agent you run, whether that is an ElevenLabs agent, LiveKit Agents, Pipecat or OpenAI Realtime. The webhook turns text from Realtime Avatar's pipeline into speech; it cannot push an agent's audio onto the face. For that, a face-only renderer such as LiveAvatar LITE is the better fit.
- It does not combine with the built-in voice (a 422) and cannot be set from the browser (the field is removed).
- It does not change who writes the reply. Your own OpenAI-compatible model endpoint can be enabled per workspace on request, or your server can drive each turn through sendTurn with per-turn instructions; either pairs with voice_webhook.
What you pay
Realtime Avatar meters calls by the second against your plan's credits, and the built-in voices are included in that per-second rate. With a webhook, your TTS provider bills its own usage on top, on your account with it. As of November 2026, from Realtime Avatar's billing catalog: Sandbox is 480 free credits once per account, no card: 8 realtime minutes, or a first avatar plus 2 minutes of calls; Starter is $9 a month for 120 minutes, then $0.095 a minute; Developer is $24 a month for 600 minutes, then $0.085 a minute, about $5.10 an hour; Studio is $119 a month for 3,000 minutes, then $0.08 a minute, or $4.80 an hour.
Worked example: 400 ten-minute calls a month is 4,000 minutes. On Studio that is $119 plus 1,000 overage minutes at $0.08, so $199 for the avatar side, plus your ElevenLabs bill for the text it synthesizes. On Developer the same month is $24 plus 3,400 minutes at $0.085, or $313.
FAQ
Can I use my ElevenLabs voice with a hosted realtime talking avatar and keep the lip sync?
Yes. On Realtime Avatar, add voice_webhook at mint and stream ElevenLabs pcm_24000 back; the lips follow that audio. On Tavus, set tts_engine to elevenlabs with your external_voice_id. On LiveAvatar FULL, import the voice with a paid ElevenLabs key.
Does ElevenLabs have a live avatar?
Not in its own docs as of November 2026. ElevenLabs' Avatars feature makes recorded talking-head videos from a script and any voice in your library; its page describes no live mode and lists API access as not available at launch. For live calls, ElevenLabs' ElevenAgents docs describe an integration with HeyGen's LiveAvatar: an ElevenLabs agent runs the conversation and LiveAvatar's LITE mode renders a lip-synced face from the agent's 24 kHz PCM audio. To use ElevenLabs only as the voice of a hosted live avatar that runs the conversation, pick a custom voice option: Tavus's TTS layer, LiveAvatar FULL, or the webhook above.
How do HeyGen and ElevenLabs integrate?
For live avatars, the LiveAvatar and ElevenLabs docs describe two ways. FULL mode imports an ElevenLabs voice through a stored ElevenLabs key and LiveAvatar's own agent speaks with it. LITE mode's ElevenLabs agent connector puts a LiveAvatar face on an ElevenLabs agent's audio.
LiveAvatar custom TTS only takes ElevenLabs, Fish Audio or Cartesia. Which live avatar API lets me plug in any TTS, including a model I host?
Realtime Avatar's voice webhook calls whatever HTTPS endpoint you give it: a commercial API, a cloned voice or your own model, as long as the host has a public address and the reply is PCM, WAV, MP3 or Ogg. A face-only renderer also takes any audio, but you then run the whole agent yourself.
Can I use OpenAI gpt-4o-mini-tts as the voice of my live video avatar instead of the built-in voices?
Yes. It is the Calls docs example: response_format pcm, passed through as audio/pcm;rate=24000. OpenAI states gpt-4o-mini-tts shuts down on January 6, 2027.
What audio should my custom TTS endpoint return: PCM, WAV or MP3, and at what sample rate?
Raw PCM, signed 16-bit little-endian mono, labelled audio/pcm, at 24000 Hz unless you set sample_rate or name the rate in the label, as in audio/pcm;rate=16000. WAV, MP3 and Ogg are decoded too, but PCM is the format the docs recommend.
My voice webhook returns 200 but the avatar is completely silent. What format does it expect?
Check four things. The body is not empty: a 204 or zero-length body is voice_webhook_empty_audio. The content type matches the bytes: audio/pcm for ElevenLabs pcm_24000, never JSON with base64 audio inside. The first byte arrives within timeout_ms, 5000 ms by default, so stream instead of buffering. And the labelled rate is the rate of the samples. Each failure arrives as a voice_error event naming its code.
Why do I get a 422 when I send both voice and voice_webhook in my avatar session request?
The webhook replaces the built-in voice, so a session carrying voice_webhook with voice or voice_id is refused with a 422. Drop voice and voice_id when you send the webhook.
实时数字人API能接入我自己的TTS声音吗?还能保持口型同步吗?
可以。Realtime Avatar 的 voice_webhook 会把角色要说的每一句话签名后 POST 到你的 HTTPS 接口,你返回音频(推荐 24 kHz、16 位、单声道 PCM),视频通话中口型与你的音频同步,纯语音通话同样可用。In English: yes, the webhook sends each sentence to your endpoint and lip-syncs the audio you return; set language to a BCP-47 tag such as zh-CN and it is echoed in every request.
Can a hosted realtime avatar speak with a licensed voice from the ElevenLabs voice library instead of its built-in voices?
Yes. On Realtime Avatar, through the webhook: your server calls ElevenLabs with your own API key and any voice in your ElevenLabs library, including your own cloned voice, and streams the audio back; a voice override naming ElevenLabs is not an error but speaks with a Fish voice. On Tavus, external_voice_id takes the ElevenLabs voice ID, with api_key needed only for a private voice. On LiveAvatar FULL, import it with provider_voice_id and a paid ElevenLabs key.
- Calls: Custom voice (webhook), the full contract
- Next.js route adapter: the server half
- Tool calling and the transcript webhook (same signature scheme)
- Plans and the dated all-in cost table
- Realtime Avatar vs Tavus
- Realtime Avatar vs HeyGen LiveAvatar
- Tavus docs: Text-to-Speech layer of a PAL (read 2026-11-16)
- LiveAvatar docs: Custom TTS integration, FULL mode (read 2026-11-16)
- LiveAvatar docs: LITE mode overview (read 2026-11-16)
- ElevenLabs docs: LiveAvatar integration for ElevenAgents (read 2026-11-16)
- ElevenLabs docs: Avatars, recorded talking-head videos (read 2026-11-16)
- ElevenLabs API reference: Stream speech (read 2026-11-16)
- ElevenLabs docs: Text to Speech output formats (read 2026-11-16)
- OpenAI docs: Text to speech guide (read 2026-11-16)
Compare and cost guides
- Realtime Avatar pricing
- Avatar API cost calculator
- Realtime Avatar vs Tavus, HeyGen LiveAvatar, Anam and Simli
- Realtime AI avatar APIs compared
- Realtime avatar API pricing, worked out
- HeyGen and LiveAvatar API pricing explained
- Choosing a HeyGen alternative for realtime avatars
- Tavus pricing per minute
- A Tavus alternative for live AI characters
- Meta Muse Realtime Avatar vs Realtime Avatar
- A realtime AI avatar in React Native or Expo
- Live avatars in 2026: a field guide to the research