Audio
The three audio endpoints follow OpenAI’s Audio API. Models for each are listed with GET /v1/models?output_modalities=speech and ?output_modalities=transcription, and on indorouter.ai/models.
Text to speech
Section titled “Text to speech”curl https://api.indorouter.ai/v1/audio/speech \ -H "Authorization: Bearer $INDOROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "openai/gpt-4o-mini-tts", "voice": "alloy", "input": "Hello, welcome to indoRouter."}' \ --output hello.mp3import osfrom openai import OpenAI
client = OpenAI( base_url="https://api.indorouter.ai/v1", api_key=os.environ["INDOROUTER_API_KEY"],)
with client.audio.speech.with_streaming_response.create( model="openai/gpt-4o-mini-tts", voice="alloy", input="Hello, welcome to indoRouter.",) as response: response.stream_to_file("hello.mp3")| Field | Notes |
|---|---|
model |
Required. A speech model ID. |
input |
Required. The text to read. Each model has a character limit, indorouter.speech_input_characters_max in GET /v1/models. Longer text is refused with input_too_large. |
voice, speed, instructions |
Forwarded to the vendor unchanged. |
response_format |
The audio format. OpenAI’s models default to MP3. Google’s Gemini speech models support only wav (the default) or pcm. |
stream_format |
Leave it out. It is refused. |
The response body is the audio itself, with the vendor’s Content-Type. The JSON body may be up to 64 KB.
Billing depends on the model’s units.speech_billing. characters means a price per character of input, the tts_characters rate divided by 1,000,000. tokens means your text at the prompt rate plus the audio produced at the audio_output rate.
Speech to text
Section titled “Speech to text”Send the audio file as multipart/form-data:
curl https://api.indorouter.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $INDOROUTER_API_KEY" \ -F model=openai/gpt-4o-mini-transcribe \ -F file=@meeting.mp3import osfrom openai import OpenAI
client = OpenAI( base_url="https://api.indorouter.ai/v1", api_key=os.environ["INDOROUTER_API_KEY"],)
with open("meeting.mp3", "rb") as audio: result = client.audio.transcriptions.create( model="openai/gpt-4o-mini-transcribe", file=audio, )print(result.text)| Field | Notes |
|---|---|
file |
Required. Up to 25 MB, in WAV, MP3, FLAC, Ogg, MP4/M4A or WebM. We read the audio duration before forwarding the file. If the duration cannot be read, the request is rejected with unreadable_media. |
model |
Required. A transcription model ID. |
prompt, language, response_format, temperature, chunking_strategy, timestamp_granularities, include, known_speaker_names, known_speaker_references |
Forwarded to the vendor unchanged. |
stream |
Leave it out. Streaming is not available. |
The vendor’s JSON response is returned unchanged.
POST /v1/audio/translations takes the same form and returns English text. Only openai/whisper-1 translates; other models refuse with translation_not_served.
Billing depends on the model’s units.audio_billing. seconds means a price per second of audio, the audio_seconds rate divided by 1,000,000. tokens means the audio at the audio rate plus the transcript at the completion rate. Either way, the amount reserved before processing is calculated from the audio duration.
See Error codes for errors and how to handle them.