API Reference
Audio & TTS
Text-to-speech and speech-to-text through a unified OpenAI-compatible API. Access models from OpenAI, ElevenLabs, and other audio providers.
Text-to-Speech
http
POST https://api.onerouter.app/v1/audio/speechParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | TTS model: tts-1, tts-1-hd, gpt-4o-mini-tts |
| input | string | Yes | Text to convert to speech (max 4096 chars) |
| voice | string | Yes | Voice: alloy, echo, fable, onyx, nova, shimmer |
| response_format | string | No | mp3 (default), opus, aac, flac, wav, pcm |
| speed | number | No | Playback speed: 0.25 to 4.0. Default: 1.0 |
Example
python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-key",
base_url="https://api.onerouter.app/v1",
)
# Text-to-Speech
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="Hello! Welcome to OneRouter.",
)
response.stream_to_file("output.mp3")Speech-to-Text
http
POST https://api.onerouter.app/v1/audio/transcriptionsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | STT model: whisper-1 |
| file | file | Yes | Audio file (mp3, mp4, mpeg, mpga, m4a, wav, webm) |
| language | string | No | ISO 639-1 language code for better accuracy |
| response_format | string | No | json (default), text, srt, vtt, verbose_json |
| temperature | number | No | Sampling temperature (0–1). Default: 0 |
Example
python
# Speech-to-Text (Whisper)
audio_file = open("audio.mp3", "rb")
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
response_format="text",
)
print(transcript)Available Models
See the Models page for all supported TTS and STT providers including OpenAI TTS, Whisper, and ElevenLabs.