Skip to content
Dashboard

Codestral Embed

Codestral Embed is Mistral AI's first embedding model specialized for code, outperforming general-purpose and competing code embedding models on real-world retrieval benchmarks.

index.ts
import { embed } from 'ai';
const result = await embed({
model: 'mistral/codestral-embed',
value: 'Sunny day at the beach',
})

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
$0.15/M——
05/28/2025

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
$1.50/M$7.50/M——
+1
mistral logo
04/29/2026
256K
0.4s
61tps
$0.50/M$1.50/M——
mistral logo
12/02/2025
128K
0.3s
172tps
$0.10/M$0.10/M——
mistral logo
10/16/2024
128K
0.3s
82tps
$0.15/M$0.15/M——
mistral logo
10/16/2024
32K
0.3s
132tps
$0.10/M$0.30/M——
mistral logo
09/17/2024
$0.10/M——
mistral logo
12/11/2023

About Codestral Embed

Released May 28, 2025, Codestral Embed is Mistral AI's first embedding model purpose-built for code. Codestral Embed achieves an 85% average score on code retrieval benchmarks, outperforming Voyage Code 3, Cohere Embed v4.0, and OpenAI's large embedding model on evaluations derived from real-world code data.

Codestral Embed supports variable dimensions with ordered relevance. You can truncate to the first n dimensions and still get ranked embeddings. Mistral AI's benchmarks show retrieval performance even at 256 dimensions with int8 precision, enabling index size reduction without proportional quality loss.

The context window is 0 tokens. For repositories with large files, Mistral AI recommends chunking at 3,000 characters with 1,000-character overlap. This balances retrieval recall against chunk boundary artifacts.

What To Consider When Choosing a Provider

  • Configuration: Codestral Embed supports variable embedding dimensions, letting you tune the size-versus-quality tradeoff to match your vector store's cost and latency constraints.
  • 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 Codestral Embed

Best For

  • RAG pipelines for coding agents: Building pipelines that retrieve relevant code snippets
  • Semantic code search: Large repositories where keyword search is insufficient
  • Duplicate code detection: Similarity analysis across codebases using Codestral Embed's 85% average on code retrieval benchmarks
  • Code clustering: For analytics, refactoring identification, or repository organization
  • Large-scale indexing pipelines: Workloads where embedding cost is a primary concern at millions of documents

Consider Alternatives When

  • General text documentation: You need to embed prose rather than source code (consider Mistral AI Embed)
  • Natural language retrieval: Your workload is primarily over descriptions of code rather than code itself
  • Generation alongside embedding: You require both capabilities in a single model call

Conclusion

Codestral Embed fills a gap that general-purpose embedding models leave open. Code has structural patterns, syntax, and semantics that differ from prose, and a model trained on real-world code data retrieves it more accurately. For teams building coding agents, code search, or repository analytics, Codestral Embed is more precise than adapting a text embedding model.