This will automatically use the environment variable VOYAGE_API_KEY. changedbuild-with-claude/embeddings
Nearest release: v2.1.290, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+91added
Lines−75removed
From line
14
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits5to this page, all time
### Voyage AI Python library ### Voyage AI HTTP API ### Voyage Python library ### Voyage HTTP API
The whole hunk
from line 14, old and new numbered
/
from line 14
1414
1515## How to get embeddings with Anthropic
1616
17Anthropic does not offer its own embedding model. One embeddings provider that has a wide variety of options and capabilities encompassing all of the preceding considerations is Voyage AI.
17Anthropic does not offer its own embedding model. One embeddings provider with a wide variety of models and capabilities is Voyage AI by MongoDB.
1818
19Voyage AI makes state-of-the-art embedding models and offers customized models for specific industry domains such as finance and healthcare, or bespoke fine-tuned models for individual customers.
19Voyage AI makes embedding models and rerankers. Its embedding models include general-purpose, multimodal, contextualized, and domain-specific models.
2020
2121The rest of this guide is for Voyage AI, but you should assess a variety of embeddings vendors to find the best fit for your specific use case.
2222
2323## Available models
2424
25Voyage recommends using the following text embedding models:
25Voyage AI offers the following text embedding models:
2626
27**Voyage 4 (latest generation)**
27**Latest generation**
2828
29| Model | Context length | Embedding dimension | Description |
30| ---------------- | -------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31| `voyage-4-large` | 32,000 | 1024 (default), 256, 512, 2048 | The best general-purpose and multilingual retrieval quality. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
32| `voyage-4` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for general-purpose and multilingual retrieval quality. Balances quality and efficiency. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
33| `voyage-4-lite` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for latency and cost. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
34| `voyage-4-nano` | 32,000 | 1024 (default), 256, 512, 2048 | Open-weight model (Apache 2.0 license) available on Hugging Face. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
29| Model | Context length | Embedding dimension | Description |
30| ---------------- | -------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31| `voyage-4-large` | 32,000 | 1024 (default), 256, 512, 2048 | The best general-purpose and multilingual retrieval quality. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
32| `voyage-4` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for general-purpose and multilingual retrieval quality. Balances quality and efficiency. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
33| `voyage-4-lite` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for latency and cost. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
34| `voyage-code-4` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for **code** retrieval and agentic coding applications. See the [voyage-code-4 blog post](https://blog.voyageai.com/2026/08/13/voyage-code-4/) for details. |
35| `voyage-4-nano` | 32,000 | 2048 (default), 256, 512, 1024 | Open-weight model (Apache 2.0 license) that you download from [Hugging Face](https://huggingface.co/voyageai/voyage-4-nano) and run yourself. Not available through the Atlas Embedding and Reranking API. See the [Voyage 4 blog post](https://blog.voyageai.com/2026/01/15/voyage-4/) for details. |
3536
3637**Previous generation**
3738
38| Model | Context length | Embedding dimension | Description |
39| ------------------ | -------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
40| `voyage-3-large` | 32,000 | 1024 (default), 256, 512, 2048 | The best general-purpose and multilingual retrieval quality. See the [voyage-3-large blog post](https://blog.voyageai.com/2025/01/07/voyage-3-large/) for details. |
41| `voyage-3.5` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for general-purpose and multilingual retrieval quality. See the [voyage-3.5 blog post](https://blog.voyageai.com/2025/05/20/voyage-3-5/) for details. |
42| `voyage-3.5-lite` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for latency and cost. See the [voyage-3.5 blog post](https://blog.voyageai.com/2025/05/20/voyage-3-5/) for details. |
43| `voyage-code-3` | 32,000 | 1024 (default), 256, 512, 2048 | Optimized for **code** retrieval. See the [voyage-code-3 blog post](https://blog.voyageai.com/2024/12/04/voyage-code-3/) for details. |
44| `voyage-finance-2` | 32,000 | 1024 | Optimized for **finance** retrieval and RAG. See the [voyage-finance-2 blog post](https://blog.voyageai.com/2024/06/03/domain-specific-embeddings-finance-edition-voyage-finance-2/) for details. |
45| `voyage-law-2` | 16,000 | 1024 | Optimized for **legal** and **long-context** retrieval and RAG. Also improved performance across all domains. See the [voyage-law-2 blog post](https://blog.voyageai.com/2024/04/15/domain-specific-embeddings-and-retrieval-legal-edition-voyage-law-2/) for details. |
39For each model's lifecycle status and recommended replacement, see [Model deprecations, lifecycle states, and support](https://www.mongodb.com/docs/voyageai/models/lifecycle/) in the MongoDB documentation.
4640
47Additionally, Voyage recommends the following multimodal embedding models:
41| Model | Context length | Embedding dimension | Description |
42| ------------------ | -------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43| `voyage-3-large` | 32,000 | 1024 (default), 256, 512, 2048 | Previous generation of `voyage-4-large`. See the [voyage-3-large blog post](https://blog.voyageai.com/2025/01/07/voyage-3-large/) for details. |
44| `voyage-3.5` | 32,000 | 1024 (default), 256, 512, 2048 | Previous generation of `voyage-4`. See the [voyage-3.5 blog post](https://blog.voyageai.com/2025/05/20/voyage-3-5/) for details. |
45| `voyage-3.5-lite` | 32,000 | 1024 (default), 256, 512, 2048 | Previous generation of `voyage-4-lite`. See the [voyage-3.5 blog post](https://blog.voyageai.com/2025/05/20/voyage-3-5/) for details. |
46| `voyage-code-3` | 32,000 | 1024 (default), 256, 512, 2048 | Previous generation of `voyage-code-4`. See the [voyage-code-3 blog post](https://blog.voyageai.com/2024/12/04/voyage-code-3/) for details. |
47| `voyage-finance-2` | 32,000 | 1024 | Optimized for **finance** retrieval and RAG. See the [voyage-finance-2 blog post](https://blog.voyageai.com/2024/06/03/domain-specific-embeddings-finance-edition-voyage-finance-2/) for details. |
48| `voyage-law-2` | 16,000 | 1024 | Optimized for **legal** retrieval and RAG. See the [voyage-law-2 blog post](https://blog.voyageai.com/2024/04/15/domain-specific-embeddings-and-retrieval-legal-edition-voyage-law-2/) for details. |
4849
50Additionally, Voyage AI offers the following multimodal embedding models. Call these models with `multimodal_embed()` instead of `embed()`:
51
4952| Model | Context length | Embedding dimension | Description |
5053| ----------------------- | -------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5154| `voyage-multimodal-3.5` | 32,000 | 1024 (default), 256, 512, 2048 | Rich multimodal embedding model that can vectorize interleaved text, images, and videos. Includes video support as the first production-grade video embedding model. See the [voyage-multimodal-3.5 blog post](https://blog.voyageai.com/2026/01/15/voyage-multimodal-3-5/) for details. |
52| `voyage-multimodal-3` | 32,000 | 1024 | Rich multimodal embedding model that can vectorize interleaved text and content-rich images, such as screenshots of PDFs, slides, tables, figures, and more. See the [voyage-multimodal-3 blog post](https://blog.voyageai.com/2024/11/12/voyage-multimodal-3/) for details. |
55| `voyage-multimodal-3` | 32,000 | 1024 | Previous generation of `voyage-multimodal-3.5`. Vectorizes interleaved text and content-rich images, such as screenshots of PDFs, slides, tables, figures, and more. See the [voyage-multimodal-3 blog post](https://blog.voyageai.com/2024/11/12/voyage-multimodal-3/) for details. |
5356
5457The following contextualized chunk embedding models produce chunk-level vectors that capture full document context without manual metadata augmentation. Call these models with `contextualized_embed()` instead of `embed()`:
5558
from line 59
5659| Model | Context length | Embedding dimension | Description |
5760| ------------------ | -------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5861| `voyage-context-4` | 120,000 | 1024 (default), 256, 512, 2048 | Contextualized chunk embeddings optimized for general-purpose and multilingual retrieval quality. See the [voyage-context-4 blog post](https://blog.voyageai.com/2026/06/29/voyage-context-4/) for details. |
59| `voyage-context-3` | 120,000 | 1024 (default), 256, 512, 2048 | Contextualized chunk embeddings optimized for general-purpose and multilingual retrieval quality. See the [voyage-context-3 blog post](https://blog.voyageai.com/2025/07/23/voyage-context-3/) for details. |
62| `voyage-context-3` | 120,000 | 1024 (default), 256, 512, 2048 | Previous generation of `voyage-context-4`. See the [voyage-context-3 blog post](https://blog.voyageai.com/2025/07/23/voyage-context-3/) for details. |
6063
64The 120,000-token limit applies when you set `enable_auto_chunking` to `true`. Otherwise, the total number of tokens across all inputs can't exceed 32,000.
65
6166Voyage AI also offers rerankers, which take a query and a list of documents and return them ranked by relevance to the query. Call these models with `rerank()`:
6267
63| Model | Context length | Description |
64| ----------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
65| `rerank-2.5` | 32,000 | Highest accuracy. Recommended for most applications. See the [rerank-2.5 blog post](https://blog.voyageai.com/2025/08/11/rerank-2-5/) for details. |
66| `rerank-2.5-lite` | 32,000 | Optimized for latency and cost. See the [rerank-2.5 blog post](https://blog.voyageai.com/2025/08/11/rerank-2-5/) for details. |
68| Model | Context length | Description |
69| ----------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
70| `rerank-3` | 32,000 | Highest accuracy. Recommended for most applications. See the [rerank-3 blog post](https://blog.voyageai.com/2026/09/30/rerank-3/) for details. |
71| `rerank-3-lite` | 32,000 | Optimized for latency and cost. See the [rerank-3 blog post](https://blog.voyageai.com/2026/09/30/rerank-3/) for details. |
72| `rerank-2.5` | 32,000 | Previous generation of `rerank-3`. See the [rerank-2.5 blog post](https://blog.voyageai.com/2025/08/11/rerank-2-5/) for details. |
73| `rerank-2.5-lite` | 32,000 | Previous generation of `rerank-3-lite`. See the [rerank-2.5 blog post](https://blog.voyageai.com/2025/08/11/rerank-2-5/) for details. |
6774
68Need help deciding which text embedding model to use? Check out the [Voyage AI FAQ](https://docs.voyageai.com/docs/faq#what-embedding-models-are-available-and-which-one-should-i-use\&ref=anthropic).
75Need help deciding which model to use? See [Voyage AI embedding and reranking models overview](https://www.mongodb.com/docs/voyageai/models/) in the MongoDB documentation.
6976
7077## Getting started with Voyage AI
7178
72To access Voyage embeddings:
79To access Voyage AI models, create a model API key in MongoDB Atlas:
7380
741. Sign up on Voyage AI's website.
752. Obtain an API key.
811. Sign up for a MongoDB Atlas account, or log in.
822. In your Atlas project, select **AI Model APIs** in the navigation bar, click **Create model API key**, name the key, and click **Create**.
76833. Set the API key as an environment variable for convenience:
7784
7885```bash
79export VOYAGE_API_KEY="<your secret key>"
86export VOYAGE_API_KEY="<your model API key>"
8087```
8188
82You can obtain the embeddings by either using the official [`voyageai` Python package](https://github.com/voyage-ai/voyageai-python) or HTTP requests, as described in the following sections.
89For more detail, see [Voyage AI quick start](https://www.mongodb.com/docs/voyageai/quickstart/) in the MongoDB documentation.
8390
84### Voyage Python library
91You can obtain the embeddings by either using the official [`voyageai` Python package](https://github.com/voyage-ai/voyageai-python) or HTTP requests, as described in the following sections. Voyage AI also has an official TypeScript client. To use it with a model API key from Atlas, set its `environment` option to `https://ai.mongodb.com/v1`, as described in [TypeScript client](https://www.mongodb.com/docs/voyageai/api-and-clients/#typescript-client) in the MongoDB documentation.
8592
86Install the `voyageai` package using the following command:
93### Voyage AI Python library
8794
95Install the `voyageai` package using the following command. To use a model API key from Atlas, you need version 0.3.7 or later.
96
8897```bash
8998pip install -U voyageai
9099```
from line 105
96105
97106vo = voyageai.Client()
98107# This will automatically use the environment variable VOYAGE_API_KEY.
99# Alternatively, you can use vo = voyageai.Client(api_key="<your secret key>")
108# Alternatively, you can use vo = voyageai.Client(api_key="<your model API key>")
100109
101110texts = ["Sample text 1", "Sample text 2"]
102111
from line 123
114123
115124When creating the embeddings, you can specify a few other arguments to the `embed()` function.
116125
117For more information on the Voyage Python package, see the [Voyage Python package documentation](https://docs.voyageai.com/docs/embeddings#python-api).
126For more information on the Python package, see [Accessing Voyage AI models](https://www.mongodb.com/docs/voyageai/api-and-clients/) in the MongoDB documentation.
118127
119### Voyage HTTP API
128### Voyage AI HTTP API
120129
121You can also get embeddings by requesting Voyage HTTP API. For example, you can send an HTTP request through the `curl` command in a terminal:
130You can also get embeddings by sending HTTP requests to the Atlas Embedding and Reranking API. For example, you can send an HTTP request through the `curl` command in a terminal:
122131
123132```bash cURL
124curl https://api.voyageai.com/v1/embeddings \
133curl https://ai.mongodb.com/v1/embeddings \
125134 -H "Content-Type: application/json" \
126135 -H "Authorization: Bearer $VOYAGE_API_KEY" \
127136 -d '{
128137 "input": ["Sample text 1", "Sample text 2"],
129 "model": "voyage-4"
138 "model": "voyage-4",
139 "input_type": "document"
130140 }'
131141```
132142
from line 147
137147 "object": "list",
138148 "data": [
139149 {
150 "object": "embedding",
140151 "embedding": [-0.013131560757756233, 0.019828535616397858 /* ... */],
141152 "index": 0
142153 },
143154 {
155 "object": "embedding",
144156 "embedding": [-0.0069352793507277966, 0.020878976210951805 /* ... */],
145157 "index": 1
146158 }
from line 164
152164}
153165```
154166
155For more information on the Voyage HTTP API, see the [Voyage HTTP API documentation](https://docs.voyageai.com/reference/embeddings-api).
167Model API keys from Atlas work with `ai.mongodb.com`, except keys scoped to a geography, which use that geography's endpoint. If you have an API key from the Voyage AI platform instead, see [Migrate your applications to use the Atlas Embedding and Reranking API](https://www.mongodb.com/docs/voyageai/tutorials/migrate-to-atlas/) in the MongoDB documentation.
156168
169For the full request and response reference, see [Create text embeddings](https://www.mongodb.com/docs/api/doc/atlas-embedding-and-reranking-api/operation/operation-createembedding) in the Atlas Embedding and Reranking API documentation.
170
157171### AWS Marketplace
158172
159Voyage embeddings are available on [AWS Marketplace](https://aws.amazon.com/marketplace/seller-profile?id=c9032c7b-70dd-459f-834f-c1e23cf3d092). Instructions for accessing Voyage on AWS are available in the [Voyage AWS Marketplace documentation](https://docs.voyageai.com/docs/aws-marketplace-mongodb-voyage?ref=anthropic).
173Voyage AI models are also available on AWS Marketplace through [MongoDB's seller profile](https://aws.amazon.com/marketplace/seller-profile?id=c9032c7b-70dd-459f-834f-c1e23cf3d092). For instructions, see [Deploy Voyage AI models using AWS Marketplace](https://www.mongodb.com/docs/voyageai/management/aws-marketplace/) in the MongoDB documentation.
160174
161175## Quickstart example
162176
from line 189
175189]
176190```
177191
178First, use Voyage to convert each document into an embedding vector.
192First, use Voyage AI to convert each document into an embedding vector.
179193
180194```python
181195import voyageai
from line 215
201215query_embd = vo.embed([query], model="voyage-4", input_type="query").embeddings[0]
202216
203217# Compute the similarity
204# Voyage embeddings are normalized to length 1, therefore dot-product
218# Voyage AI embeddings are normalized to length 1, so dot-product
205219# and cosine similarity are the same.
206220similarities = np.dot(doc_embds, query_embd)
207221
from line 223
209223print(documents[retrieved_id])
210224```
211225
212Note that `input_type="document"` and `input_type="query"` are used for embedding the document and query, respectively. More specification can be found in [Voyage Python library](https://platform.claude.com/docs/en/build-with-claude/embeddings#voyage-python-library).
226Note that `input_type="document"` and `input_type="query"` are used for embedding the document and query, respectively. For more about `input_type`, see [When and how should I use the input\_type parameter?](https://platform.claude.com/docs/en/build-with-claude/embeddings#faq) in the FAQ.
213227
214228The output is the fifth document, which is indeed the most relevant to the query:
215229
from line 236
222236## FAQ
223237
224238<AccordionGroup>
225 <Accordion title="Why do Voyage embeddings have superior quality?">
226 Embedding models rely on powerful neural networks to capture and compress semantic context, similar to generative models. Voyage's team of experienced AI researchers optimizes every component of the embedding process, including:
239 <Accordion title="Why do Voyage AI embeddings have superior quality?">
240 Embedding models rely on powerful neural networks to capture and compress semantic context, similar to generative models. Voyage AI's team of experienced AI researchers optimizes every component of the embedding process, including:
227241
228242 * Model architecture
229243 * Data collection
from line 244
230244 * Loss functions
231245 * Optimizer selection
232246
233 Learn more about Voyage's technical approach on the [Voyage AI blog](https://blog.voyageai.com/).
247 Learn more about Voyage AI's technical approach on the [Voyage AI blog](https://blog.voyageai.com/).
234248 </Accordion>
235249
236250 <Accordion title="What embedding models are available and which should I use?">
from line 259
245259 Domain-specific models:
246260
247261 * Legal tasks: `voyage-law-2`
248 * Code and programming documentation: `voyage-code-3`
262 * Code retrieval and agentic coding: `voyage-code-4`
249263 * Finance-related tasks: `voyage-finance-2`
250264
251265 For chunk-level and document-level retrieval: `voyage-context-4`
266
267 For text, images, and video: `voyage-multimodal-3.5`
252268 </Accordion>
253269
254270 <Accordion title="Which similarity function should I use?">
255 You can use Voyage embeddings with either dot-product similarity, cosine similarity, or Euclidean distance. For an explanation of embedding similarity, see this [vector similarity guide](https://www.pinecone.io/learn/vector-similarity/).
271 You can use Voyage AI embeddings with dot-product similarity, cosine similarity, or Euclidean distance. For an explanation of embedding similarity, see this [vector similarity guide](https://www.pinecone.io/learn/vector-similarity/).
256272
257273 Voyage AI embeddings are normalized to length 1, which means that:
258274
from line 277
261277 </Accordion>
262278
263279 <Accordion title="What is the relationship between characters, words, and tokens?">
264 See the [Voyage tokenization guide](https://docs.voyageai.com/docs/tokenization?ref=anthropic).
280 See [Tokenization](https://www.mongodb.com/docs/voyageai/tutorials/tokenization/) in the MongoDB documentation.
265281 </Accordion>
266282
267283 <Accordion title="When and how should I use the input_type parameter?">
from line 287
271287
272288 > 📘 **Prompts associated with `input_type`**
273289 >
274 > * For a query, the prompt is “Represent the query for retrieving supporting documents: “.
290 > * For a query, the prompt is `"Represent the query for retrieving supporting documents: "`.
275291 >
276 > * For a document, the prompt is “Represent the document for retrieval: “.
292 > * For a document, the prompt is `"Represent the document for retrieval: "`.
277293 >
278294 > * Example
279295 >
280 > * When `input_type="query"`, a query like "When is Apple's conference call scheduled?" will become "**Represent the query for retrieving supporting documents:** When is Apple's conference call scheduled?"
281 > * When `input_type="document"`, a query like "Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET." will become "**Represent the document for retrieval:** Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET."
282
283 `voyage-large-2-instruct`, as the name suggests, is trained to be responsive to additional instructions that are prepended to the input text. For classification, clustering, or other [MTEB](https://huggingface.co/mteb) subtasks, use the [voyage-large-2-instruct instructions](https://github.com/voyage-ai/voyage-large-2-instruct).
296 > * When `input_type="query"`, a query such as "When is Apple's conference call scheduled?" will become "**Represent the query for retrieving supporting documents:** When is Apple's conference call scheduled?"
297 > * When `input_type="document"`, a document such as "Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET." will become "**Represent the document for retrieval:** Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET."
284298 </Accordion>
285299
286300 <Accordion title="What quantization options are available?">
287 Quantization in embeddings converts high-precision values, such as 32-bit single-precision floating-point numbers, to lower-precision formats such as 8-bit integers or 1-bit binary values, reducing storage, memory, and costs by 4x and 32x, respectively. Supported Voyage models enable quantization by specifying the output data type with the `output_dtype` parameter:
301 Quantization in embeddings converts high-precision values, such as 32-bit single-precision floating-point numbers, to lower-precision formats such as 8-bit integers or 1-bit binary values, reducing storage, memory, and costs by 4x and 32x, respectively. Supported Voyage AI models enable quantization by specifying the output data type with the `output_dtype` parameter:
288302
289303 * `float`: Each returned embedding is a list of 32-bit (4-byte) single-precision floating-point numbers. This is the default and provides the highest precision / retrieval accuracy.
290304 * `int8` and `uint8`: Each returned embedding is a list of 8-bit (1-byte) integers ranging from -128 to 127 and 0 to 255, respectively.
291 * `binary` and `ubinary`: Each returned embedding is a list of 8-bit integers that represent bit-packed, quantized single-bit embedding values: `int8` for `binary` and `uint8` for `ubinary`. The length of the returned list of integers is 1/8 of the actual dimension of the embedding. The binary type uses the offset binary method, which you can learn more about in the [embeddings FAQ](https://platform.claude.com/docs/en/build-with-claude/embeddings#faq).
305 * `binary` and `ubinary`: Each returned embedding is a list of 8-bit integers that represent bit-packed, quantized single-bit embedding values: `int8` for `binary` and `uint8` for `ubinary`. The length of the returned list of integers is 1/8 of the actual dimension of the embedding. The binary type uses the offset binary method, as the following example shows.
292306
293307 > **Binary quantization example**
294308 >
from line 310
296310 >
297311 > * `ubinary`: The binary sequence is directly converted and represented as the unsigned integer (`uint8`) 77.
298312 > * `binary`: The binary sequence is represented as the signed integer (`int8`) -51, calculated using the offset binary method (77 - 128 = -51).
313
314 For the models that support each data type, see [Create text embeddings](https://www.mongodb.com/docs/api/doc/atlas-embedding-and-reranking-api/operation/operation-createembedding) in the Atlas Embedding and Reranking API documentation.
299315 </Accordion>
300316
301317 <Accordion title="How can I truncate Matryoshka embeddings?">
302 Matryoshka learning creates embeddings with coarse-to-fine representations within a single vector. Voyage models, such as `voyage-code-3`, that support multiple output dimensions generate such Matryoshka embeddings. You can truncate these vectors by keeping the leading subset of dimensions. For example, the following Python code demonstrates how to truncate 1024-dimensional vectors to 256 dimensions:
318 Matryoshka learning creates embeddings with coarse-to-fine representations within a single vector. Voyage AI models that support multiple output dimensions, such as `voyage-code-4`, generate such Matryoshka embeddings. To get shorter vectors from the API, pass `output_dimension` (for example, `output_dimension=256`). To shorten vectors you already stored, truncate them by keeping the leading subset of dimensions, then normalize them again. For example, the following Python code demonstrates how to truncate 1024-dimensional vectors to 256 dimensions:
303319
304320 ```python
305321 import voyageai
from line 335
319335
320336 vo = voyageai.Client()
321337
322 # Generate voyage-code-3 vectors, which by default are 1024-dimensional floating-point numbers
323 embd = vo.embed(["Sample text 1", "Sample text 2"], model="voyage-code-3").embeddings
338 # Generate voyage-code-4 vectors, which by default are 1024-dimensional floating-point numbers
339 embd = vo.embed(["Sample text 1", "Sample text 2"], model="voyage-code-4").embeddings
324340
325341 # Set shorter dimension
326342 short_dim = 256
from line 349
333349
334350## Pricing
335351
336Visit Voyage's [pricing page](https://docs.voyageai.com/docs/pricing?ref=anthropic) for the most up to date pricing details.
352For the most up-to-date pricing details, see [Model pricing](https://www.mongodb.com/docs/voyageai/management/billing/#model-pricing) in the MongoDB documentation.
337353
No line in this hunk matches that.