Lunos logoLunos

Audio Generation (TTS)

Convert text to speech. The response is raw binary audio data.

Basic Usage

const response = await client.audio.create({
  model: "openai/tts",
  input: "Hello from Lunos!",
  voice: "alloy",
  response_format: "mp3",
  speed: 1.0,
});

// Write audio to file (Node.js)
import { writeFileSync } from "fs";
writeFileSync("output.mp3", Buffer.from(await response.arrayBuffer()));

Parameters

Parameter Type Description
model string TTS model identifier
input string Text to convert to speech
voice string Voice selection
response_format 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' Audio format
speed number Speed multiplier (0.25–4.0)

Available Voices

Voice Description
alloy Neutral, balanced
echo Warm, conversational
fable Expressive, storytelling
onyx Deep, authoritative
nova Friendly, upbeat
shimmer Clear, professional

Streaming to Client

In a web server context, pipe the audio response directly:

// Express.js example
app.get("/speak", async (req, res) => {
  const response = await client.audio.create({
    model: "openai/tts",
    input: req.query.text,
    voice: "nova",
    response_format: "mp3",
  });

  res.setHeader("Content-Type", "audio/mpeg");
  const buffer = Buffer.from(await response.arrayBuffer());
  res.send(buffer);
});