Skip to main content

Audio

POST https://gateway-api.mastra.ai/v1/audio/speech
POST https://gateway-api.mastra.ai/v1/audio/transcriptions

Compatible with the OpenAI Audio API. List speech and transcription models with /v1/models. Each model's endpoints includes speech or transcription.

Speech
Direct link to Speech

curl https://gateway-api.mastra.ai/v1/audio/speech \
-H "Authorization: Bearer $MASTRA_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs/eleven-flash-v2.5",
"input": "Hello from Gateway.",
"voice": "YOUR_VOICE_ID"
}' \
--output speech.mp3

model:

string
A speech model from `/v1/models`.

input:

string
Text to speak, 1 to 4,096 characters.

voice:

string
A voice supported by the model.

response_format?:

'mp3' | 'pcm'
= mp3
Audio format. pcm is available only on models that support it.

A speech request stays on one voice and model, so it doesn't fail over to a different model.

Transcriptions
Direct link to Transcriptions

Send one audio file as multipart form data:

curl https://gateway-api.mastra.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $MASTRA_GATEWAY_API_KEY" \
-F model="deepgram/nova-3" \
-F file="@meeting.mp3"
  • Files can be up to 8 MiB in MP3, MP4, M4A, WAV, WebM, OGG, or FLAC format.
  • The response is a JSON transcript. response_format must be json if set.
On this page