LLM Gateway
Features

Speech Generation

Generate speech (text-to-speech) using ElevenLabs, Gemini, OpenAI, Qwen, and Orpheus models through the OpenAI-compatible audio API

LLMGateway supports text-to-speech (TTS) through the OpenAI-compatible /v1/audio/speech endpoint, powered by ElevenLabs, Google Gemini, OpenAI (also served through Azure), Alibaba Qwen, and Canopy Labs Orpheus (served through Groq) speech models.

Want to hear the voices before writing code? The Audio Studio in Lounge generates speech from up to three models side by side, with per-model voice, format, and speed controls.

Available Models

Browse all speech generation models, with up-to-date pricing, on the models page.

Billing varies by model family. Some models are billed on token usage reported by the provider (input text tokens and output audio tokens), while others are billed on input character count (those return audio bytes without usage data). See the models page for each model's exact pricing.

Parameters

ParameterTypeDefaultDescription
modelstringrequiredThe speech model to use
inputstringrequiredThe text to synthesize into speech
voicestringmodelA prebuilt voice. Defaults to Kore (Gemini), alloy (OpenAI), Sarah (ElevenLabs), or the model's first voice on Qwen (longanlingxin on Plus, longanhuan_v3.6 on Flash)
response_formatstringmodelAudio format. OpenAI: mp3 (default), opus, aac, flac, wav, pcm. ElevenLabs: mp3 (default), wav, pcm, opus. Gemini: wav (default), pcm. Qwen and Orpheus: wav
stream_formatstringaudioBinary audio, or sse events ending with usage and cost; see Streaming below
instructionsstring—Optional style/delivery directive prepended to the input (e.g. "Say cheerfully")
speednumber—Accepted for OpenAI compatibility, but not applied by Gemini or Orpheus speech models

Gemini speech models return raw PCM audio. LLMGateway wraps it in a WAV container by default (response_format: "wav"), or returns the raw 16-bit little-endian PCM at 24 kHz when response_format: "pcm" is requested. Other formats such as mp3 are only available on the OpenAI models, which return the audio already encoded in the requested format.

curl

curl -X POST "https://api.llmgateway.io/v1/audio/speech" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash-preview-tts",
    "input": "Hello, welcome to LLM Gateway!",
    "voice": "Kore"
  }' \
  --output speech.wav

OpenAI SDK

Works with the standard OpenAI client library — just point the base URL to LLMGateway.

import OpenAI from "openai";
import { writeFileSync } from "fs";

const openai = new OpenAI({
	apiKey: process.env.LLM_GATEWAY_API_KEY,
	baseURL: "https://api.llmgateway.io/v1",
});

const response = await openai.audio.speech.create({
	model: "gemini-2.5-flash-preview-tts",
	voice: "Kore",
	input: "Hello, welcome to LLM Gateway!",
});

const buffer = Buffer.from(await response.arrayBuffer());
writeFileSync("speech.wav", buffer);

Streaming

OpenAI-compatible speech responses, including Azure, stream audio as the provider produces it. Omit stream_format or use "audio" for binary audio; existing clients can still read the complete response with arrayBuffer(). Playback latency also depends on the selected audio format and your player.

Use stream_format: "sse" to receive speech events instead: speech.audio.delta events with base64 audio, then one speech.audio.done event whose usage reports what the request was billed. This works on every speech model. Native speech events are forwarded as the provider produces them; audio from other models arrives in deltas as it is generated or, for models that return it in one piece, at once.

{
	"type": "speech.audio.done",
	"usage": {
		"input_tokens": 7,
		"output_tokens": 42,
		"total_tokens": 49,
		"cost": 0.0005082,
		"cost_details": {
			"input_cost": 0.0000042,
			"output_cost": 0.000504,
			"request_cost": 0,
			"total_cost": 0.0005082
		}
	}
}

Models priced per token report input_tokens, output_tokens and total_tokens; models priced per character report input_characters. Binary audio has no body to carry a cost, so use SSE when you need the cost with the response.

curl -N "https://api.llmgateway.io/v1/audio/speech" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<provider>/<speech-model>",
    "input": "Hello, welcome to LLM Gateway!",
    "response_format": "pcm",
    "stream_format": "sse"
  }'

Billing completes when generation finishes, including provider-reported usage. Disconnecting does not undo accepted generation: the gateway discards subsequent SSE audio until final usage arrives or the original request deadline expires. Disconnecting never extends that deadline. If usage cannot be recovered, the log records incomplete, estimated accounting rather than a successful zero-usage request. Character-billed models remain billed on accepted input after audio generation starts.

Token-billed streams queue at most 1 MiB or 1,024 chunks for a slow client. Exceeding either limit fails delivery and discards subsequent audio while final usage is collected within the original request deadline.

Errors before audio starts return an HTTP error. Errors or deadlines after output starts interrupt the stream; clients must detect truncated output and handle stream read errors.

Voices

Gemini exposes 30 prebuilt voices. A few common ones: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede. When voice is omitted on a Gemini model, Kore is used.

OpenAI voices include alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, and verse. When voice is omitted on an OpenAI model, alloy is used.

ElevenLabs models accept 20 named voices, including Sarah, Aria, Roger, Laura, Charlie, George, Charlotte, Jessica, Brian, and Lily. When voice is omitted on an ElevenLabs model, Sarah is used. Any raw ElevenLabs voice id, including voice library voices, is also accepted directly; voices your ElevenLabs plan cannot use fail upstream.

Qwen-Audio-3.0-TTS voices are model-specific and cannot be mixed between models: longanlingxin and longanlufeng on Plus (default longanlingxin), and longanhuan_v3.6, longjielidou_v3.6, loongeva_v3.6, and loongjohn on Flash (default longanhuan_v3.6).

Orpheus V1 English offers six voices: troy (default), autumn, diana, hannah, austin, and daniel, and follows bracketed vocal directions in input such as [cheerful] or [whisper]. Orpheus Arabic Saudi offers six Saudi-dialect voices: fahad (default), abdullah, sultan, lulwa, noura, and aisha. Groq limits Orpheus input to 200 characters per request.

Music generation

Music models (Google Lyria) also use /v1/audio/speech: input is the music prompt, voice and speed are ignored, and each request generates one track billed at a flat per-track price. Each model returns a single native format, wav on Google Vertex or mp3 on Google AI Studio, which is the default and only accepted response_format. Find them on the models page.

curl -X POST "https://api.llmgateway.io/v1/audio/speech" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3-clip-preview",
    "input": "An upbeat lo-fi hip hop beat with warm piano chords"
  }' \
  --output music.mp3

Full-length songs can take a minute or more to generate.

ElevenLabs

The four ElevenLabs models are billed per input character (see the models page for rates):

  • eleven-multilingual-v2 — most lifelike, rich emotional expression, 29 languages
  • eleven-v3 — most expressive and human-like, 70+ languages
  • eleven-flash-v2-5 — ultra-low latency, 32 languages
  • eleven-turbo-v2-5 — fast and balanced, 32 languages
curl -X POST "https://api.llmgateway.io/v1/audio/speech" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "eleven-multilingual-v2",
    "input": "Hello, welcome to LLM Gateway!",
    "voice": "Sarah"
  }' \
  --output speech.mp3

How is this guide?

Last updated on

On this page

Ready for production?

Ship to production with SSO, audit logs, spend controls, and guardrails your security team will approve.

Explore Enterprise