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
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.textEmbeddingModel('voyage-3');

You can find more models on the Voyage Library homepage.

Model Capabilities

ModelDefault DimensionsContext Length
voyage-3102432000
voyage-3-lite51232000
voyage-finance-2102432000
voyage-multilingual-2102432000
voyage-law-2102432000
voyage-code-2102416000
voyage-3-lite102416000

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,
});