Text embeddings convert text into dense vector representations that capture semantic meaning. You can use Voyage AI’s specialized text embedding models to power semantic search, recommendations, clustering, and other AI applications.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/patelvivekdev/voyageai-ai-provider/llms.txt
Use this file to discover all available pages before exploring further.
Available models
Voyage AI offers multiple text embedding models optimized for different use cases:voyage-3.5- Latest flagship model with enhanced performancevoyage-3.5-lite- Efficient version with faster inferencevoyage-3-large- Large model with 2048 default dimensionsvoyage-3- General purpose modelvoyage-3-lite- Lightweight variant for speedvoyage-code-3- Specialized for code and technical contentvoyage-finance-2- Optimized for financial documentsvoyage-multilingual-2- Supports multiple languagesvoyage-law-2- Specialized for legal content
Basic usage
Generate embeddings for a single text input using theembed function:
Batch processing
Generate embeddings for multiple texts efficiently usingembedMany:
Input types
Voyage AI uses different prompts for queries and documents to optimize retrieval performance.import { createVoyage } from 'voyage-ai-provider';
import { embed } from 'ai';
import type { VoyageEmbeddingOptions } from 'voyage-ai-provider';
const voyage = createVoyage({
apiKey: process.env.VOYAGE_API_KEY,
});
const { embedding } = await embed({
model: voyage.textEmbeddingModel('voyage-3-lite'),
value: 'How do I reset my password?',
providerOptions: {
voyage: {
inputType: 'query',
} satisfies VoyageEmbeddingOptions,
},
});
import { createVoyage } from 'voyage-ai-provider';
import { embedMany } from 'ai';
import type { VoyageEmbeddingOptions } from 'voyage-ai-provider';
const voyage = createVoyage({
apiKey: process.env.VOYAGE_API_KEY,
});
const { embeddings } = await embedMany({
model: voyage.textEmbeddingModel('voyage-3-lite'),
values: [
'To reset your password, click the forgot password link on the login page.',
'Our support team is available 24/7 to help with your questions.',
'Premium users get access to priority support and advanced features.',
],
providerOptions: {
voyage: {
inputType: 'document',
} satisfies VoyageEmbeddingOptions,
},
});
Grouped text embeddings
You can combine multiple related text segments into a single embedding. This is useful for representing complex documents with titles, descriptions, and metadata:Specialized models
Code embeddings
Usevoyage-code-3 for code snippets and technical documentation:
Multilingual embeddings
Usevoyage-multilingual-2 for content in multiple languages:
Domain-specific models
- Tab Title
- Tab Title
Use
voyage-finance-2 for financial documents:Configuration options
Customize embedding behavior with provider options:Available options
inputType
inputType
The input type for embeddings. Defaults to
"query".query- Prepends “Represent the query for retrieving supporting documents: ”document- Prepends “Represent the document for retrieval: ”
outputDimension
outputDimension
The number of dimensions for output embeddings. If not specified, uses the model’s default dimension.
voyage-code-3supports: 2048, 1024 (default), 512, and 256voyage-3-largesupports: 2048, 1024 (default), 512, and 256
outputDtype
outputDtype
The data type for output embeddings. Defaults to
"float".float- 32-bit single-precision floating-point numbers (supported by all models)int8- 8-bit integers from -128 to 127 (supported byvoyage-code-3)uint8- 8-bit integers from 0 to 255 (supported byvoyage-code-3)binary- Bit-packed quantized values usingint8(supported byvoyage-code-3)ubinary- Bit-packed quantized values usinguint8(supported byvoyage-code-3)
truncation
truncation
Whether to truncate input texts to fit within the context length. Defaults to
false.Set to true to automatically truncate long texts instead of raising an error.Working with usage data
The embedding response includes token usage information:Error handling
Handle errors gracefully when generating embeddings:Best practices
voyage-3.5 or voyage-3-litevoyage-code-3voyage-multilingual-2voyage-finance-2 or voyage-law-2Next steps
Image embeddings
Learn how to generate embeddings from images
Multimodal embeddings
Combine text and images in a single embedding
Reranking
Improve search results with reranking
Configuration
Customize provider settings