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.

Updated Aug 14, 2026 · 93+ models tracked across 11 providers

TL;DR

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:

FeatureCodestralDevstral 2Devstral 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 window256K128K128K
Fill-in-the-middleYesYesYes
Code qualityBestMid-tierGood
Best forComplex code tasks, large codebasesMid-complexity code generationHigh-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:

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:

ModelMonthly InputMonthly OutputTotal
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

How much does Codestral cost?
$0.30 per million input tokens and $0.90 per million output tokens. The 3:1 output-to-input ratio makes it efficient for code generation, where output tokens typically outnumber input tokens.
What is the difference between Codestral and Devstral?
Codestral is Mistral's flagship coding model at $0.30/$0.90 with 256K context and the best code quality. Devstral 2 ($0.40/$2.00, 128K) is a mid-tier alternative, and Devstral Small 2 ($0.10/$0.30, 128K) is the cheapest option in Mistral's coding family. All three support fill-in-the-middle for code completion.
Does Codestral support fill-in-the-middle?
Yes. Codestral supports fill-in-the-middle (FIM), which lets you provide a prefix and suffix and have the model generate the code in between. This is essential for IDE code completion, autocompletion plugins, and code refactoring tools.
Is Codestral cheaper than GPT-5.4 for code generation?
Yes, significantly. Codestral costs $0.30/$0.90 while GPT-5.4 costs $2.50/$15. That's 8x cheaper on input and 16x cheaper on output. Codestral is code-specialized, so it often matches or exceeds GPT-5.4 quality on coding tasks despite the lower price.
What is the cheapest Mistral coding model?
Devstral Small 2 is the cheapest at $0.10/M input and $0.30/M output with a 128K context window. It's ideal for high-volume code completion where cost is the primary concern. For better quality, Codestral ($0.30/$0.90) with 256K context is the recommended choice.

Calculate Your Codestral Costs

Enter your token counts and see exactly what you'd pay. Compare Codestral against 93+ other models instantly.

Related Pages