ElevenLabs: Eleven v3 (Text to Audio) API Reference

About

Eleven v3 is ElevenLabs' human-like, expressive model for 70+ languages. Inline audio tags such as [whispers] or [laughs] in the text direct the delivery. Infron serves it through the OpenAI-compatible POST /v1/audio/speech endpoint with any ElevenLabs voice ID, mp3, opus, pcm or wav output and optional streaming. A request takes up to 5,000 characters and is billed per character.

1. Calling the API

Setup your API Key

To begin using Infron, create an account and generate your API Key.

export INFRON_KEY="YOUR_API_KEY"

Submit a request

Send JSON to POST https://llm.onerouter.pro/v1/audio/speech with your Infron API key. The request and response follow the OpenAI speech API, so the OpenAI SDKs work with the base URL https://llm.onerouter.pro/v1. The examples use the ElevenLabs voice JBFqnCBsd6RMkjVDRZzb. Replace YOUR_API_KEY with your key.

curl

curl https://llm.onerouter.pro/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "elevenlabs/eleven-v3/text-to-audio",
    "voice": "JBFqnCBsd6RMkjVDRZzb",
    "input": "Hello! Welcome to Infron.",
    "response_format": "mp3"
  }' \
  --output speech.mp3

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://llm.onerouter.pro/v1",
    api_key="YOUR_API_KEY",
)

with client.audio.speech.with_streaming_response.create(
    model="elevenlabs/eleven-v3/text-to-audio",
    voice="JBFqnCBsd6RMkjVDRZzb",
    input="Hello! Welcome to Infron.",
    response_format="mp3",
) as response:
    response.stream_to_file("speech.mp3")

TypeScript (OpenAI SDK)

import fs from "node:fs";
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://llm.onerouter.pro/v1",
  apiKey: "YOUR_API_KEY",
});

const response = await client.audio.speech.create({
  model: "elevenlabs/eleven-v3/text-to-audio",
  voice: "JBFqnCBsd6RMkjVDRZzb",
  input: "Hello! Welcome to Infron.",
  response_format: "mp3",
});
fs.writeFileSync("speech.mp3", Buffer.from(await response.arrayBuffer()));

Response

A successful request returns HTTP 200 with the audio file as the body, not JSON. Content-Type follows response_format: audio/mpeg for mp3, audio/opus for opus, audio/pcm for pcm, audio/wav for wav. The examples above save it as speech.mp3.

Streaming

Add "stream_format": "sse" to receive Server-Sent Events while the audio is generated. Each speech.audio.delta event carries the next base64 chunk of the audio in response_format; decode the chunks and append them in order. The stream ends with a speech.audio.done event that reports usage.

curl https://llm.onerouter.pro/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "elevenlabs/eleven-v3/text-to-audio",
    "voice": "JBFqnCBsd6RMkjVDRZzb",
    "input": "Hello! Welcome to Infron.",
    "response_format": "mp3",
    "stream_format": "sse"
  }' \
  --no-buffer
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}

data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}

data: {"type":"speech.audio.done","usage":{"input_tokens":25,"output_tokens":0,"total_tokens":25}}

In this example input_tokens is the billable character count of the input.

Routing and usage

This model is served by elevenlabs (ElevenLabs). Billing uses the character count ElevenLabs reports for the request (the input characters when it reports none). The audio response carries no usage; with streaming, speech.audio.done reports the billable count as usage.input_tokens.

Errors

Parameters this model does not accept are rejected with HTTP 400 before the request is sent to ElevenLabs, and nothing is charged. error.message explains the problem and ends with the request ID:

{
  "error": {
    "message": "voice is required (ElevenLabs voice_id) (request id: 20261111221810441285700pZnPkvCJ)",
    "type": "infron_ai_error",
    "param": "",
    "code": "invalid_request_error"
  }
}

Errors reported by ElevenLabs, such as an unknown voice ID, are returned with ElevenLabs's message. If a stream fails after it has started, an error event is sent instead of speech.audio.done.

2. Schema

Input

ParameterTypeRequiredDefaultRangeDescription
modelstringYes--elevenlabs/eleven-v3/text-to-audioModel ID.
inputstringYes--Up to 5,000 charactersText to synthesize. Inline audio tags such as [whispers], [laughs] or [sighs] direct the delivery.
voicestringYes----ElevenLabs voice ID, for example JBFqnCBsd6RMkjVDRZzb. Use a voice from your ElevenLabs voice library or the ElevenLabs voices API (see Sources).
response_formatstringNomp3mp3, opus, pcm, wavAudio format. Sent to ElevenLabs as mp3_44100_128, opus_48000_128, pcm_24000 and wav_24000. When streaming wav, ElevenLabs streams pcm_24000 and Infron adds the WAV header.
speednumberNo1Validated by ElevenLabsSpeaking rate; below 1 is slower, above 1 is faster. Sent as voice_settings.speed and merged with any voice_settings you send.
languagestringNo--ISO 639-1, e.g. enForces the language for the model and text normalization. Sent as language_code.
text_normalizationbooleanNoElevenLabs autotrue, falseSpell out numbers, dates and similar. Sent as apply_text_normalization on or off.
stream_formatstringNoaudioaudio, ssesse streams Server-Sent Events (see Streaming).

ElevenLabs fields

These fields are not part of the OpenAI speech API. Put them at the top level of the JSON body; with the OpenAI Python SDK pass them in extra_body.

ParameterTypeRequiredDefaultRangeDescription
voice_settingsobjectNo----Per-request voice settings: stability (default 0.5; lower is more expressive), similarity_boost (default 0.75), style (default 0), use_speaker_boost (default true) and speed (default 1).
output_formatstringNo--e.g. mp3_22050_32, mp3_44100_192, pcm_16000, pcm_44100, wav_44100, opus_48000_64, ulaw_8000, alaw_8000ElevenLabs output format (codec, sample rate, bitrate). Takes precedence over response_format; wav_* is not available when streaming.
seedintegerNo--0 to 4294967295Best-effort deterministic sampling.
previous_textstringNo----Text that comes before this request, for continuity.
next_textstringNo----Text that comes after this request, for continuity.
previous_request_idsarrayNo--Up to 3ElevenLabs request IDs of the preceding generations; when set, previous_text is ignored.
next_request_idsarrayNo--Up to 3ElevenLabs request IDs of the following generations; when set, next_text is ignored.
pronunciation_dictionary_locatorsarrayNo--Up to 3Pronunciation dictionaries to apply in order: pronunciation_dictionary_id and optional version_id.
apply_text_normalizationstringNoautoauto, on, offText normalization mode; text_normalization sets it too.
apply_language_text_normalizationbooleanNofalsetrue, falseLanguage-specific normalization (Japanese only); adds latency.

Unsupported fields

FieldBehavior
instructionsRejected with 400. Use inline audio tags such as [whispers] in the input where the model supports them.
sample_rate, bit_rateIgnored. Choose a sample rate and bitrate with output_format.
Other fieldsNot forwarded to ElevenLabs.

Output

ParameterTypeRangeDescription
Response bodybinarymp3, opus, pcm, wavThe audio file in response_format (without stream_format=sse).
Content-Type headerstringaudio/mpeg, audio/opus, audio/pcm, audio/wavMIME type of the audio.
typestringspeech.audio.delta, speech.audio.done, errorStreaming event type.
audiostringBase64Next chunk of the audio (speech.audio.delta).
usage.input_tokensintegerNon-negativeBillable count of the input (speech.audio.done).
usage.output_tokensinteger0Always 0 for this model.
usage.total_tokensintegerNon-negativeSum of input and output.
errorobject--message, type and code of a failure (error event).

3. Detailed Pricing

ModelEndpointBilling unitPrice
ElevenLabs: Eleven v3elevenlabsPer 1M characters$80.00

Prices are in USD. Billing uses the character count ElevenLabs reports for the request (the input characters when it reports none).

Sources: Create speech, Stream speech, Models, Pricing.