Audio transcription
/v1/audio/transcriptions converts audio into text in the OpenAI format. The gateway supports OpenAI, Azure OpenAI, Deepgram, Groq, Fireworks, AssemblyAI, Amazon Transcribe, Azure AI Speech, Soniox, ElevenLabs and other speech-to-text providers behind one request format, and prices transcriptions per second or per token as the price map records. Applications upload a file and get the transcript back, and the admin can change the provider behind the public name without the applications noticing.
Scenario
A meetings tool records calls and needs transcripts with timestamps. The admin registers a transcription model and gives the tool a key. The tool uploads each recording as it finishes, asks for verbose_json to get segments, and the gateway bills every minute of audio to the tool's key. When the team trials a cheaper provider, the admin adds a second deployment under the same name and compares the results in the Logs page.
Steps
-
Register the model. In the Admin UI open Models + Endpoints (
/ui/models-and-endpoints), click Add Model, pick the Provider, choose the model, set the Public Model Name towhisper-1and set Mode to Audio Transcription - /audio/transcriptions so health checks send a short clip, then click Add Model.model_list:- model_name: whisper-1spanway_params:model: openai/whisper-1api_key: os.environ/OPENAI_API_KEYmodel_info:mode: audio_transcription -
Create a key in Virtual Keys (
/ui/api-keys) and pick the model under Models. -
Upload a recording.
curl -X POST http://localhost:4000/v1/audio/transcriptions \-H "Authorization: Bearer $SPANWAY_API_KEY" \-F "model=whisper-1" \-F "file=@meeting.wav" \-F "language=en" \-F "response_format=verbose_json" -
Try it in the browser. Open Playground (
/ui/playground), set Endpoint Type to/v1/audio/transcriptions, pick the model, drop an audio file (MP3, MP4, MPEG, MPGA, M4A, WAV or WEBM up to 25 MB) on the upload area and send. -
Check the cost in Logs (
/ui/logs). The row shows the audio duration and the cost.
Expected result
{
"text": "Let's start with the incident review.",
"language": "english",
"duration": 12.4,
"segments": [{"id": 0, "start": 0.0, "end": 3.2, "text": "Let's start with the incident review."}]
}
With response_format=text the body is the plain transcript.
Request fields
| Field | Meaning |
|---|---|
file | The audio file. |
model | Public model name. |
language | Input language hint. |
prompt | Text to guide style or spelling. |
response_format | json, text, srt, vtt or verbose_json. |
temperature | Sampling temperature where supported. |
timestamp_granularities | word or segment timestamps with verbose_json. |
Streaming and realtime
For live transcription use the realtime endpoint, which supports transcription sessions. Batch jobs on Amazon Transcribe and Azure AI Speech are available through their pass-through routes.
Gateway features
Transcriptions are cached when transcription is in the cache's supported_call_types, screened by guardrails on the resulting text, and limited in size by max_file_size_mb set in a deployment's spanway_params, which needs an Enterprise license. The whole request is also limited by general_settings.max_request_size_mb, 100 MB by default. general_settings.moderation_model and completion_model never change the transcription model, the model you send is the one used.
Errors
| Status | What it means | Fix |
|---|---|---|
400 BadRequestError | file is missing, the format is not accepted by the provider, or response_format is not supported by the model. | Send a supported audio format and format name. |
400 File size is too large. Please check your file size. Passed file size: <n> MB. Max file size: <m> MB | The file is larger than the deployment's spanway_params.max_file_size_mb. | Split the recording or raise the limit on the deployment. |
400 Tried setting max_file_size_mb for /audio/transcriptions. ... | A deployment sets max_file_size_mb but the gateway has no Enterprise license. | Load a license or remove the setting from the deployment. |
| 413 | The request is larger than general_settings.max_request_size_mb. | Split the recording or raise the limit. |
401 AuthenticationError | The key is missing, wrong or expired. | Use a live key. |
403 PermissionDeniedError | The key may not use the model. | Add the model to the key. |
429 RateLimitError | Budget or rate limit reached. | Raise the limit or add a deployment. |
Cost shows 0 | The model has no per-second or per-token price. | Set input_cost_per_second on the deployment with custom pricing. |
Related
- Text to speech for the other direction.
- Realtime API for live transcription sessions.
- Caching for caching transcriptions.
Providers
The gateway's endpoint support matrix marks 16 provider integrations as supporting this endpoint:
AIHubMix (aihubmix), AssemblyAI (assemblyai), Azure, Azure AI, Azure Text, Custom OpenAI (custom_openai), Deepgram, Eden AI, Nvidia Riva (nvidia_riva), Oobabooga (oobabooga), OpenAI, OVHCloud AI Endpoints, Scaleway, Soniox (soniox), Text Completion OpenAI, IBM - Watsonx.ai.