# Mistral SDK The Mistral SDK is the official client library for [[Mistral AI]]'s API platform, La Plateforme. Sits at the *model SDK* layer of [[AI SDKs]], peer to [[Anthropic SDK]] and [[OpenAI SDK]]. Officially supported in **Python** (`mistralai`) and **TypeScript / JavaScript** (`@mistralai/mistralai`), with a Go and TypeScript implementations also available. It is also OpenAI-API-compatible at the chat completions layer, so the [[OpenAI SDK]] can talk to Mistral's endpoints with a custom `base_url` if you want a single dependency across providers. ## API Surfaces - **Chat Completions** ; standard prompt/response, tool use, streaming - **Embeddings** ; `mistral-embed` - **Code completion** ; Codestral models - **Vision** ; Pixtral models - **OCR** ; Mistral OCR for document understanding - **Function calling** ; structured tool definitions - **JSON mode / structured outputs** - **Fine-tuning** ; via API - **Agents API** ; Mistral's own agent runtime layer (newer) ## Python Example ```python 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": "Why pick Mistral?"}], ) ``` ## TypeScript Example ```ts import { Mistral } from "@mistralai/mistralai"; const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY }); const result = await client.chat.complete({ model: "mistral-large-latest", messages: [{ role: "user", content: "Why pick Mistral?" }], }); ``` ## Why You'd Reach For It - **Open-weight models with optional managed hosting** ; Mistral 7B, 8x7B, Mistral Small/Medium/Large, Codestral, Pixtral, Mistral OCR. La Plateforme hosts the closed Large/Medium tier; the smaller models are downloadable - **EU residency** ; Mistral runs on EU infrastructure; meaningful for GDPR-strict deployments - **Specialized models** ; Codestral for code, Pixtral for vision, OCR for document workflows ; one provider covers several niches - **Strong cost / quality trade-off** for the medium tier ## Where It Fits - **Direct Mistral API access** → Mistral SDK - **Mistral as one of many providers behind one abstraction** → [[Vercel AI SDK]] with `@ai-sdk/mistral`, or [[LiteLLM]] in Python - **Self-hosted Mistral via Ollama / vLLM** → use those tools' clients (often OpenAI-API-compatible) - **Mistral via [[Groq]]** ; Groq hosts open Mistral variants on LPU silicon for very fast inference ## License Apache-2.0 on the SDK. Mistral's models have varying licenses (Apache-2.0 for many open-weight ones; commercial licenses for Large/Medium). ## References - Python SDK: https://github.com/mistralai/client-python - TypeScript SDK: https://github.com/mistralai/client-ts - Documentation: https://docs.mistral.ai/ ## Related - [[Mistral AI]] - [[Anthropic SDK]] - [[OpenAI SDK]] - [[AI SDKs]] - [[Vercel AI SDK]] - [[LiteLLM]] - [[Groq]]