Official Python SDK for Mistral AI API. Has gone through two major breaking rewrites: v0 → v1 (MistralClient removed) and v1 → v2 (in pre-release on GitHub, not yet on PyPI). Most LLM-generated code references v0 patterns which no longer work.
pip install mistralaiVerified import paths — ran on the pinned version, not inferred.
Minimal chat completion using v1 SDK
Replace MistralClient(api_key=...) with Mistral(api_key=...). Same constructor signature.
Change client.chat(model=m, messages=msgs) to client.chat.complete(model=m, messages=msgs)
Add .data between chunk and .choices in all streaming handlers
Replace ChatMessage(role='user', content='...') with {'role': 'user', 'content': '...'}Always include tool_call_id in tool response messages
Use PyPI docs at pypi.org/project/mistralai for v1 reference. GitHub main = v2 pre-release.
pip install 'mistralai[agents]' and ensure Python 3.10+
Refer to official Mistral AI documentation for configuring Azure/GCP deployments. Do not attempt to 'pip install mistralai-azure' or 'mistralai-gcp' as these packages are not available.