Audio

GetRouter exposes three OpenAI-compatible audio operations:

OperationEndpoint
TranscriptionPOST /v1/audio/transcriptions
TranslationPOST /v1/audio/translations
Text to speechPOST /v1/audio/speech

Use a model that supports the requested audio operation.

Transcribe audio

Upload the source file as multipart form data:

curl https://getrouter.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "model=MODEL_ID" \
  -F "response_format=json"

The JSON response contains the transcript in text.

Optional transcription fields in the API schema include:

  • language — ISO-639-1 language code
  • prompt — context or vocabulary hint
  • response_formatjson, text, srt, verbose_json, or vtt
  • temperature
  • timestamp_granularitiesword or segment

Support for optional fields depends on the selected model.

Translate audio

curl https://getrouter.ai/v1/audio/translations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "model=MODEL_ID" \
  -F "response_format=json"

The response uses the same basic text shape as transcription.

Generate speech

curl https://getrouter.ai/v1/audio/speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "input": "GetRouter connects your application to multiple AI models.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output speech.mp3

The speech request schema includes:

FieldDescription
modelRequired speech model ID
inputRequired text to synthesize
voiceRequired voice supported by the model
response_formatmp3, opus, aac, flac, wav, or pcm
speedPlayback speed for compatible models

Python transcription example

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://getrouter.ai/v1",
)

with open("recording.mp3", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model="MODEL_ID",
        file=audio_file,
    )

print(transcript.text)
Tip

Audio uploads and generated files can be large. Set client timeouts appropriately and stream file data instead of loading unnecessary copies into memory.

Billing and retries

Audio billing can depend on the model, input size, duration, or generated output. Check Pricing. Before retrying, determine whether the server completed the request and only the file download failed.

Next steps