Environment:Mistralai Client python Azure Deployment Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Cloud_Deployment |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Python 3.10+ environment with the `mistralai_azure` package for Mistral models deployed on Azure AI.
Description
This environment provides the context for running Mistral models through Azure AI endpoints. It uses the separate `mistralai_azure` package (version 1.8.x) which wraps the Azure-specific authentication and endpoint configuration. The package auto-appends `/v1/` to Azure endpoint URLs if missing, and rewrites the User-Agent header to include Azure-specific identifiers.
Usage
Use this environment when deploying and consuming Mistral models through Azure AI services. It is required for the Azure Chat Completion workflow and supports both synchronous and streaming completions, as well as OCR processing.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Same as core SDK |
| Python | >= 3.10 | Consistent with main SDK requirement |
| Cloud | Azure subscription | Must have Mistral model deployed via Azure AI |
Dependencies
System Packages
- No additional system packages beyond core SDK
Python Packages
- `mistralai_azure` >= 1.8.0 (or install via main SDK)
- `httpx` >= 0.28.1
- `httpcore` >= 1.0.9
- `pydantic` >= 2.11.2
Credentials
The following environment variables must be set:
- `AZURE_API_KEY`: API key from the Azure AI deployment portal.
- `AZURE_ENDPOINT`: Azure AI endpoint URL (e.g., `https://your-resource.models.ai.azure.com`).
Quick Install
# Install the Azure package
pip install mistralai_azure
Code Evidence
Azure environment variable usage from `examples/azure/chat_no_streaming.py`:
client = MistralAzure(
azure_api_key=os.environ["AZURE_API_KEY"],
azure_endpoint=os.environ["AZURE_ENDPOINT"],
)
Azure endpoint auto-appending from `packages/mistralai_azure/src/mistralai_azure/sdk.py`:
# The SDK auto-appends /v1/ to the azure_endpoint if not present
MistralAzure(
azure_api_key=azure_api_key,
azure_endpoint=azure_endpoint, # e.g., "https://your-resource.models.ai.azure.com"
)
Custom User-Agent hook from `packages/mistralai_azure/src/mistralai_azure/_hooks/custom_user_agent.py`:
# Rewrites User-Agent header to include Azure-specific SDK identifier
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `MistralAzureError` (HTTP 401) | Invalid Azure API key | Verify `AZURE_API_KEY` matches the key from Azure portal |
| `MistralAzureError` (HTTP 404) | Wrong endpoint URL or model not deployed | Verify `AZURE_ENDPOINT` and ensure the Mistral model is deployed in Azure AI |
| `httpx.ConnectError` | Cannot reach Azure endpoint | Check network/firewall settings and verify endpoint URL format |
Compatibility Notes
- Endpoint format: The SDK automatically appends `/v1/` to the endpoint URL if not already present.
- Model naming: Azure deployment names may differ from standard Mistral model IDs.
- Features: Azure package supports `chat.complete`, `chat.stream`, and `ocr.process` only. Other features like embeddings and fine-tuning are not available through Azure.