Mistral AI Python SDK

1.12.4 · active · verified Sat Feb 28

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.

Warnings

Install

Imports

Quickstart

Minimal chat completion using v1 SDK

import os
from mistralai import Mistral

client = Mistral(api_key=os.environ['MISTRAL_API_KEY'])

response = client.chat.complete(
    model='mistral-large-latest',
    messages=[{'role': 'user', 'content': 'Hello'}]
)
print(response.choices[0].message.content)

view raw JSON →