I’m having trouble with Azure OpenAI’s Whisper service when trying to convert audio to text. Even though I set up everything correctly and the same deployment works fine in Azure’s web interface, my code keeps returning a 404 error.
The error message I get is:
HTTP 404: {"error":{"code":"404","message": "Resource not found"}}
Here’s my Python code:
import os
import requests
# Set up Azure credentials
os.environ['OPENAI_KEY_AZURE'] = 'YOUR_KEY'
os.environ['OPENAI_ENDPOINT_AZURE'] = 'YOUR_ENDPOINT'
# Configuration settings
config = {
'key': os.environ.get('OPENAI_KEY_AZURE'),
'endpoint': os.environ.get('OPENAI_ENDPOINT_AZURE'),
'version': '2023-06-01-preview',
'model_name': 'my-whisper-deployment'
}
# Request headers
auth_headers = {
'api-key': config['key']
}
# Path to audio file
audio_path = '/path/to/my/recording.wav'
# Build API URL
api_url = f"{config['endpoint']}/openai/deployments/{config['model_name']}/audio/transcriptions?api-version={config['version']}"
try:
# Open and send audio file
with open(audio_path, 'rb') as sound_file:
result = requests.post(api_url, headers=auth_headers, files={"file": sound_file})
# Process response
if result.status_code == 200:
text_output = result.json().get('text', 'No text found')
print("Result:", text_output)
else:
print(f"Failed with {result.status_code}: {result.text}")
except Exception as error:
print(f"Something went wrong: {error}")
What could be causing this 404 error when the deployment works in the browser?
double-check that your deployment name in the code exactly matches what’s in azure portal - i’v been burned by spaces or dashes being different. also try adding the model parameter to your request body. azure sometimes wants it there even tho it’s already in the url.
I’ve worked with Azure APIs for years and all these endpoint formatting issues and version headaches drove me nuts. That’s why I ditched manual management completely.
Skip debugging Azure’s weird quirks - I just built my transcription workflow in Latenode instead. You connect to Azure OpenAI Whisper through their visual builder without endpoint formats or API versions breaking on you.
Best part? Drag and drop your audio processing steps, handle errors properly, and chain other services together. No more digging through Azure docs trying to figure out which API version works with which region.
You get automatic retries and way better error handling than coding from scratch. Built a similar workflow last week in 10 minutes instead of hours troubleshooting.
Had this exact same issue last month - super frustrating! Spent hours on it. The culprit was my endpoint format. Azure OpenAI endpoints need to be https://your-resource-name.openai.azure.com with no trailing slashes or extra paths. Your code looks fine, so I’m betting your endpoint variable has extra characters or wrong formatting. Also got burned by region support - some newer regions don’t fully support Whisper yet. Try East US or West Europe if you’re in a newer region. And double-check your deployment is actually active. Sometimes the portal shows it’s working but it’s not fully provisioned.
Had this exact problem recently - it’s an API version issue. The 2023-06-01-preview version doesn’t support Whisper transcriptions for all deployments. Switch to 2024-02-15-preview or 2023-09-01-preview instead. Also double-check your deployment name matches exactly what’s in the Azure portal (case sensitive). Make sure your Azure subscription has Whisper permissions enabled too - availability varies by region. Since it works in the web interface, your deployment’s fine. It’s probably just how you’re constructing the endpoint.
yea man, i had the same issue! make sure the endpoint URL is exactly right, even a tiny typo can cause a 404. also, check your deployment settings in the Azure portal, it can be super picky sometimes.