Audio formats
Request audio and transcript formats the selected provider can produce.
TTS output format
Use response_format with the OpenAI SDK or output_format with the ElevenLabs SDK. The selected model and provider must support the requested format.
| Format | Content type | Typical use |
|---|---|---|
| MP3 | audio/mpeg | Compressed audio for playback and storage. |
| WAV | audio/wav | Broad compatibility with audio tools. |
| PCM | audio/L16 | Headerless audio for low-latency playback and telephony bridges. |
| μ-law | audio/basic | 8 kHz telephony audio, where supported. |
import { writeFile } from "node:fs/promises";const response = await fetch("https://api.allmodels.io/oai/audio/speech", { method: "POST", headers: { Authorization: `Bearer ${process.env.ALLMODELS_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "model": "grok/grok-tts", "voice": "eve", "input": "Hello from AllModels", "response_format": "mp3"})});if (!response.ok) throw new Error(`AllModels request failed: ${response.status}`);await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()));ElevenLabs-style format tokens include the sample rate and sometimes the bitrate, such as mp3_44100_128, pcm_16000, or ulaw_8000. OpenAI-style values use the container or encoding name, such as mp3, wav, or pcm; AllModels selects the corresponding output format.
AllModels does not silently transcode unsupported output. If the selected provider cannot produce the requested format, the request returns an invalid_output_format error.
Streaming input formats
Streaming transcription routes use an audio format and sample rate to describe each input chunk.
| Format | Description |
|---|---|
pcm_16000 | Mono, signed 16-bit PCM at 16 kHz; common for streaming STT. |
pcm_24000 | Mono, signed 16-bit PCM at 24 kHz; required by some streaming models. |
ulaw_8000 | 8 kHz μ-law for telephony audio. |
auto | Self-describing container audio on native routes, where supported. |
Raw PCM does not contain a file header. The configured format, sample rate, channel count, and encoding must match the bytes you send. See Streaming & realtime for complete streaming examples.
Provider support
Format support varies by provider and transport. Some streaming TTS models emit only PCM or μ-law over WebSockets, while their HTTP endpoints may support compressed formats. Check the API reference for the selected route and provider-specific constraints.
