Speech & audio
MirAPI has three OpenAI-compatible audio endpoints: transcription turns speech into text, translation turns audio into English, and text-to-speech generates speech from text. All three use the OpenAI protocol, so you authenticate with Authorization: Bearer and point your OpenAI SDK at https://api.mirapi.ai/v1.
| Endpoint | What it does | Request | Response |
|---|---|---|---|
POST /v1/audio/transcriptions |
Transcribe audio to text | multipart/form-data |
JSON with a text field |
POST /v1/audio/translations |
Translate audio to English | multipart/form-data |
JSON with a text field |
POST /v1/audio/speech |
Synthesize speech from text | JSON body | Raw audio bytes |
Transcribing and translating
Section titled “Transcribing and translating”Both endpoints take the audio file as multipart/form-data; file and model are required. transcriptions returns the text in the language of the audio (or the one you set with language), while translations always returns English.
Uploading a file
Section titled “Uploading a file”curl https://api.mirapi.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $MIRAPI_API_KEY" \ -F file=@speech.mp3 \ -F model="deepseek-chat" \ -F response_format="json"import osfrom openai import OpenAI
client = OpenAI(base_url="https://api.mirapi.ai/v1", api_key=os.environ["MIRAPI_API_KEY"])
with open("speech.mp3", "rb") as audio: transcript = client.audio.transcriptions.create( model="deepseek-chat", file=audio, response_format="json", )
print(transcript.text)For translation, change the path to /v1/audio/translations. The request shape is the same.
Parameters
Section titled “Parameters”| Field | Type | Required | Notes |
|---|---|---|---|
file |
binary | Yes | The audio file |
model |
string | Yes | Speech-to-text model name from the catalog |
language |
string | No | ISO-639-1 language code (transcriptions only) |
prompt |
string | No | Context or terminology hint to steer the transcript |
response_format |
string | No | json (default), text, srt, verbose_json, vtt |
temperature |
number | No | Sampling temperature |
timestamp_granularities |
array | No | word and/or segment (transcriptions only) |
translations accepts the same fields except language and timestamp_granularities.
Response formats
Section titled “Response formats”response_format controls the shape of the result:
json(default): a JSON object with atextfield.text: the transcript as plain text.srtandvtt: subtitle files.verbose_json: a JSON object with segment-level detail. Addtimestamp_granularities(word/segment) to choose how fine-grained the timestamps are.
Text-to-speech
Section titled “Text-to-speech”/v1/audio/speech takes a JSON body with the text, a voice, and a format, and returns raw audio bytes, not JSON. Save or stream the response body directly.
Generating speech
Section titled “Generating speech”curl https://api.mirapi.ai/v1/audio/speech \ -H "Authorization: Bearer $MIRAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-chat", "input": "Hello from MirAPI", "voice": "alloy", "response_format": "mp3" }' \ -o speech.mp3import osfrom openai import OpenAI
client = OpenAI(base_url="https://api.mirapi.ai/v1", api_key=os.environ["MIRAPI_API_KEY"])
response = client.audio.speech.create( model="deepseek-chat", input="Hello from MirAPI", voice="alloy", response_format="mp3",)
response.stream_to_file("speech.mp3")Parameters
Section titled “Parameters”| Field | Type | Required | Notes |
|---|---|---|---|
model |
string | Yes | Text-to-speech model name from the catalog |
input |
string | Yes | Text to synthesize (up to 4096 characters) |
voice |
string | Yes | alloy, echo, fable, onyx, nova, or shimmer |
response_format |
string | No | mp3 (default), opus, aac, flac, wav, pcm |
speed |
number | No | 0.25–4.0 (default 1.0); supported where the model allows it |
Output formats
Section titled “Output formats”Choose the output format with response_format. mp3, opus, and aac are compressed; flac is lossless; wav and pcm are uncompressed. Use a compressed format for storage and an uncompressed one when fidelity matters more than size. The response body is the audio itself, so pipe it straight to a file.
Choosing a model
Section titled “Choosing a model”Audio endpoints only work with models that support the task. For /v1/audio/speech pick a model with audio output; for transcription and translation pick a speech-to-text model. Browse the catalog at https://platform.mirapi.ai or query GET /v1/models, check each model’s capabilities, and send the exact id it returns. A vendor/ prefix you may see in the Platform is only for browsing and is not part of the model ID you send.
Errors, billing, and logs
Section titled “Errors, billing, and logs”- Errors follow the standard status codes:
401for a missing or invalid key,403for a valid key that is rejected (for example, an exhausted balance or a model not on the key’s whitelist),413for a file that is too large,429for rate limiting, and500for an upstream failure. For429, retry with exponential backoff; the gateway does not send aRetry-Afterheader. Every error message ends with a request ID; include it in support tickets. - Billing uses a per-model price in USD, shown on each catalog entry. Audio requests appear in the Platform billing log and in
GET /api/log/token, and the account-level summary is inGET /api/usage/token. When your balance runs out, requests fail with403. Top up and the same key works again.
Related links
Section titled “Related links”- Models & pricing: how to pick a model and read its price
- Billing & top-ups: balances, pricing units, and reconciliation
- Realtime speech: live speech-to-speech over WebSocket