AI State of the Art
Mistral/Mistral Models: Complete Catalog/9 min
Section 248

Codestral Embed: Code Embeddings

Listen as a podcast →

Codestral Embed: the model that generates nothing

The name invites confusion. Codestral writes code; Codestral Embed, released on 28 May 2025 (version v25.05), does the exact opposite: it does not produce code, it turns code into vectors. Two distinct products, two prices, two API names.

The principle behind embeddings is explained on the Mistral Embed page: turn a text into a list of numbers that captures its meaning, so that two pieces close in meaning end up close in space.

Why code deserves its own model

You might assume a good general-purpose embedding model would do. It does not, and the reason is instructive.

Take two functions that sort a list, one in Python, one in Rust. They do the same thing. But they share almost no words: different keywords, different syntax, different variable names. A model trained on prose will see two texts that have nothing to do with each other.

Conversely, two functions that look very much alike can behave radically differently, one flipped comparison is enough. Code is a domain where surface similarity and semantic similarity diverge violently. Hence the value of a model that learned on code.

What it is for

Finding code. It is the retrieval brick underneath coding agents: before modifying a repository of a million lines, you first have to find the twenty lines that matter. An agent that read the whole repository on every question would be slow and ruinous; an agent that guessed would be cheap and wrong.

Mistral also cites semantic search across a codebase, duplicate detection, and repository analysis.

The link to RAG

This is the same mechanism as RAG, applied to code: index first, retrieve second, and hand the model only the relevant pieces. If the topic interests you beyond Mistral, the Search Toolkit treats retrieval quality as a subject in its own right.

Its distinctive feature: vectors of adjustable geometry

This is the interesting technical point, and it is a rare one. Two parameters let you choose the trade-off between quality and storage cost.

  • output_dimension sets the vector size: 1536 by default, 3072 at most. The subtlety is that the dimensions are ordered by relevance. To get a vector of size n, you simply keep the first n values, nothing needs recomputing. It is a continuous dial, not a binary choice.
  • output_dtype sets the precision of each number: float (32 bits, the most precise), int8, uint8, or even binary / ubinary, where each value fits in a single bit, the resulting vector then takes an eighth of its nominal size.

This idea of ordering dimensions so a vector can be truncated without recomputation has a name, and the course devotes a lesson to it: Matryoshka embeddings, after the Russian dolls that nest inside one another. Codestral Embed is a direct application of it.

Why this flexibility changes the bill

A vector database costs memory, and memory is expensive. Going from 3072 dimensions at 32 bits to 256 dimensions at 8 bits shrinks the footprint by a considerable factor.

Mistral claims that at dimension 256 and int8 precision, Codestral Embed still beats competing models. In other words the dial is not a trade-off between "good" and "cheap": on this particular case, you can have both. That is the kind of claim to verify on your own data, but the architectural idea (ordering dimensions by relevance so the vector can be truncated) is solid and quite real.

Chart titled Retrieval performance vs embedding storage cost: retrieval quality NDCG at 10 on the vertical axis, relative storage cost on the horizontal axis, on a logarithmic scale from under one hundredth to full cost. Four models are compared, each point annotated with its dimension and precision, from 256 binary to 3072 float, with distinct symbols for float32, int8 and binary. The orange Codestral Embed curve stays above those of Voyage Code 3, Cohere Embed v4.0 and OpenAI Text Embedding 3 Large across the whole range.
Matryoshka truncation in numbers, as published by Mistral: each point is a dimension-and-precision setting. Higher is better, further left is cheaper to store. Look at the far left in particular: the 256-dimension int8 configuration of Codestral Embed, at roughly one hundredth of the storage cost, still sits above the heaviest configurations of the three competitors, the claim made in the text, as the vendor publishes it.Source : Mistral AI, Codestral Embed announcement

What Mistral claims against the competition

The announcement positions Codestral Embed ahead of Voyage Code 3, Cohere Embed v4.0 and OpenAI's large embedding model on real-world code retrieval.

Two families of tests are highlighted: SWE-Bench, built on genuine GitHub issues and their fixes, which measures the ability to find the right file from a bug description; and Text2Code, which measures retrieval of the context needed to complete or edit code.

Read these numbers carefully

These are vendor-published comparisons, on test sets the vendor chose. That does not make them worthless (SWE-Bench is a public, recognised benchmark) but the only measurement that concerns you is the one run on your codebase. An embedding model can be tested in a day: index a sample, ask twenty questions whose answers you already know, and count.

Quick reference

CharacteristicValue
Versionv25.05, released 28 May 2025
Maximum context8,192 tokens
Dimension1536 by default, 3072 at most, truncatable
Precisionsfloat, int8, uint8, binary, ubinary
Price$0.15 per million tokens (50% discount in batch mode)
API namecodestral-embed
LicencePremier, proprietary model, available through the API

Mistral recommends chunking code into segments of roughly 3,000 characters with 1,000 characters of overlap for good retrieval results.

Still in the catalogue

Unlike the code models absorbed into Mistral Medium 3.5 during the April 2026 consolidation, Codestral Embed still appears in the official list of available models, with no announced retirement date. It does a job no large generative model does: produce a vector, fast and for almost nothing.


If Codestral is the reflex that completes your line, Codestral Embed is the memory that knows where, in your repository, that code lives.