Skip to content

Mistral Codestral

Mistral Codestral is Mistral AI's first dedicated code generation model, trained on 80+ programming languages with a context window of 128K tokens and fill-in-the-middle (FIM) support for in-context code completion.

Tool Use
index.ts
import { streamText } from 'ai'
const result = streamText({
model: 'mistral/codestral',
prompt: 'Why is the sky blue?'
})

Playground

Try out Mistral Codestral by Mistral AI. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.

Providers

Route requests across multiple providers. Copy a provider slug to set your preference. Visit the docs for more info. Using a provider means you agree to their terms, listed under Legal.

Provider
Context
Latency
Throughput
Input
Output
Cache
Web Search
Per Query
Capabilities
ZDR
No Training
Release Date
Mistral AI
Legal:Terms
Privacy
128K
0.2s
106tps
$0.30/M$0.90/M
05/29/2024
Throughput

P50 throughput on live AI Gateway traffic, in tokens per second (TPS). Visit the docs for more info.

Latency

P50 time to first token (TTFT) on live AI Gateway traffic, in milliseconds. View the docs for more info.

Uptime

Direct request success rate on AI Gateway and per-provider. Visit the docs for more info.

More models by Mistral AI

Model
Context
Latency
Throughput
Input
Output
Cache
Web Search
Per Query
Capabilities
Providers
ZDR
No Training
Release Date
256K
0.3s
39tps
$0.40/M$2.00/M
mistral logo
12/09/2025
256K
0.2s
121tps
$0.20/M$0.20/M
mistral logo
12/01/2025
128K
0.2s
190tps
$0.10/M$0.10/M
mistral logo
10/01/2024
32K
0.3s
208tps
$0.10/M$0.30/M
mistral logo
09/01/2024
$0.10/M
mistral logo
12/11/2023
256K
0.3s
118tps
$1.50/M$7.50/M
mistral logo

About Mistral Codestral

Announced May 29, 2024, Mistral Codestral was the first model Mistral AI dedicated entirely to code. With 22 billion parameters and training across more than 80 programming languages, including Python, Java, C, C++, JavaScript, Bash, Swift, and Fortran, Mistral Codestral covers the breadth of languages developers encounter in production.

Mistral Codestral's defining technical feature is fill-in-the-middle (FIM) support. Unlike instruction-only models that generate code from a prompt, FIM lets Mistral Codestral complete code within a partial snippet. Mistral Codestral can insert a function body, finish a conditional branch, or complete a class method given the surrounding context. This makes Mistral Codestral a natural fit for IDE integrations like Continue.dev and Tabnine, where code above and below the cursor is provided as context.

Beyond completion, Mistral Codestral handles test generation and documentation authoring. Its context window of 128K tokens was over four times larger than those of competing models at launch, so Mistral Codestral can process full files rather than truncated snippets.

What To Consider When Choosing a Provider

  • Configuration: Mistral Codestral's context window of 128K tokens was over four times larger than the 4K to 16K windows typical of competing code models at release. You can reason over entire files or multi-file snippets in a single request.
  • Zero Data Retention: AI Gateway supports Zero Data Retention for this model via direct gateway requests (BYOK is not included). To configure this, check the documentation.
  • Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.

When to Use Mistral Codestral

Best For

  • IDE and editor plugins: Requiring fill-in-the-middle code completion
  • Automated test generation: Producing unit or integration tests from existing source code
  • Documentation generation: Writing inline docs and reference material for functions, classes, and modules
  • Code translation between languages: Converting source across languages, for example Python to TypeScript
  • Broad language coverage: Applications that need wide support in a single model

Consider Alternatives When

  • Agentic software engineering: You need multi-file orchestration (consider Devstral)
  • Semantic code search: Your primary requirement is search rather than generation (consider Codestral Embed)
  • Reasoning-heavy problem solving: You need deep reasoning alongside coding (consider Magistral)

Conclusion

Mistral Codestral established Mistral AI's footprint in developer tooling when it launched. Mistral Codestral remains relevant for teams that need broad language coverage, fill-in-the-middle completion, and a context window of 128K tokens optimized for code. Mistral AI's coding model family builds on this foundation.

Frequently Asked Questions

  • What is fill-in-the-middle (FIM) and how does Mistral Codestral use it?

    FIM allows Mistral Codestral to complete code given both a prefix (code before the cursor) and a suffix (code after the cursor). Mistral Codestral uses this to insert completions inside partial functions or expressions, which is the dominant pattern in IDE plugins.

  • How many programming languages does Mistral Codestral support?

    Mistral Codestral was trained on over 80 programming languages. Benchmarked languages include Python, C++, Bash, Java, PHP, TypeScript, C#, SQL, Swift, and Fortran.

  • What is Mistral Codestral's context window?

    128K tokens. At launch this was over four times larger than the 4K to 16K windows typical of competing code models.

  • Can Mistral Codestral write unit tests?

    Yes. Test generation is an explicit use case in Mistral AI's documentation for Mistral Codestral alongside code completion and documentation authoring.

  • Is Mistral Codestral available as an open-weight model?

    Yes. Weights are available on HuggingFace under the Mistral AI Non-Production License (MNPL). Commercial API access is available through La Plateforme and AI Gateway.

  • How does Mistral Codestral integrate with IDEs?

    Mistral Codestral integrates with Continue.dev and Tabnine plugins for VS Code and JetBrains, using the FIM API for in-editor completions.

  • How is Mistral Codestral different from Devstral?

    Mistral Codestral is a code generation and completion model focused on individual file-level tasks. Devstral is an agentic model designed to navigate entire codebases, resolve GitHub issues, and orchestrate multi-file changes autonomously.