# Create text embeddings **POST /embeddings** 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. ## Servers - https://ai.mongodb.com/v1: https://ai.mongodb.com/v1 () ## Authentication methods - Api key auth ## Parameters ### Body: application/json (object) - **input** (string | array[string]) 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-lite`; 320K for `voyage-3.5` and `voyage-2`; 120K for `voyage-3-large`, `voyage-code-3`, `voyage-finance-2`, and `voyage-law-2` - **model** (string) The embedding model to use. Recommended models: `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, `voyage-code-3`, `voyage-finance-2`, `voyage-law-2`. - **input_type** (string | null) 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 `query` or `document` as appropriate. Embeddings generated with and without the `input_type` argument are compatible. - **truncation** (boolean) 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. - **output_dimension** (integer | null) The number of dimensions for the output embeddings. Most models support only a single default dimension. The models `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, and `voyage-code-3` support the following values: 256, 512, 1024 (default), and 2048. Set to `null` to use the model's default dimension. - **output_dtype** (string) 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 by `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, and `voyage-code-3`. - `uint8`: 8-bit unsigned integers ranging from 0 to 255. Supported by `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, and `voyage-code-3`. - `binary`: Bit-packed, quantized single-bit embedding values represented as `int8`. The returned list length is 1/8 of `output_dimension`. Uses the offset binary method. Supported by `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, and `voyage-code-3`. - `ubinary`: Bit-packed, quantized single-bit embedding values represented as `uint8`. The returned list length is 1/8 of `output_dimension`. Supported by `voyage-3-large`, `voyage-3.5`, `voyage-3.5-lite`, and `voyage-code-3`. - **encoding_format** (string | null) The format in which embeddings are encoded in the response. Options: - `null` (default): Embeddings are returned as arrays. When `output_dtype` is `float`, each embedding is an array of floating-point numbers. For other `output_dtype` values (`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.float32` when `output_dtype` is `float` - `numpy.int8` when `output_dtype` is `int8` or `binary` - `numpy.uint8` when `output_dtype` is `uint8` or `ubinary` ## Responses ### 200 Success #### Body: application/json (object) - **object** (string) The object type. Always returns "list". - **data** (array[object]) An array of embedding objects, one for each input text. - **model** (string) The name of the model used to generate the embeddings. - **usage** (object) ### 400 Invalid Request #### Body: application/json (object) - **detail** (string) The request is invalid. This error can occur due to invalid JSON, invalid parameter types, incorrect data types, batch size too large, total tokens exceeding the limit, or tokens in an example exceeding context length. ### 401 Unauthorized #### Body: application/json (object) - **detail** (string) Invalid authentication. Ensure your model API key is correctly specified in the Authorization header as `Bearer YOUR_API_KEY`. ### 403 Forbidden #### Body: application/json (object) - **detail** (string) Access forbidden. This may occur if the IP address you are sending the request from is not allowed. ### 429 Rate Limit Exceeded #### Body: application/json (object) - **detail** (string) Rate limit exceeded. Your request frequency or token usage is too high. Reduce your request rate or wait before retrying. ### 500 Internal Server Error #### Body: application/json (object) - **detail** (string) An unexpected error occurred on the server. Retry your request after a brief wait. ### 502 Bad Gateway #### Body: application/json (object) - **detail** (string) The server received an invalid response from an upstream server. Retry your request after a brief wait. ### 503 Service Unavailable #### Body: application/json (object) - **detail** (string) The service is temporarily unavailable due to high traffic or maintenance. Retry your request after a brief wait. ### 504 Gateway Timeout #### Body: application/json (object) - **detail** (string) The server did not receive a timely response from an upstream server. Retry your request after a brief wait. [Powered by Bump.sh](https://bump.sh)