Skip to main content
Creates a Voyage AI provider instance with optional configuration settings. You can customize the API key, base URL, headers, and fetch implementation.

Import

import { createVoyage } from 'voyage-ai-provider';

Parameters

options
VoyageProviderSettings
Configuration options for the Voyage provider
options.apiKey
string
API key for authenticating with the Voyage AI API. Defaults to the VOYAGE_API_KEY environment variable.
options.baseURL
string
Base URL for API calls. Use this to configure proxy servers or custom endpoints. Defaults to https://api.voyageai.com/v1.
options.headers
Record<string, string>
Custom headers to include in all requests.
options.fetch
FetchFunction
Custom fetch implementation. Use this as middleware to intercept requests or provide a custom fetch for testing.

Returns

provider
VoyageProvider
A Voyage provider instance that implements the Vercel AI SDK provider interface. The provider can be called as a function or you can use its methods to create specific model types.

Examples

Basic usage with environment variable

import { createVoyage } from 'voyage-ai-provider';

const voyage = createVoyage();

Custom API key

import { createVoyage } from 'voyage-ai-provider';

const voyage = createVoyage({
  apiKey: process.env.VOYAGE_API_KEY,
});

Custom base URL with proxy

import { createVoyage } from 'voyage-ai-provider';

const voyage = createVoyage({
  baseURL: 'https://my-proxy.example.com/voyage',
});

Custom headers

import { createVoyage } from 'voyage-ai-provider';

const voyage = createVoyage({
  headers: {
    'X-Custom-Header': 'value',
  },
});

Custom fetch for testing

import { createVoyage } from 'voyage-ai-provider';

const voyage = createVoyage({
  fetch: async (url, options) => {
    console.log('Request:', url, options);
    return fetch(url, options);
  },
});

Build docs developers (and LLMs) love