Codestral

On this page 7

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.

ModeInputTypical use
Fill-in-the-middlePrefix and suffix around the cursorInline completion in the editor
Instruction chatNatural-language request with codeExplanations, tests, refactoring
Code generationSpecification or docstringNew functions and boilerplate
EmbeddingCode snippets or queriesRetrieval and semantic code search
Codestral interaction modes

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.

ModelApproximate sizeContext windowDistribution
Codestral 22B22 billion parameters32,000 tokensOpen weights, non-production license
Codestral MambaAbout 7 billion parametersLong context, tested to 256,000 tokensOpen weights, Apache 2.0
Codestral 25.01Not fully disclosed256,000 tokensAPI and enterprise deployment
Codestral 25.08Not fully disclosed256,000 tokensEnterprise coding stack
Codestral EmbedNot fully disclosedConfigurable embedding dimensionsAPI for retrieval
Main members of the Codestral family

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.

ModelPrimary strengthOpennessTypical role
CodestralFast fill-in-the-middle completionMixed: open and hosted versionsIDE autocomplete and chat
DevstralAgentic software engineeringOpen weightsRepository-level agents
Code LlamaEarly open code baselineOpen weightsResearch and self-hosting
StarCoderTransparent training dataOpen weightsResearch and custom fine-tuning
Qwen-CoderStrong benchmark results across sizesOpen weightsSelf-hosted assistants
Codestral and related code models

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.

RequirementRecommended optionReason
Fast start for individual developersHosted API with IDE pluginNo infrastructure to maintain
Code must not leave the networkOn-premises enterprise deploymentKeeps proprietary code under internal control
Research or experimentationOpen-weight 22B or Mamba modelLocal testing and fine-tuning
Large monorepo understandingLong-context version with retrieval256,000 tokens plus indexed context
Choosing a Codestral deployment

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.