Skip to content
exoticrouter.com ↗

Audio

Two endpoints in OpenAI’s audio format: one reads text aloud, the other writes down what was said.

POST https://api.exoticrouter.com/v1/audio/speech

cURL
curl https://api.exoticrouter.com/v1/audio/speech \
-H "Authorization: Bearer $EXOTIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini-tts",
"voice": "alloy",
"input": "The sky is blue because air scatters blue light the most."
}' \
-o speech.mp3
Python
with client.audio.speech.with_streaming_response.create(
model="openai/gpt-4o-mini-tts",
voice="alloy",
input="The sky is blue because air scatters blue light the most.",
) as response:
response.stream_to_file("speech.mp3")
TypeScript
import fs from "node:fs";
const speech = await client.audio.speech.create({
model: "openai/gpt-4o-mini-tts",
voice: "alloy",
input: "The sky is blue because air scatters blue light the most.",
});
fs.writeFileSync("speech.mp3", Buffer.from(await speech.arrayBuffer()));
  • model has to be a speech model: one whose formats in the list of models has speech.
  • The answer is the audio itself, sent as it is made, with its own content type (audio/mpeg for MP3). The rest of the body, voice and the output format for instance, goes to the model.

POST https://api.exoticrouter.com/v1/audio/transcriptions

Send the recording as a form, with the model beside it.

cURL
curl https://api.exoticrouter.com/v1/audio/transcriptions \
-H "Authorization: Bearer $EXOTIC_API_KEY" \
-F model="openai/gpt-4o-mini-transcribe" \
-F file="@meeting.mp3"
Python
transcript = client.audio.transcriptions.create(
model="openai/gpt-4o-mini-transcribe",
file=open("meeting.mp3", "rb"),
)
print(transcript.text)
TypeScript
import fs from "node:fs";
const transcript = await client.audio.transcriptions.create({
model: "openai/gpt-4o-mini-transcribe",
file: fs.createReadStream("meeting.mp3"),
});
console.log(transcript.text);
{ "text": "Right, shall we start? First on the list is the launch date." }
  • model has to be a transcription model: one whose formats has transcriptions.
  • The file and every other part of the form reach the model unchanged. Ask for another response_format, plain text or subtitles, and the answer comes in it.
  • The whole request, recording included, may be up to 32 MiB.
  • Speech is priced on the characters of input: for a speech model, input_per_mtok is USD per million characters.
  • Transcription is priced on the tokens the model reports where it reports them, and otherwise on the length of the recording, by the second.
  • A model’s per_request, if it has one, is added once to each request.

Billing has the whole of it.