Codestral is a family of code-specialized language models from Mistral AI, designed for code completion, fill-in-the-middle editing, test generation and answering programming questions. In the field of AI for coding, it is best known as a low-latency completion engine that powers inline suggestions in editors and IDE plugins, rather than as a general-purpose chat model.
The family includes the original 22-billion-parameter Codestral, an experimental Codestral Mamba variant built on a state-space architecture, later API releases with a 256,000-token context window, and a separate Codestral Embed model for semantic code search.
How Codestral completes and generates code
Codestral is a decoder-only transformer trained predominantly on source code and technical text covering more than 80 programming languages, from Python, Java, C++ and JavaScript to Bash, SQL, Swift and Fortran. Like other code models, it predicts the next tokens of a program, but its training places strong weight on the fill-in-the-middle objective.
In fill-in-the-middle mode, the editor sends the code before the cursor as a prefix and the code after the cursor as a suffix. The model generates only the missing span, so a suggestion respects both the function signature above and the return statement below. This mode is what makes Codestral suitable for inline autocomplete, where a response must arrive in a few hundred milliseconds.
The model is also served through an instruction-following chat endpoint, which handles tasks such as explaining a function, writing unit tests or converting code between languages. The table below lists the main interaction modes.
| Mode | Input | Typical use |
|---|---|---|
| Fill-in-the-middle | Prefix and suffix around the cursor | Inline completion in the editor |
| Instruction chat | Natural-language request with code | Explanations, tests, refactoring |
| Code generation | Specification or docstring | New functions and boilerplate |
| Embedding | Code snippets or queries | Retrieval and semantic code search |
Codestral models and versions
Mistral AI released the first Codestral in 2024 with open weights under a non-production license, which allowed research and evaluation but required a commercial agreement for production use. Subsequent releases moved toward hosted API access, longer context and faster inference, while the Mamba variant was published under the permissive Apache 2.0 license.
The following overview uses approximate public figures; versions are named by year and month, and capabilities may change with later updates, so the values are indicative rather than definitive.
| Model | Approximate size | Context window | Distribution |
|---|---|---|---|
| Codestral 22B | 22 billion parameters | 32,000 tokens | Open weights, non-production license |
| Codestral Mamba | About 7 billion parameters | Long context, tested to 256,000 tokens | Open weights, Apache 2.0 |
| Codestral 25.01 | Not fully disclosed | 256,000 tokens | API and enterprise deployment |
| Codestral 25.08 | Not fully disclosed | 256,000 tokens | Enterprise coding stack |
| Codestral Embed | Not fully disclosed | Configurable embedding dimensions | API for retrieval |
Codestral Mamba is notable because it replaces attention with a Mamba state-space architecture, whose inference cost grows linearly with sequence length. It demonstrated that non-transformer designs can be competitive for code, although transformer versions remained the primary product line.
Codestral compared with other code models
Code models differ in size, license, latency and agentic capability. Codestral targets the completion and editing loop, while larger general models and agent-oriented models such as Devstral target multi-step tasks in a repository. The comparison below places Codestral among well-known alternatives.
| Model | Primary strength | Openness | Typical role |
|---|---|---|---|
| Codestral | Fast fill-in-the-middle completion | Mixed: open and hosted versions | IDE autocomplete and chat |
| Devstral | Agentic software engineering | Open weights | Repository-level agents |
| Code Llama | Early open code baseline | Open weights | Research and self-hosting |
| StarCoder | Transparent training data | Open weights | Research and custom fine-tuning |
| Qwen-Coder | Strong benchmark results across sizes | Open weights | Self-hosted assistants |
Benchmark scores on HumanEval, MBPP or LiveCodeBench give a rough ranking, but real-world acceptance rates depend on latency, context retrieval and the editor integration. A smaller model with lower latency often produces a better developer experience than a stronger but slower model.
Deploying Codestral in development workflows
Teams use Codestral through Mistral’s API, through IDE extensions such as Continue and JetBrains plugins, through cloud model catalogs, or as a self-hosted deployment where source code must stay inside the company network. The choice depends on data policy, expected traffic and the license of the selected version.
The decision table below maps common requirements to a suitable deployment option.
| Requirement | Recommended option | Reason |
|---|---|---|
| Fast start for individual developers | Hosted API with IDE plugin | No infrastructure to maintain |
| Code must not leave the network | On-premises enterprise deployment | Keeps proprietary code under internal control |
| Research or experimentation | Open-weight 22B or Mamba model | Local testing and fine-tuning |
| Large monorepo understanding | Long-context version with retrieval | 256,000 tokens plus indexed context |
Limitations and risks
Like all code models, Codestral can produce plausible but incorrect code, including subtle off-by-one errors, outdated API calls and insecure patterns. Every suggestion should pass the same review, testing and static analysis as human-written code before it reaches production.
- Package hallucination: suggested imports may name libraries that do not exist, which attackers can exploit by registering those names.
- License confusion: the non-production license of the original weights does not permit commercial deployment without an agreement.
- Context limits: without repository indexing, completions ignore conventions defined in distant files.
- Benchmark overfitting: published scores may not reflect performance on proprietary frameworks and internal coding styles.
Understanding it simply
Codestral is an AI model that helps programmers write code faster. While a developer types, it guesses the next lines and shows them in gray. Pressing a key accepts the suggestion.
It is a bit like the predictive text on a phone, but for software. It has read a very large amount of code, so it knows common patterns. It can also explain code or write tests on request. A person must still check every suggestion, because the model can be confidently wrong.
Applied in practice
A financial software company with about 300 developers cannot send its source code to external services because of regulatory and contractual obligations. It deploys a Codestral enterprise model on its own GPU servers and connects it to the developers’ IDEs through an internal completion endpoint.
The platform team indexes the main repositories so that completions follow internal naming conventions and shared libraries. After a three-month pilot, the team measures a suggestion acceptance rate of roughly 30 percent for inline completions and faster creation of unit tests. Static analysis and mandatory code review remain unchanged, and the security team adds a check that blocks imports of unknown packages.