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(...) and mistral.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 *_async counterpart.
  • 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

  1. Install – pip install mistralai (or uv add mistralai).
  2. Set your API key – export MISTRAL_API_KEY or point MISTRAL_SA_TOKEN_PATH to a service‑account token file.
  3. Write code – import Mistral and 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)
    
  4. Run examples – the repo ships an examples/ folder you can execute with uv 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