Choose Auto, TokenLab Verified, or Official for each request, with prices shown up front. See what's new

Mistral: Codestral Embed

Codestral Embed is Mistral's embedding model for source-code search. It maps code and related queries into vectors for repository retrieval, helping coding assistants find relevant functions and files before generating or editing code.
Compare models
codestral-embed
AvailableMistralEmbeddingSync
Input / Output
$0.15 / $0.00
Context
8K
Modalities
Embedding

About Codestral Embed

Codestral Embed is Mistral AI's first embedding model built for code. It turns source files, snippets, and natural-language questions into vectors so a coding assistant can retrieve the right functions before it writes or edits anything. Mistral reports that it beats Voyage Code 3, Cohere Embed v4.0, and OpenAI's large embedding model on its code-retrieval evaluations. Mistral's general-purpose text embedder, Mistral Embed, is the better fit for prose.

Where it works well

  • Trained for code retrieval, covering natural-language-to-code search, code-to-code similarity, and SQL retrieval in Mistral's evaluation suite.
  • Output dimensions are ordered by relevance, so you can keep any number of leading dimensions to shrink the index.
  • Mistral reports that even 256 dimensions at int8 precision outperform the competing code embedders it tested.
  • Suits retrieval-augmented generation for coding agents, duplicate detection, clustering, and code analytics.

When to choose another model

  • It embeds only; it does not generate or explain code, so you still need a chat model for answers.
  • Mistral advises chunks of about 3,000 characters with 1,000 overlap, because larger chunks hurt retrieval quality.
  • For non-code documents such as policies or support articles, a general text embedding model is the more natural choice.

Getting started

  1. Create API key

    Create a key in Console, then use it with every model on the platform.

  2. Send your first request

    Copy the example for your language and run it against the endpoint.

    EmbeddingTokenLab endpoint
    POST/v1/embeddings
    curl -X POST "https://api.tokenlab.sh/v1/embeddings" \
      -H "Authorization: Bearer sk-xxx" \
      -H "Content-Type: application/json" \
      -d '{
      "encoding_format": "float",
      "model": "codestral-embed",
      "input": "The quick brown fox jumps over the lazy dog."
    }'

Parameters

Embedding

ParameterValues and limitsDefaultNotes
encoding_formatfloat, base64Not providedNot provided
inputNot providedNot providedNot provided

Pricing

The Verified price applies to Verified, which costs less on most models. The Official price is the model maker's published price and applies to the more reliable Official route. Auto bills the route that completes the request.

Embedding

per 1M tokens
Official price
Input $0.15 / Output $0.00 / Cache read $0.015
Verified price
—
Discount
—
Prompt cache pricing

Cache read

Official price
$0.015
Verified price
—
Discount
—

Usage & activity

Success rate is the share of requests that completed. Latency is how long a full response takes; P95 means 95% of requests finished within that time.

Usage & availability

Last 24 hours
Requests
Success rate
P95 latency
Total tokens
Model performance
Metrics appear once privacy and data volume thresholds are met.

Data is based on aggregate user requests, excluding status checks.

Open in Console

Open Codestral Embed in Console with a prompt ready to edit or send.

Help me try codestral-embed with embedding at /v1/embeddings. Show the result and cost.

Use cases

  • Repository search for coding agents

    Index every function and file of a codebase, then retrieve the closest matches to a task description before the agent edits code.

  • Natural-language code search

    Let developers type a question such as how retries are handled and get the relevant source files back instead of keyword hits.

  • Duplicate and near-clone detection

    Embed functions across services and flag pairs with very close vectors, which points to copy-pasted logic worth consolidating.

  • Issue-to-code matching

    Embed bug reports and match them to the files most likely to need a fix, as a first step for triage bots.

Prompt examples

Where in this repository do we validate webhook signatures?

def retry_with_backoff(fn, attempts=5): ... (embed a function to find similar helpers in other services)

SELECT customer_id, SUM(total) FROM orders GROUP BY customer_id HAVING SUM(total) > 1000

This model has conditional pricing. Monthly token totals alone cannot produce a reliable estimate; use the detailed pricing for the request specification, cache, and applicable time window.

FAQ

What is Codestral Embed used for?

Retrieval over source code. You embed code chunks and queries, store the vectors, and fetch the nearest chunks by similarity. Typical jobs are semantic code search, context retrieval for coding agents, duplicate detection, and clustering of code by purpose.

How is Codestral Embed different from Mistral Embed?

Codestral Embed is specialised for code and code-related queries, while Mistral Embed is a general text model for documents, clustering, and retrieval-augmented generation over prose. Use Codestral Embed for repositories and Mistral Embed for knowledge bases and articles.

Can I reduce the vector size?

Yes. Mistral orders the output dimensions by relevance, so you can keep a shorter prefix for a smaller index. Mistral reports that 256 dimensions at int8 precision still beat the competing code embedders it tested, but check recall on your own code.

How should I split code before embedding it?

Mistral recommends chunks of around 3,000 characters with 1,000 characters of overlap. Larger chunks lowered retrieval performance in its tests. Split along function or class boundaries where you can, and keep file path and symbol name with each chunk.

Does it generate code?

No. It returns vectors only. Pair it with a coding chat model: Codestral Embed finds the relevant code, and the chat model reads it and writes the change.

How much does Codestral Embed cost?

On TokenLab, Codestral Embed costs Input $0.15 / Output $0.00 per 1M tokens. The pricing table above shows the full breakdown. Rates depend on the billing unit, specification, and usage. Compare matching conditions in the model's detailed pricing; a single rate does not determine the total cost.

Which endpoint should Codestral Embed use?

Use https://api.tokenlab.sh/v1/embeddings for Codestral Embed. The request example below shows the matching code shape.

Which operations does Codestral Embed support?

Codestral Embed supports Embedding. Select an operation above to see its endpoint and request example.

Compare Codestral Embed

Sources

Reviewed Oct 2, 2026

More from Mistral

Related models