Voyage AI Provider

This community provider is not yet compatible with AI SDK 5. It uses the deprecated .embedding() method instead of the standard .textEmbeddingModel() method. Please wait for the provider to be updated or consider using an AI SDK 5 compatible 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
npm
yarn
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.embedding('voyage-3');

You can find more models on the Voyage Library homepage.

Model Capabilities

ModelDefault DimensionsContext Length
voyage-3-large1024 (default), 256, 512, 204832,000
voyage-3102432000
voyage-code-31024 (default), 256, 512, 204832000
voyage-3-lite51232000
voyage-finance-2102432000
voyage-multilingual-2102432000
voyage-law-2102432000
voyage-code-2102416000

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.embedding('voyage-3', {
inputType: 'document', // 'document' or 'query'
truncation: false,
outputDimension: 1024, // the new model voyage-code-3, voyage-3-large has 4 different output dimensions: 256, 512, 1024 (default), 2048
outputDtype: 'float', // output data types - int8, uint8, binary, ubinary are supported by the new model voyage-code-3, voyage-3-large
});

Learn more about the output data types.