Back to Models

Codestral is Mistral AI's specialized coding model family, first released May 29, 2024 as a 22.2B-parameter open-weight model. It was designed from the ground up for code generation, completion, and fill-in-the-middle (FIM) tasks rather than general-purpose chat. Over its lifecycle, Codestral has seen two major revisions: Codestral 25.01 (Jan 2025) expanded the context window to 256K tokens and introduced a more efficient tokenizer, and Codestral 25.08 (Jul 2025) delivered roughly 30% more accepted code suggestions. The model supports 80+ programming languages.

For TheRouter operators, Codestral occupies a distinct niche: it is a fast, lightweight code completion model rather than an agentic coding assistant. Its native Fill-in-the-Middle (FIM) capability makes it ideal for IDE autocomplete, short single-file scaffolding, and test generation β€” workloads where latency matters more than deep reasoning. It is not designed for multi-file refactoring, complex agent loops, or tool-calling workflows; those are better served by Mistral's Devstral 2 or Claude Opus 4.7. On TheRouter, Codestral is reachable through the standard OpenAI-compatible chat completions endpoint, and its $0.30 / $0.90 per million tokens pricing makes it one of the most cost-effective code-completion options available through any router.

Best for
  • β€’ IDE code autocomplete and fill-in-the-middle (FIM) β€” low-latency inline suggestions in editors supporting Mistral's completion protocol
  • β€’ Single-file code generation, refactoring, and documentation β€” scaffolding utilities, writing tests, or generating docstrings with fast turnaround
  • β€’ Cost-sensitive code completion pipelines where priority is low price per suggestion rather than reasoning depth β€” $0.30/$0.90 per million tokens
  • β€’ Fine-tuning base for domain-specific code models β€” the original 22B open weights allow custom training on proprietary codebases
Reach for something else if
  • β€’ Agentic multi-file refactoring or autonomous debugging β€” use Mistral Devstral 2 (agent-optimized with tool use) or Claude Opus 4.7
  • β€’ General-purpose chat or reasoning tasks β€” route to Mistral Small 4, Mistral Large 3, or GPT-4o-mini instead
  • β€’ Vision or multimodal inputs β€” Codestral is text-only; use Pixtral Large for image understanding
  • β€’ Tasks requiring function calling or tool use β€” Codestral's design emphasizes code completion over agentic workflows; use Claude Sonnet 4.6 or GPT-5o
Context Length
256K
Max Output
16K
Input Priceper 1M tokens
$0.324/ 1M tokens
Output Priceper 1M tokens
$0.972/ 1M tokens

Modalities

text→text

Pricing Breakdown

TypeRate
Input$0.324 / 1M tokens
Output$0.972 / 1M tokens

Supported Parameters

temperaturemax_tokenstop_ptoolstool_choiceresponse_formatstop

Specifications

Release date2024-05-29 (original); 2025-01-13 (25.01); 2025-07-30 (25.08)mistral.ai β†—verified
Architecture22.2B-parameter dense decoder-only transformer (original). 25.01/25.08 architecture not publicly disclosed β€” estimated below 100B parameters with improved tokenizerhuggingface.co β†—to verify
Context window32K (original); 256K (25.01+); TheRouter entry shows 256Kmistral.ai β†—verified
Native fill-in-the-middle (FIM)Yes β€” Codestral's core design feature. Natively trained for FIM completion; 25.01 improved FIM quality with new tokenizermistral.ai β†—verified
Languages80+ programming languages including Python, Java, JavaScript, TypeScript, C++, Go, Rust, SQLmistral.ai β†—verified
LicenseMistral AI Non-Production License (original 22B open weights). Codestral 25.01+ is API-only β€” weights not publicly releasedhuggingface.co β†—verified
SuccessorMistral Devstral 2 (May 2025) is the agentic coding successor with tool use and multi-file capabilities. Codestral 25.08 remains available for pure code completion workloadsverified

Benchmarks

BenchmarkDistributionScoreSource
HumanEval pass@1
Original Codestral 22B (May 2024); Python single-function code generation
81.1%%mistral.ai β†—
HumanEval pass@1
Codestral 25.01 (Jan 2025) β€” Python single-function pass@1 improvement over original
86.6%%mistral.ai β†—
HumanEval FIM average
Codestral 25.01 fill-in-the-middle across Python, Java, JavaScript
85.9%%mistral.ai β†—
MBPP sanitized pass@1
Codestral 25.01 β€” Python program synthesis
80.2%%mistral.ai β†—
CruxEval
Python output prediction β€” original Codestral 22B (May 2024)
75.5%%mistral.ai β†—
RepoBench EM
Long-range repository-level code completion β€” original Codestral 22B; outperformed Code Llama 70B and DeepSeek Coder 33B at launch
34.0%%mistral.ai β†—
Spider SQL
Text-to-SQL generation β€” Codestral 25.01
66.5%%overchat.ai β†—

API Usage Examples

Use the global api.therouter.ai endpoint shown below for new integrations; the legacy China accelerated endpoint is retired.

cURL
curl https://api.therouter.ai/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer $THE_ROUTER_API_KEY"   -d '{
    "model": "mistral/codestral",
    "messages": [
      {"role": "user", "content": "Summarize the key points from this input."}
    ]
  }'

Chat completion

Standard OpenAI-compatible chat completion. Codestral responds best to explicit code-generation prompts.

cURL
curl https://api.therouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $THEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistral/codestral",
    "messages": [
      {"role": "user", "content": "Write a Python function to merge two sorted arrays into one sorted array."}
    ],
    "temperature": 0.2
  }'

More from mistral

Similar models

Cross-provider sibling models

News & changes

2025-07-30

Codestral 25.08: +30% accepted suggestions, complete Mistral coding stack

Mistral released Codestral 25.08 alongside Codestral Embed, Devstral 2, and the Mistral Vibe CLI β€” forming an end-to-end enterprise coding stack. Codestral 25.08 delivers roughly 30% more accepted code suggestions over 25.01, with improved latency.

re-authored by TheRoutermistral.ai β†—
2025-01-13

Codestral 25.01: 256K context, 2x speed, improved FIM

Mistral released Codestral 25.01 with a 256K context window (up from 32K), a more efficient tokenizer, and roughly 2x faster code generation. HumanEval pass@1 improved from 81.1% to 86.6%. FIM scores reached 85.9% across Python, Java, and JavaScript.

re-authored by TheRoutermistral.ai β†—

Frequently asked

Is Codestral a good general-purpose chatbot?

No β€” Codestral is specialized for code generation and completion. For general chat, routing to Mistral Small 4 or Mistral Large 3 will give better results at comparable or lower cost. The standard-models.yaml entry lists tools/tool_choice in supported_params, but in practice Codestral's design emphasis is on raw code completion, not agentic tool use.

What is fill-in-the-middle (FIM) and why does it matter?

FIM is a code completion technique where the model fills in a missing section of code given surrounding context (prefix and suffix). Codestral is natively trained for this, making it ideal for IDE autocomplete where the cursor is in the middle of a file. Codestral 25.01 scored 85.9% average on HumanEval FIM across Python, Java, and JavaScript.

Can I fine-tune Codestral on my own codebase?

Only the original Codestral 22B (May 2024) has publicly available open weights, licensed under Mistral AI's Non-Production License. Codestral 25.01 and 25.08 are API-only β€” their weights have not been publicly released. Mistral does offer fine-tuning for Codestral through their own API platform, so custom training is possible via that route.

How does Codestral compare to Devstral 2?

Codestral is a focused code completion model β€” fast, cheap, and specialized for single-file generation and inline FIM. Devstral 2 (May 2025) is the agentic successor built on top of the Mistral coding stack, adding tool calling, autonomous debugging, multi-file refactoring, and MCP integration. If you need IDE autocomplete or cheap code generation, use Codestral. If you need an agent that edits whole repositories, use Devstral 2 via TheRouter.

Fact ledger β€” every claim on this page traces here
sourceURLretrieved
Release datemistral.ai β†—2026-05-27verified
Architecturehuggingface.co β†—2026-05-27to verify
Context windowmistral.ai β†—2026-05-27verified
Native fill-in-the-middle (FIM)mistral.ai β†—2026-05-27verified
Languagesmistral.ai β†—2026-05-27verified
Licensehuggingface.co β†—2026-05-27verified
Successorβ€”β€”verified
HumanEval pass@1mistral.ai β†—2026-05-27verified
HumanEval pass@1mistral.ai β†—2026-05-27verified
HumanEval FIM averagemistral.ai β†—2026-05-27verified
MBPP sanitized pass@1mistral.ai β†—2026-05-27verified
CruxEvalmistral.ai β†—2026-05-27verified
RepoBench EMmistral.ai β†—2026-05-27verified
Spider SQLoverchat.ai β†—2026-05-27to verify
Codestral 25.08: +30% accepted suggestions, complete Mistral coding stackmistral.ai β†—2026-05-27verified
Codestral 25.01: 256K context, 2x speed, improved FIMmistral.ai β†—2026-05-27verified
Is Codestral a good general-purpose chatbot?mistral.ai β†—2026-05-27to verify
What is fill-in-the-middle (FIM) and why does it matter?mistral.ai β†—2026-05-27to verify
Can I fine-tune Codestral on my own codebase?huggingface.co β†—2026-05-27to verify
How does Codestral compare to Devstral 2?mistral.ai β†—2026-05-27to verify
Help & contact