Skip to main content

Azure AI Speech pass-through

The /azure_speech route forwards Azure AI Speech REST paths to Azure. Short audio goes to paths under /speech/ with the audio as the body, fast transcription goes to /speechtotext/transcriptions:transcribe as multipart form data, and batch transcription goes to paths under /speechtotext/. The body is forwarded byte for byte. The gateway checks the virtual key, adds its own Ocp-Apim-Subscription-Key and records the spend. The caller's Authorization header is the Spanway key and never reaches Azure.

Batch transcription paths create resources that belong to the gateway's Azure subscription and whose cost is unknown when the request is made, so they are limited to proxy admin keys. Any key can use short audio and fast transcription, which are priced per request.

A real-world scenario​

A field service app records short voice notes and sends them to Azure AI Speech for recognition. The app used to embed the Azure subscription key. It now posts the audio to /azure_speech/speech/recognition/conversation/cognitiveservices/v1 on the gateway with a virtual key. The subscription key is gone from the app, each technician's key has a daily budget, and the recognition calls show up on the Logs page.

Before you start​

The gateway needs the Azure Speech key and either the region or the endpoint. It looks first for a model_list deployment of provider Azure AI Speech with use_in_pass_through: true, then for the environment below.

VariablePurpose
AZURE_SPEECH_API_KEYThe subscription key the gateway sends upstream.
AZURE_SPEECH_REGIONThe Azure region, such as eastus. The gateway builds the regional endpoint from it.
AZURE_SPEECH_API_BASEOptional. A full custom endpoint instead of the region.

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, on the Add Model tab pick Azure AI Speech under Provider, fill in the key and region, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or set AZURE_SPEECH_API_KEY and AZURE_SPEECH_REGION and restart the gateway.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Recognise a short recording through the gateway.

    curl -X POST "http://localhost:4000/azure_speech/speech/recognition/conversation/cognitiveservices/v1?language=en-US" \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: audio/wav" \
    --data-binary @meeting.wav
  4. For a batch transcription, use a proxy admin key and the batch path.

    curl -X POST http://localhost:4000/azure_speech/speechtotext/v3.2/transcriptions \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
    -H "Content-Type: application/json" \
    -d '{"contentUrls": ["https://files.example.com/standup.wav"], "locale": "en-US", "displayName": "standup-2026-11-21"}'
  5. Open /ui/logs and click the newest row to see the request, the key and its cost.

Expected result​

Azure's own response, with its status code and headers. For the batch call above:

{
"self": "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.2/transcriptions/9c1e",
"displayName": "standup-2026-11-21",
"locale": "en-US",
"status": "NotStarted"
}

Short audio and fast transcription calls are costed per request and the spend log row carries the key, team and user.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /azure_speech/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
400Unsupported Azure Speech path: ... Supported prefixes are /speech/ and /speechtotext/; set AZURE_SPEECH_REGION or AZURE_SPEECH_API_BASEThe path is outside the two prefixes, or no region or endpoint is set. Fix the path or set the region.
400Azure Speech credentials not found. Set AZURE_SPEECH_API_KEY in the proxy environment.The gateway has no subscription key. Add a deployment with Use in pass through routes on, or set the variable.
403POST /speechtotext/v3.2/transcriptions manages batch transcription resources ... limited to proxy admin keysA non-admin key called a batch path. Use /speechtotext/transcriptions:transcribe, or a proxy admin key.
Any otherAzure's own error bodyAzure refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. The unified audio transcription endpoint covers synchronous transcription with every provider. Amazon Transcribe pass-through and AssemblyAI pass-through cover the other transcription services.