voyage-code-4
About this model
Text embedding models are neural networks that transform texts into numerical vectors. They are a foundational building block for semantic search/retrieval systems and retrieval-augmented generation (RAG) and directly determine retrieval quality.
voyage-code-4 is the next generation of Voyage AI's code embedding model, purpose-built to improve performance and reduce cost for coding agents. Coding agents now issue many of the code retrieval queries served in production: they explore, backtrack, and re-query across multiple steps, often starting from a goal as vague as a bug report rather than a known identifier. Most agents rely entirely on full-text search (grep), which works well when the agent already knows the symbol it is looking for, but returns no useful hits when the query describes a symptom rather than syntax. Semantic retrieval with voyage-code-4 complements full-text search and significantly reduces wasted token usage. It is trained on an entirely new corpus mined from completed, issue-fixing pull requests spanning tens of thousands of repositories and hundreds of programming languages, and supports embeddings in 2048, 1024, 512, and 256 dimensions with multiple quantization options. Learn more about voyage-code-4 here: https://blog.voyageai.com/2026/08/13/voyage-code-4/
Key model capabilities
- Code embedding model purpose-built for coding agents, trained on a new corpus mined from issue-fixing pull requests across tens of thousands of repositories and hundreds of programming languages, so it can locate the code that needs to change given only a symptom.
- Outperforms Cohere Embed v4 and Gemini Embedding 2 by an average of 28.25% and 31.03% on agentic code retrieval, and by 19.21% and 16.01% across the 28 code retrieval datasets used to evaluate voyage-code-3.
- Supports embeddings of 2048, 1024, 512, and 256 dimensions and offers multiple embedding quantization, including float (32-bit floating point), int8 (8-bit signed integer), uint8 (8-bit unsigned integer), binary (bit-packed int8), and ubinary (bit-packed uint8).
- 32K token context length.
Usage
The deployed Azure AI Foundry endpoint exposes the Voyage inference API. Authenticate with your Azure ML endpoint key or a bearer token issued for the workspace.
Generate Embeddings
curl <AZUREML_ENDPOINT_URL>/v1/embeddings \
-X POST \
-H "Authorization: Bearer <AZUREML_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"input":["def add(a, b):\n return a + b"],"model":"voyage-code-4"}'
Supported Parameters
- input (string or array of strings, required): Text(s) or code snippet(s) to embed.
- model (string, required):
voyage-code-4. - input_type (string, optional):
queryordocument. Tunes embeddings for retrieval. - output_dimension (int, optional): One of
2048,1024,512,256. Defaults to1024. - output_dtype (string, optional):
float,int8,uint8,binary, orubinary. Defaults tofloat. - truncation (bool, optional): Truncate inputs longer than the 32K-token context. Defaults to
true. - encoding_format (string, optional): Set to
base64to receive embeddings as base64-encoded strings instead of float arrays.
See the full API reference at https://docs.voyageai.com/reference/embeddings-api .
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.00068755, 0.03410244, -0.02404458, 0.04494607]
}
],
"model": "voyage-code-4",
"usage": { "total_tokens": 4 }
}
The embedding array contains the full vector at the requested output_dimension (shown truncated above). When encoding_format is base64, each embedding is returned as a base64 string instead of a float array.