Mistral
Use Mistral AI models with cagent.
Overview
Mistral AI provides powerful language models through an OpenAI-compatible API. cagent includes built-in support for Mistral as an alias provider.
Setup
- Get an API key from Mistral Console
-
Set the environment variable:
export MISTRAL_API_KEY=your-api-key
Usage
Inline Syntax
The simplest way to use Mistral:
agents:
root:
model: mistral/mistral-large-latest
description: Assistant using Mistral
instruction: You are a helpful assistant.
Named Model
For more control over parameters:
models:
mistral:
provider: mistral
model: mistral-large-latest
temperature: 0.7
max_tokens: 8192
agents:
root:
model: mistral
description: Assistant using Mistral
instruction: You are a helpful assistant.
Available Models
| Model | Description | Context |
|---|---|---|
mistral-large-latest |
Most capable Mistral model | 128K |
mistral-medium-latest |
Balanced performance and cost | 128K |
mistral-small-latest |
Fast and cost-effective (default) | 128K |
codestral-latest |
Optimized for code generation | 32K |
open-mistral-nemo |
Open-weight model | 128K |
ministral-8b-latest |
Compact 8B parameter model | 128K |
ministral-3b-latest |
Smallest Mistral model | 128K |
Check the Mistral Models documentation for the latest available models.
Auto-Detection
When you run cagent run without specifying a config, cagent automatically detects available providers. If MISTRAL_API_KEY is set and higher-priority providers (OpenAI, Anthropic, Google) are not available, Mistral will be used with mistral-small-latest as the default model.
Extended Thinking
Mistral models support thinking mode through the OpenAI-compatible API. By default, cagent enables medium thinking effort:
models:
mistral:
provider: mistral
model: mistral-large-latest
thinking_budget: high # minimal, low, medium, high, or none
To disable thinking:
models:
mistral:
provider: mistral
model: mistral-large-latest
thinking_budget: none
How It Works
Mistral is implemented as a built-in alias in cagent:
- API Type: OpenAI-compatible (
openai_chatcompletions) - Base URL:
https://api.mistral.ai/v1 - Token Variable:
MISTRAL_API_KEY
This means Mistral uses the same client as OpenAI, making it fully compatible with all OpenAI features supported by cagent.
Example: Code Assistant
agents:
coder:
model: mistral/codestral-latest
description: Expert code assistant
instruction: |
You are an expert programmer using Codestral.
Write clean, efficient, well-documented code.
Explain your reasoning when helpful.
toolsets:
- type: filesystem
- type: shell
- type: think