Creates vector embeddings for the provided text input(s). This endpoint accepts a single text string or a list of text strings and returns their corresponding vector embeddings.
For semantic search and retrieval tasks, set the input_type parameter to query or document to optimize how the model creates the vectors.
Body
Required
input
string | array[string] Required A single text string or a list of text strings to be embedded, such as
["I like cats", "I also like dogs"].Constraints:
- Maximum list length: 1,000 items
- Maximum total tokens: 1M for
voyage-3.5-liteandvoyage-4-lite; 320K forvoyage-3.5,voyage-4, andvoyage-2; 120K forvoyage-3-large,voyage-4-large,voyage-code-3,voyage-finance-2, andvoyage-law-2
-
The embedding model to use. Recommended models:
voyage-4-large,voyage-4,voyage-4-lite,voyage-code-3,voyage-finance-2,voyage-law-2.Values are
voyage-context-3,voyage-4,voyage-4-lite,voyage-4-large,voyage-3.5,voyage-3.5-lite,voyage-3-large,voyage-code-3,voyage-multimodal-3,voyage-finance-2,voyage-law-2, orvoyage-code-2. -
The type of input text. Use this parameter to optimize embeddings for semantic search and retrieval tasks.
Options:
null(default): The model directly converts the input into numerical vectors without any additional prompts.query: Use when the input represents a search query. The model prepends "Represent the query for retrieving supporting documents: " to optimize the embedding for retrieval.document: Use when the input represents a document to be searched. The model prepends "Represent the document for retrieval: " to optimize the embedding for retrieval.
For semantic search and retrieval tasks, always set this parameter to
queryordocumentas appropriate. Embeddings generated with and without theinput_typeargument are compatible.Values are
query,document, or null. -
Whether to truncate input texts that exceed the context length.
true(default): Input texts that exceed the context length are automatically truncated before vectorization.false: An error is returned if any input text exceeds the context length.
Default value is
true. -
The number of dimensions for the output embeddings.
Most models support only a single default dimension. The models
voyage-4-large,voyage-4,voyage-4-lite,voyage-3-large,voyage-3.5,voyage-3.5-lite, andvoyage-code-3support the following values: 256, 512, 1024 (default), and 2048.Set to
nullto use the model's default dimension.Values are
256,512,1024,2048, or null. -
The data type for the returned embeddings.
Options:
float(default): 32-bit single-precision floating-point numbers. Provides the highest precision and retrieval accuracy. Supported by all models.int8: 8-bit signed integers ranging from -128 to 127. Supported byvoyage-4-large,voyage-4,voyage-4-lite,voyage-3-large,voyage-3.5,voyage-3.5-lite, andvoyage-code-3.uint8: 8-bit unsigned integers ranging from 0 to 255. Supported byvoyage-4-large,voyage-4,voyage-4-lite,voyage-3-large,voyage-3.5,voyage-3.5-lite, andvoyage-code-3.binary: Bit-packed, quantized single-bit embedding values represented asint8. The returned list length is 1/8 ofoutput_dimension. Uses the offset binary method. Supported byvoyage-4-large,voyage-4,voyage-4-lite,voyage-3-large,voyage-3.5,voyage-3.5-lite, andvoyage-code-3.ubinary: Bit-packed, quantized single-bit embedding values represented asuint8. The returned list length is 1/8 ofoutput_dimension. Supported byvoyage-4-large,voyage-4,voyage-4-lite,voyage-3-large,voyage-3.5,voyage-3.5-lite, andvoyage-code-3.
Values are
float,int8,uint8,binary, orubinary. Default value isfloat. -
The format in which embeddings are encoded in the response.
Options:
null(default): Embeddings are returned as arrays. Whenoutput_dtypeisfloat, each embedding is an array of floating-point numbers. For otheroutput_dtypevalues (int8,uint8,binary,ubinary), each embedding is an array of integers.base64: Embeddings are returned as Base64-encoded NumPy arrays with the following data types:numpy.float32whenoutput_dtypeisfloatnumpy.int8whenoutput_dtypeisint8orbinarynumpy.uint8whenoutput_dtypeisuint8orubinary
Values are
base64or null.
curl \
--request POST 'https://ai.mongodb.com/v1/embeddings' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"input":"string","model":"voyage-context-3","input_type":"query","truncation":true,"output_dimension":256,"output_dtype":"float","encoding_format":"base64"}'
{
"input": "string",
"model": "voyage-context-3",
"input_type": "query",
"truncation": true,
"output_dimension": 256,
"output_dtype": "float",
"encoding_format": "base64"
}
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
42.0
],
"index": 42
}
],
"model": "string",
"usage": {
"total_tokens": 42
}
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}
{
"detail": "string"
}