REST · text-to-speech.
A single endpoint that takes a sentence and returns audio. Use it for batch jobs, non-realtime workloads, and any system that already speaks HTTP.
Endpoint
POSThttps://api.leanvoice.ai/v1/audio/speech
Returns the audio as the response body. Default response is a WAV file; pass format to switch.
Request body
meera if omitted.wav, mp3, opus, pcm_s16le_24k, pcm_s16le_16k, mulaw_8k. Default wav.4 (draft, fastest), 8 (balanced, default), 10 (studio).aayush-tts-1 (default); pinned for backwards compatibility.Response
Audio bytes in the requested format. The following headers carry per-request telemetry:
| Header | Meaning |
|---|---|
| X-Audio-Duration | Length of synthesised audio in seconds, to three decimals. |
| X-Request-Id | Opaque request id, include in support tickets. |
| X-Characters-Billed | Characters that counted toward your monthly quota. |
Examples
curl https://api.leanvoice.ai/v1/audio/speech \ -H "Authorization: Bearer $LEANVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"voice":"arjun","input":"Welcome to channel seventeen.","format":"mp3"}' \ --output greeting.mp3
from leanvoice import LeanVoice client = LeanVoice(api_key=os.environ["LEANVOICE_API_KEY"]) audio = client.speech.create(voice="arjun", input="Welcome.", format="mp3") open("out.mp3","wb").write(audio.bytes)
const audio = await client.speech.create({ voice:"arjun", input:"Welcome.", format:"mp3" }); await writeFile("out.mp3", Buffer.from(await audio.arrayBuffer()));
OpenAI compatibility
The endpoint accepts OpenAI's exact audio/speech request shape, so any client built for OpenAI can switch by changing one URL. Use the openai SDK with base_url set to https://api.leanvoice.ai/v1:
from openai import OpenAI client = OpenAI( api_key=os.environ["LEANVOICE_API_KEY"], base_url="https://api.leanvoice.ai/v1", ) audio = client.audio.speech.create( model="aayush-tts-1", voice="meera", input="Same SDK, new base URL.", ) audio.stream_to_file("out.wav")
The mapping is one-to-one: voice names match the OpenAI shape where compatible (alloy aliases to meera, onyx to arjun, etc.) and our extended fields (steps, speed) ride along as additional parameters that OpenAI's SDK passes through unchanged.