LLM Gatewaydocs

Audio

POST/v1/audio/speechbinary audio stream
POST/v1/audio/transcriptionsmultipart/form-data

Speech (text-to-speech)

Returns audio bytes. The gateway streams the provider's response through without buffering (chunked transfer), so playback can start before synthesis finishes.

bash
curl "https://api.smartapihub.com/v1/audio/speech" \
  -H "Authorization: Bearer $LLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/tts-1",
    "input": "The gateway routes each request to the best available provider.",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }' --output speech.mp3
FieldTypeNotes
modelstring, requiredSpeech model id.
inputstring ≤ 40,000 chars, requiredText to speak.
voicestring, requiredProvider/model-specific voice name.
response_formatmp3 | opus | aac | flac | wav | pcmDefault mp3. Sets the response Content-Type (audio/mpeg, audio/ogg, audio/aac, audio/flac, audio/wav, audio/pcm).
speednumber 0.25–4
routingobjectRouting override.

Response headers include X-Request-Id, X-LLM-Provider, X-LLM-Model, X-LLM-Routing-Reason and X-LLM-Cost-Micro. Speech is priced per character or per audio second depending on the model (see the model's pricing keys).

Streaming behaviour

  • Headers are sent as soon as the provider starts responding; bytes are forwarded as they arrive.
  • Retries and fallback apply only before the first byte is forwarded. A provider failure after that closes the connection early; check that the received byte count matches Content-Length when the provider supplies one, or that the container decodes cleanly.
  • Idempotency-Key is accepted (optional).
typescript
const res = await client.audio.speech.create({
  model: 'openai/tts-1',
  voice: 'alloy',
  input: 'Hello from the gateway.',
  response_format: 'mp3',
});
await fs.promises.writeFile('speech.mp3', Buffer.from(await res.arrayBuffer()));

Transcriptions (speech-to-text)

Upload an audio file as multipart/form-data.

bash
curl "https://api.smartapihub.com/v1/audio/transcriptions" \
  -H "Authorization: Bearer $LLM_API_KEY" \
  -F model="openai/whisper-1" \
  -F file=@meeting.mp3 \
  -F language=en \
  -F response_format=json
Form fieldNotes
filerequired. Audio file; total request ≤ 25 MiB.
modelrequired. Transcription model id.
languageISO-639-1 hint (e.g. en).
response_formatjson (default), text, verbose_json, srt, vtt — subject to model support.

Response for json:

json
{ "text": "Welcome everyone, let's get started with the roadmap review." }

verbose_json additionally returns language, duration and segments[] where the provider supplies them. Transcription is priced per audio second.

typescript
const transcription = await client.audio.transcriptions.create({
  model: 'openai/whisper-1',
  file: fs.createReadStream('meeting.mp3'),
});
console.log(transcription.text);

Errors

HTTPcodeCause
400validation_failedMissing voice/input/file, out-of-range speed.
413request_too_largeMultipart body over 25 MiB.
415unsupported_media_typeTranscriptions called without multipart.
403modality_not_allowedKey scope excludes audio.