mistralai/client-python
Python client library for Mistral AI platform
Mistral Python Client – Quick Overview
What it is: An official Python SDK for calling Mistral AI’s cloud services – chat‑completion, embeddings, audio, file handling, agents, and a host of management APIs. It lets you talk to Mistral models from your own Python code, both synchronously and with asyncio.
Key features
- Chat & agents – simple
mistral.chat.complete(...)andmistral.agents.complete(...)calls, with optional streaming. - Embeddings –
mistral.embeddings.create(...)for vectorising text. - File uploads – upload workspace files via
mistral.files.upload(...). - Audio – speech synthesis and transcription endpoints.
- Batch jobs, libraries, connectors, conversations – full‑featured management of Mistral resources (e.g., document libraries for RAG).
- Async support – every operation has an
*_asynccounterpart. - Server‑sent events – streaming responses via SSE.
- Built‑in pagination, retries, and error handling.
- Cloud‑provider wrappers – ready‑made clients for Azure AI and Google Cloud (Vertex AI) that automatically handle auth and endpoint construction.
How to get started
- Install –
pip install mistralai(oruv add mistralai). - Set your API key – export
MISTRAL_API_KEYor pointMISTRAL_SA_TOKEN_PATHto a service‑account token file. - Write code – import
Mistraland call the desired method, e.g.:from mistralai.client import Mistral import os with Mistral(api_key=os.getenv("MISTRAL_API_KEY")) as client: resp = client.chat.complete( model="mistral-large-latest", messages=[{"role": "user", "content": "Hello!"}], stream=False, ) print(resp) - Run examples – the repo ships an
examples/folder you can execute withuv run.
Why it matters: The SDK abstracts away HTTP details, token rotation, pagination, and streaming, letting developers focus on building applications (chatbots, RAG pipelines, voice assistants, etc.) that leverage Mistral’s large language models.
Related
- Project
- Dispatch
- Project
- Dispatch
- Project