Text to Speech
Generate speech from text with the OpenAI audio endpoint or the ElevenLabs text-to-speech routes. Billed per character.
Last reviewed 2026-08-25
OpenAI shape
POST /openai/v1/audio/speech. voice is an OpenAI name, an ElevenLabs premade id, or an mserve voice id.
from openai import OpenAI
client = OpenAI(base_url="https://api.mserve.ai/openai/v1", api_key="ms_live_your_key")
with client.audio.speech.with_streaming_response.create(
model="kokoro-82m",
voice="coral",
input="Every model. One API.",
response_format="mp3",
) as response:
response.stream_to_file("speech.mp3")Prop
Type
ElevenLabs shape
POST /elevenlabs/v1/text-to-speech/{voice_id} returns audio bytes. /stream streams them. output_format is a query parameter.
from elevenlabs.client import ElevenLabs
client = ElevenLabs(base_url="https://api.mserve.ai/elevenlabs", api_key="ms_live_your_key")
audio = client.text_to_speech.convert(
voice_id="21m00Tcm4TlvDq8ikWAM",
text="Every model. One API.",
model_id="eleven_multilingual_v2",
output_format="mp3_44100_128",
)
with open("speech.mp3", "wb") as f:
for chunk in audio:
f.write(chunk)Timestamps
/with-timestamps returns JSON with base64 audio and character-level alignment. /stream/with-timestamps emits one JSON line per chunk.
{
"audio_base64": "SUQzBAAAAAAA…",
"alignment": { "characters": ["E", "v", "e"], "character_start_times_seconds": [0.0, 0.05, 0.11], "character_end_times_seconds": [0.05, 0.11, 0.18] },
"normalized_alignment": { "characters": ["E", "v", "e"], "character_start_times_seconds": [0.0, 0.05, 0.11], "character_end_times_seconds": [0.05, 0.11, 0.18] }
}History
Every generation is recorded and re-downloadable for 30 days. See History.
Pricing
| Model | Model id | Price | Unit |
|---|---|---|---|
| Kokoro 82M | kokoro-82m | $3.00 per 1M characters | Input characters |
| Chatterbox | chatterbox | $6.00 per 1M characters | Input characters |
| Chatterbox Voice Conversion | chatterbox-vc | $0.060 per minute | Input audio, billed per second |
Overview
Text to speech, streaming, speech to text, cloning, and speech to speech. OpenAI and ElevenLabs request shapes, one key.
Streaming Input
The ElevenLabs stream-input WebSocket. Send text chunks as they are produced, receive audio chunks as they are synthesized. The protocol voice-agent frameworks speak.