# Voyage Code 3

Voyage Code 3 is Voyage AI by MongoDB's code-specialized embedding model. It covers 300+ programming languages with a context window of 0 tokens and outperforms OpenAI text-embedding-3-large by 13.80% across 32 code retrieval datasets.

- **Model ID:** `voyage/voyage-code-3`
- **Type:** embedding
- **Providers:** voyage
- **Context window:** Not applicable
- **Maximum output tokens:** 0
- **Pricing:** $0.18/1M input tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/voyage-code-3

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { embed } from 'ai';

const result = await embed({
  model: 'voyage/voyage-code-3',
  value: 'Sunny day at the beach',
})
```

## About

Voyage Code 3 is Voyage AI by MongoDB's code-specialized embedding model, released December 4, 2024. It supports a context window of 0 tokens and produces embeddings in four dimensions: 2048, 1024, 512, and 256. Voyage AI by MongoDB trained it on trillions of tokens combining text, code, and mathematical content plus real-world query-code pairs from GitHub repositories. It covers over 300 programming languages.

Across 32 code retrieval datasets, Voyage Code 3 outperforms OpenAI text-embedding-3-large by 13.80% and CodeSage-large by 16.81%. At 1024 dimensions, it retains 92.28% of its full-precision quality, compared to 77.64% for OpenAI at the same dimension. This makes dimension reduction particularly effective for cost or latency optimization.

Quantization-aware training supports 32-bit float, `int8`, `uint8`, binary, and unsigned binary formats. Binary embeddings at 256 dimensions still outperform OpenAI text-embedding-3-large by 4.81% while using 1/384th the storage of 3072-dimensional float embeddings. These compression options make Voyage Code 3 practical for very large codebases where millions of files need indexing.

## What to consider

Voyage Code 3 covers 300+ programming languages, the widest language coverage in Voyage AI by MongoDB's code embedding lineup. If your codebase spans multiple languages or includes less common languages, this breadth eliminates the need for language-specific models.

At 1024 dimensions, Voyage Code 3 retains 92.28% quality versus 77.64% for OpenAI. This makes dimension reduction particularly effective for Voyage Code 3, enabling large-scale code search indices at lower storage cost.

Voyage Code 3 doubles the context window (32K vs. 16K), adds Matryoshka dimensionality, and expands language coverage from a handful of languages to 300+. For new code search deployments, Voyage Code 3 is the recommended option.

## When to use

### Best For

- **Enterprise code search** across polyglot repositories with hundreds of programming languages
- **RAG for code generation** where retrieving relevant code examples, patterns, and documentation improves generated output quality
- **Large-scale code indexing** where binary or int8 embeddings at 256-1024 dimensions keep storage costs manageable across millions of files
- **Text-to-code retrieval** where natural language queries need to surface relevant functions, classes, and modules
- **Code-to-code similarity** for detecting duplicates, finding related implementations, and recommending refactoring targets
- **Developer tools and IDE integrations** that need fast, accurate code search as a backend service

### Consider Alternatives When

- **Your retrieval corpus is primarily natural language** with little or no code; voyage-3.5 or voyage-3-large are better general-purpose choices
- **Your workload is exclusively in one domain** like legal or finance; domain-specific models may provide marginal accuracy gains for that domain
- **You need multimodal embeddings** that handle images and code screenshots alongside text
- **Maximum cost efficiency is required** and your code retrieval accuracy requirements are moderate; voyage-3.5-lite handles code as one of its eight evaluated domains

## Best for

- **Enterprise code search:** Polyglot repositories with hundreds of programming languages
- **RAG for code generation:** Retrieving relevant code examples, patterns, and documentation improves generated output quality
- **Large-scale code indexing:** Binary or int8 embeddings at 256-1024 dimensions keep storage costs manageable across millions of files
- **Text-to-code retrieval:** Natural language queries surface relevant functions, classes, and modules
- **Code-to-code similarity:** Detecting duplicates, finding related implementations, and recommending refactoring targets
- **Developer tools and IDE integrations:** Fast, accurate code search served as a backend service

## Consider alternatives

- **Your retrieval corpus is primarily natural language:** voyage-3.5 or voyage-3-large are better general-purpose choices when there's little or no code
- **Your workload is exclusively in one domain like legal or finance:** Domain-specific models may provide marginal accuracy gains
- **You need multimodal embeddings:** Pick a model with native image inputs for screenshots and diagrams
- **Maximum cost efficiency is required:** voyage-3.5-lite handles code as one of its eight evaluated domains when accuracy requirements are moderate

## Frequently asked questions

### How many programming languages does Voyage Code 3 support?

Over 300 programming languages. That is the widest language coverage in Voyage AI by MongoDB's code embedding lineup, suitable for polyglot repositories and enterprise codebases.

### How does Voyage Code 3 compare to voyage-code-2?

Voyage Code 3 doubles the context window (32K vs. 16K), adds Matryoshka dimensionality (2048/1024/512/256), expands language coverage from a few languages to 300+, and adds quantization-aware training. It is the recommended choice for new code search deployments.

### What is the storage savings with binary embeddings?

Binary embeddings at 256 dimensions use 1/384th the storage of 3072-dimensional float embeddings while still outperforming OpenAI text-embedding-3-large by 4.81%. This makes it feasible to index very large codebases efficiently.

### How does dimension reduction quality compare to OpenAI?

At 1024 dimensions, Voyage Code 3 retains 92.28% of its full-precision quality, compared to 77.64% for OpenAI text-embedding-3-large. This means dimension reduction is significantly more effective with Voyage Code 3.

### What training data does Voyage Code 3 use?

Voyage AI by MongoDB trained Voyage Code 3 on trillions of tokens combining text, code, and mathematical content, supplemented with real-world query-code pairs from GitHub repositories for practical retrieval relevance.

### How do I access Voyage Code 3 through Vercel AI Gateway?

Add your Voyage AI by MongoDB API key in AI Gateway settings, then send embedding requests through AI Gateway. You can point the same client code at different provider models; AI Gateway authenticates requests and records usage.

### Can Voyage Code 3 handle text-to-code and code-to-code retrieval?

Yes. Voyage Code 3 is evaluated on both text-to-code retrieval (natural language queries finding relevant code) and code-to-code retrieval (finding similar implementations). Both are core strengths of the model.

## Links

- [Model page](https://vercel.com/ai-gateway/models/voyage-code-3)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://docs.voyageai.com/docs/embeddings)
- [Provider pricing](https://docs.voyageai.com/docs/pricing)
