Docs/Quickstart

Build with lifelike voice in five minutes.

A single REST endpoint, an OpenAI-compatible alias, and HTTP streaming that returns audio sentence by sentence when you need realtime. Twenty-three languages, six voices, three tenths of a cent per minute.

1 · Get your API key

Every request needs a bearer token. New accounts get an immediate key on signup, plus a free tier of ten thousand characters every month, no credit card.

Request a key →

2 · Make your first request

Send a sentence, get back a WAV. The default voice is meera; you can swap any of the ten in the voice library.

curl
# Save a synthesised WAV to disk
curl https://api.leanvoice.ai/v1/audio/speech \
  -H "Authorization: Bearer $LEANVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "aayush-tts-1",
    "voice": "meera",
    "input": "Hello, and welcome to LeanVoice.",
    "language": "en",
    "format": "wav"
  }' \
  --output hello.wav
python
from leanvoice import LeanVoice

client = LeanVoice(api_key=os.environ["LEANVOICE_API_KEY"])

audio = client.speech.create(
    voice="meera",
    input="Hello, and welcome to LeanVoice.",
    language="en",
    format="wav",
)

with open("hello.wav", "wb") as f:
    f.write(audio.bytes)
node
import { LeanVoice } from "@leanvoice/sdk";
import { writeFile } from "node:fs/promises";

const client = new LeanVoice({ apiKey: process.env.LEANVOICE_API_KEY });

const audio = await client.speech.create({
  voice: "meera",
  input: "Hello, and welcome to LeanVoice.",
  language: "en",
  format: "wav",
});

await writeFile("hello.wav", Buffer.from(await audio.arrayBuffer()));
Drop-in compatible with OpenAI

The same endpoint is mirrored at POST /v1/audio/speech with OpenAI's exact request shape. If you're using the openai SDK, change base_url to ours and keep the rest of your code. See the OpenAI compat reference →

3 · Stream when you need realtime

For voice agents, IVR, or any interaction where users wait on speech, request a streaming response over HTTP and start playing audio as each sentence is synthesised — playback begins before the full text is rendered.

javascript
const res = await fetch("https://api.leanvoice.ai/v1/audio/speech", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.LEANVOICE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    voice: "meera",
    input: "Streaming, sentence by sentence.",
    stream: true,
  }),
});

// Audio arrives sentence by sentence; play each chunk as it lands.
const reader = res.body.getReader();
while(true){
  const { value, done } = await reader.read();
  if(done) break;
  audioPlayer.push(value);
}

Full streaming reference →

What's next