A newer version of the Gradio SDK is available:
6.5.1
Azure OpenAI API Version Fix
Problem
Error: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
Root Cause: The AZURE_OPENAI_API_VERSION environment variable was set to 2024-02-01, which is outdated and not supported by the Azure OpenAI service.
Solution
Update the AZURE_OPENAI_API_VERSION to a supported version.
Recommended API Version
AZURE_OPENAI_API_VERSION=2024-07-18
Alternative Supported Versions
2024-08-01-preview(latest preview)2024-06-012024-05-01-preview2024-02-15-preview
Configuration
Local Development
Update your .env file:
# Change from:
AZURE_OPENAI_API_VERSION=2024-02-01
# To:
AZURE_OPENAI_API_VERSION=2024-07-18
HuggingFace Spaces Deployment
- Go to your Space settings
- Navigate to "Repository secrets"
- Update or add:
AZURE_OPENAI_API_VERSION=2024-07-18 - Factory reboot the Space to apply changes
Validation
Step 1: Validate Locally
Run the diagnostic script to verify your configuration:
python scripts/validate_azure_embeddings.py
Expected Output:
β
AZURE_OPENAI_API_VERSION: 2024-07-18
β
SUCCESS: Embedding generated successfully!
β
All checks passed! Your Azure OpenAI embeddings configuration is correct.
Step 2: Test the Application
python app.py
Navigate to http://localhost:7860 and test with a query to ensure no 404 errors occur.
Step 3: Verify HuggingFace Deployment
- Update the
AZURE_OPENAI_API_VERSIONsecret in HuggingFace Spaces - Restart the Space
- Monitor logs for successful startup
- Test a query to confirm the fix
Required Environment Variables
Ensure all Azure OpenAI variables are properly configured:
# Core Azure OpenAI (all required)
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini
AZURE_OPENAI_API_VERSION=2024-07-18 # UPDATED
# Embeddings deployment (CRITICAL)
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=text-embedding-3-small
Additional Notes
Checking API Version Support
To verify which API versions are supported for your Azure OpenAI resource:
- Visit the Azure OpenAI API Version Reference
- Check for deprecation notices
- Use the latest stable version for best compatibility
Impact of API Version
The API version determines:
- Available features and endpoints
- Request/response schemas
- Model availability
- Rate limits and quotas
Using an outdated or unsupported API version will result in 404 errors even if your deployment names are correct.
Prevention
For Future Deployments
Always validate before deploying:
python scripts/validate_azure_embeddings.pyKeep API version up to date: Check Azure documentation quarterly for deprecations
Document your configuration: Maintain a record of your Azure OpenAI setup
Test after updates: Always test locally before deploying to production
Testing Checklist
- Updated
AZURE_OPENAI_API_VERSIONto2024-07-18in.env - Run
python scripts/validate_azure_embeddings.pyβ Success - Test local app with
python app.pyβ No 404 errors - Updated HuggingFace Spaces secret
- Restarted HuggingFace Space
- Verified no 404 errors in production logs
- Tested query in deployed Space β Success
Related Files
.env.example- Environment variable templatescripts/validate_azure_embeddings.py- Configuration validation scriptCLAUDE.md- Development guideREADME.md- Project documentation