Audio
The audio API covers synchronous text-to-speech (TTS), prerecorded
speech-to-text (STT), and real-time WebSocket variants. Choose a model from the
audio model catalog; each provider supports a
different set of voices, languages, formats, and limits.
All HTTP requests use the same bearer-key authentication as the text APIs. TTS
returns binary audio, while STT returns JSON or plain text. Audio capability is
selected by the model ID; a TTS model cannot be used for transcription and vice
versa.
Text-to-speech
POST /v1/audio/speech returns an audio binary stream:
curl -X POST "https://api.llmapi.ai/v1/audio/speech" \
-H "Authorization: Bearer $LLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"sonic-3","input":"Welcome to LLM API","voice":"Sarah"}' \
--output welcome.mp3
The default output is MP3. Use response_format for a format supported by the
selected model. The response has an audio content type and should be written to
a file or streamed directly to a player; it is not a JSON wrapper.
TTS fields
| Field |
Description |
model |
TTS model ID, such as sonic-3 or an ElevenLabs model. |
input |
Text to synthesize. Maximum length depends on the model. |
voice |
Voice ID/name supported by the selected provider. |
response_format |
Output format such as MP3 or WAV, when supported. |
speed |
Playback speed, where supported. |
language |
Language hint, where supported. |
instructions |
Accent or style steering for models that expose it. |
stability, similarity_boost |
ElevenLabs voice controls from 0 to 1. |
Provider-specific fields are forwarded only when the selected model supports
them. Query the audio model guide for voices and limits before exposing these
options in a user interface.
Speech-to-text
POST /v1/audio/transcriptions accepts a multipart upload and returns a
transcription:
curl -X POST "https://api.llmapi.ai/v1/audio/transcriptions" \
-H "Authorization: Bearer $LLM_API_KEY" \
-F "model=ink-whisper" \
-F "file=@recording.mp3"
The default JSON response is:
{ "text": "Welcome to our platform. We are glad to have you here." }
STT fields
| Field |
Description |
model |
STT model ID, such as ink-whisper or an AssemblyAI model. |
file |
Required audio upload in multipart form data. |
language |
ISO-639-1 language code, when known. |
response_format |
json or text for all models; verbose_json for Whisper models. |
timestamp_granularities |
Set to word for Whisper word timestamps with verbose_json. |
use_multi_channel |
Transcribe channels independently for models that support it. |
multichannel_output_style |
separate or combined; combined output requires verbose_json. |
Use response_format=text when you only need the transcript string. Use JSON
or verbose JSON when you need metadata, timestamps, or channel results. The
HTTP body limit is 15 MB; accepted codecs, duration, and channel limits remain
model-dependent.
Real-time WebSockets
Streaming TTS
Connect to GET /v1/audio/speech/ws, then send JSON messages such as:
{ "type": "tts", "model": "sonic-3", "input": "Hello", "voice": "Sarah" }
The server sends messages such as
{ "type": "audio", "data": "<base64>" }. Send
{ "type": "cancel" } to stop the current generation. Every request on one
connection must resolve to the same provider.
Streaming STT
Connect to GET /v1/audio/transcriptions/ws and configure the stream first:
{
"type": "configure",
"model": "ink-whisper",
"encoding": "pcm_s16le",
"sample_rate": 16000
}
After configuration, send raw PCM binary frames. The server emits transcript
updates such as:
{
"type": "transcript",
"text": "Hello there",
"is_final": true,
"words": []
}
Full-duplex voice
Streaming TTS and STT each run in one direction. For a speech-to-speech session
where the model listens and answers on the same socket, use
Live voice sessions (GET /v1/live/sessions).
Use the Authorization header for either WebSocket endpoint. Streaming TTS
also accepts the key as a token query parameter. Streaming sessions include
budget protection and can terminate when estimated cost reaches 90% of the
remaining balance.
See Audio Streaming for connection examples and
message details. WebSocket connections accept the bearer token in the
Authorization header; streaming TTS also supports a token query parameter.
API operation: POST /v1/audio/speech
API operation: POST /v1/audio/transcriptions
API operation: GET /v1/audio/speech/ws
API operation: GET /v1/audio/transcriptions/ws