Voyage AI Provider
patelvivekdev/voyage-ai-provider is a community provider that uses Voyage AI to provide Embedding support for the AI SDK.
Setup
The Voyage provider is available in the voyage-ai-provider
module. You can install it with
pnpm add voyage-ai-provider
Provider Instance
You can import the default provider instance voyage
from voyage-ai-provider
:
import { voyage } from 'voyage-ai-provider';
If you need a customized setup, you can import createVoyage
from voyage-ai-provider
and create a provider instance with your settings:
import { createVoyage } from 'voyage-ai-provider';
const voyage = createVoyage({ baseURL: 'https://api.voyageai.com/v1', apiKey: process.env.VOYAGE_API_KEY,});
You can use the following optional settings to customize the Voyage provider instance:
-
baseURL string
The base URL of the voyage API
-
headers Record<string,string>
Custom headers to include in the requests.
Embedding Models
You can create models that call the Voyage embeddings API
using the .embedding()
factory method.
import { voyage } from 'voyage-ai-provider';
const embeddingModel = voyage.textEmbeddingModel('voyage-3');
You can find more models on the Voyage Library homepage.
Model Capabilities
Model | Default Dimensions | Context Length |
---|---|---|
voyage-3 | 1024 | 32000 |
voyage-3-lite | 512 | 32000 |
voyage-finance-2 | 1024 | 32000 |
voyage-multilingual-2 | 1024 | 32000 |
voyage-law-2 | 1024 | 32000 |
voyage-code-2 | 1024 | 16000 |
voyage-3-lite | 1024 | 16000 |
The table above lists popular models. Please see the Voyage docs for a full list of available models.
Add settings to the model
The settings object should contain the settings you want to add to the model.
import { voyage } from 'voyage-ai-provider';
const embeddingModel = voyage.textEmbeddingModel('voyage-3', { inputType: 'document', // 'document' or 'query' truncation: false,});