Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Environment:Mistralai Client python Azure Deployment Environment

From Leeroopedia
Revision as of 18:35, 16 February 2026 by Admin (talk | contribs) (Auto-imported from environments/Mistralai_Client_python_Azure_Deployment_Environment.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

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.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment