Codestral API Pricing: Mistral's Coding Model at $0.30/$0.90 Per Million Tokens
Codestral is Mistral's code-focused model, optimized for code generation, completion, and fill-in-the-middle — with 256K context for large codebases.
TL;DR
- Price: $0.30/M input, $0.90/M output — 3:1 output ratio, efficient for code generation
- Context: 256K tokens — handles large codebases, multi-file refactors, and full project context
- Specialization: Code-only — optimized for code generation, completion, fill-in-the-middle, and debugging
- Provider: Mistral (French company) — EU data sovereignty advantage for European teams
- Best for: Code completion, code generation, refactoring, fill-in-the-middle, multi-file editing
- Cheaper alternative: Devstral Small 2 at $0.10/$0.30 for high-volume, lower-complexity code tasks
Codestral Pricing Breakdown
At $0.30 per million input tokens and $0.90 per million output tokens, Codestral is 8x cheaper on input than GPT-5.4 ($2.50/$15) while being specifically optimized for code. Here's how the costs scale:
| Monthly Volume | Input Cost | Output Cost | Total Cost |
|---|---|---|---|
| 1M tokens | $0.30 | $0.90 | $1.20 |
| 10M tokens | $3.00 | $9.00 | $12.00 |
| 100M tokens | $30.00 | $90.00 | $120.00 |
| 1B tokens | $300.00 | $900.00 | $1,200.00 |
At 100M tokens/month, Codestral costs $120. The same volume on GPT-5.4 would cost $875+, and on Claude Sonnet 5 it would cost $900+.
How Codestral Compares to Other Budget Models
| Model | Input $/M | Output $/M | Context | Specialization | Provider |
|---|---|---|---|---|---|
| Devstral Small 2 | $0.10 | $0.30 | 128K | Code | Mistral |
| DeepSeek V4 Flash | $0.14 | $0.28 | 1M | General | DeepSeek |
| Qwen 3.7 Flash | $0.03 | $0.13 | 1M | General | Alibaba |
| Codestral | $0.30 | $0.90 | 256K | Code | Mistral |
| Devstral 2 | $0.40 | $2.00 | 128K | Code | Mistral |
| GPT-5 nano | $0.05 | $0.40 | 128K | General | OpenAI |
Codestral sits between the cheapest general-purpose models and the mid-tier code models. It's specifically optimized for code tasks — meaning better code quality per dollar than general-purpose models at similar price points.
Mistral Coding Family: Codestral vs Devstral 2 vs Devstral Small 2
Mistral offers three code-focused models at different price tiers. Here's how they compare:
| Feature | Codestral | Devstral 2 | Devstral Small 2 |
|---|---|---|---|
| Input price | $0.30/M | $0.40/M | $0.10/M |
| Output price | $0.90/M | $2.00/M | $0.30/M |
| Context window | 256K | 128K | 128K |
| Fill-in-the-middle | Yes | Yes | Yes |
| Code quality | Best | Mid-tier | Good |
| Best for | Complex code tasks, large codebases | Mid-complexity code generation | High-volume completions, cost-sensitive |
Rule of thumb: Use Codestral for complex code generation and large codebases (256K context). Use Devstral Small 2 for high-volume, cost-sensitive completions. Devstral 2 sits in between but is actually more expensive per token than Codestral — so Codestral is usually the better choice at that tier.
When to Use Codestral
Code Completion
IDE-style code completion with fill-in-the-middle support. Provide prefix and suffix, get the code in between. Ideal for developer tools and plugins.
Code Generation
Generate functions, classes, or entire modules from natural language descriptions. The 3:1 output ratio keeps costs efficient for generation-heavy workloads.
Multi-File Refactoring
256K context lets you load entire codebases for cross-file refactors, dependency updates, and architectural changes. No chunking needed for most projects.
Code Review
Automated code review: find bugs, suggest improvements, check style compliance. Code-specialized training means better detection of code-specific issues.
Test Generation
Generate unit tests, integration tests, and edge case coverage from existing code. Optimized for understanding code patterns and generating valid test cases.
Documentation
Generate docstrings, API documentation, and inline comments from code. Understands code structure better than general-purpose models for accurate docs.
When NOT to Use Codestral
Codestral is optimized for code tasks. For non-code work, general-purpose models are a better fit:
- General chat/Q&A: Use Qwen 3.7 Flash ($0.03/$0.13) or GPT-5 nano ($0.05/$0.40) — cheaper for non-code tasks
- Creative writing: Use Claude Opus 5 ($5/$25) or GPT-5.4 ($2.50/$15) — better at nuanced, creative outputs
- Data extraction: Use GPT-5 nano ($0.05/$0.40) or DeepSeek V4 Flash ($0.14/$0.28) — more cost-effective for structured extraction
- Vision/multimodal: Codestral is text-only — use Qwen 3.7 Flash ($0.03/$0.13) or Gemini 2.5 Flash-Lite ($0.10/$0.40) for image inputs
- Massive context (500K+): Use Gemini 2.5 Flash-Lite (1M, $0.10/$0.40) or Qwen 3.7 Flash (1M, $0.03/$0.13) for context beyond 256K
Real-World Cost Scenario
Let's say you're building a code completion tool that processes 100,000 code completions per month, with an average of 500 input tokens (context prefix) and 150 output tokens (generated code) per completion:
| Model | Monthly Input | Monthly Output | Total |
|---|---|---|---|
| Devstral Small 2 | $5.00 | $4.50 | $9.50 |
| Codestral | $15.00 | $13.50 | $28.50 |
| Devstral 2 | $20.00 | $30.00 | $50.00 |
| Claude Sonnet 5 | $100.00 | $150.00 | $250.00 |
| GPT-5.4 | $125.00 | $225.00 | $350.00 |
Codestral costs $28.50/month for 100K code completions — 3x cheaper than Devstral 2, 9x cheaper than Claude Sonnet 5, and 12x cheaper than GPT-5.4. For even tighter budgets, Devstral Small 2 does it for $9.50/month.
Frequently Asked Questions
Calculate Your Codestral Costs
Enter your token counts and see exactly what you'd pay. Compare Codestral against 93+ other models instantly.
Related Pages
- Mistral Small 4 Pricing — Mistral's general-purpose budget model at $0.15/$0.60
- Mistral Pricing Guide — Full breakdown of all Mistral models
- Mistral Provider Page — All Mistral models compared
- GPT-5 nano Pricing — OpenAI's cheapest at $0.05/$0.40
- DeepSeek V4 Pro Pricing — Budget reasoning model
- Full Model Rankings — All models ranked by price