Installation
The Mistral AI client is included in the core Koog library. No additional dependencies required.Quick Start
Authentication
API Key Setup
Get your API key from Mistral AI Platform.Programmatic Configuration
Available Models
Chat Models
General-purpose conversation and reasoning models.- 128K context window
- Multimodal: vision, images, documents
- Tools and function calling
- Structured JSON outputs
- 128K context window
- Most capable for complex reasoning
- Tools and function calling
- Structured JSON outputs
- 32K context window
- Efficient for standard tasks
- Tools and function calling
Reasoning Models
Advanced models with extended reasoning capabilities.- 128K context window
- Advanced reasoning with speculation
- Vision and document processing
- Structured JSON outputs
Coding Models
Specialized models optimized for software engineering tasks.- 256K context window
- Fill-in-the-middle, code completion
- Code correction and test generation
- Low-latency responses
- 128K context window
- Codebase exploration and editing
- Multi-file editing
- Software engineering agents
Embedding Models
Vector embeddings for semantic search and RAG.Moderation Model
Content safety and harmful content detection.Code Examples
Basic Chat Completion
Function Calling
Vision - Image Analysis
Document Processing
Structured Output
Embeddings
Code Embeddings
Content Moderation
Streaming Responses
Advanced Configuration
Custom Parameters
Speculation (Predictive Decoding)
Use speculation for faster generation when output is predictable:Tool Choice Control
Model Capabilities
| Model | Context | Vision | Docs | Tools | Embeddings | Moderation |
|---|---|---|---|---|---|---|
| Mistral Medium 3.1 | 128K | ✅ | ✅ | ✅ | ❌ | ❌ |
| Mistral Large 2.1 | 128K | ❌ | ❌ | ✅ | ❌ | ❌ |
| Mistral Small 2 | 32K | ❌ | ❌ | ✅ | ❌ | ❌ |
| Magistral Medium 1.2 | 128K | ✅ | ✅ | ✅ | ❌ | ❌ |
| Codestral | 256K | ❌ | ❌ | ✅ | ❌ | ❌ |
| Devstral Medium | 128K | ❌ | ✅ | ✅ | ❌ | ❌ |
| Mistral Embed | 8K | ❌ | ❌ | ❌ | ✅ | ❌ |
| Codestral Embed | 8K | ❌ | ❌ | ❌ | ✅ | ❌ |
| Mistral Moderation | 8K | ❌ | ❌ | ❌ | ❌ | ✅ |
Pricing
Pricing varies by model. See Mistral AI Pricing for current rates. Model Tiers:- Premier Models: Mistral Medium 3.1, Large 2.1, Small 2, Magistral Medium 1.2, Codestral, Devstral Medium
- All premier models require API access and have usage-based pricing
Best Practices
- Use Mistral Large 2.1 for complex reasoning and high-stakes tasks
- Use Codestral for code completion, fill-in-the-middle, and low-latency coding
- Use Devstral Medium for codebase exploration and multi-file editing
- Use Mistral Medium 3.1 for multimodal tasks with vision
- Enable safe prompt for user-facing applications
- Use Codestral Embed for code search and semantic code analysis
- Leverage 256K context in Codestral for large codebase analysis
Use Cases
Software Engineering Agents
Software Engineering Agents
Use Devstral Medium or Codestral for building agents that explore codebases, edit multiple files, and assist with software development tasks.
Code Generation
Code Generation
Use Codestral for low-latency code completion, fill-in-the-middle, test generation, and code corrections.
Multimodal Analysis
Multimodal Analysis
Use Mistral Medium 3.1 or Magistral Medium 1.2 for processing images, documents, and mixed-content analysis.
Complex Reasoning
Complex Reasoning
Use Mistral Large 2.1 or Magistral Medium 1.2 for tasks requiring advanced reasoning and problem-solving.
Code Search & RAG
Code Search & RAG
Use Codestral Embed for semantic code search, code similarity, and RAG applications with code.
Content Safety
Content Safety
Use Mistral Moderation to detect and filter harmful content in user inputs.