Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/voyageai/llms.txt

Use this file to discover all available pages before exploring further.

The VoyageAI PHP SDK is the official Voyage AI provider for the PHP AI SDK. It lets you generate text embeddings using Voyage AI’s state-of-the-art models with a single, portable interface — no boilerplate, no vendor lock-in.

Quickstart

Install the package and generate your first embedding in minutes.

Configuration

Set your API key, base URL, and custom headers.

Embeddings Overview

Learn how to embed single strings, batches, and tune output dimensions.

Provider Options

Pass Voyage-specific fields like input_type, truncation, and output_dtype.

Get started in three steps

1

Install via Composer

composer require aisdk/voyageai
2

Set your API key

Export your Voyage AI key as an environment variable, or pass it directly when creating the provider.
export VOYAGE_API_KEY=pa-...
3

Generate an embedding

use AiSdk\Generate;
use AiSdk\VoyageAI;

$result = Generate::embedding(['First document', 'Second document'])
    ->model(VoyageAI::model('voyage-4-large'))
    ->dimensions(512)
    ->run();

$vector  = $result->output->vector;   // first document's float vector
$vectors = $result->embeddings;       // all document vectors

Why VoyageAI PHP SDK?

Portable API

Built on the PHP AI SDK’s shared embedding contract — swap providers without rewriting your application code.

Voyage-native options

Pass input_type, truncation, output_dtype, and custom dimensions directly to Voyage’s API.

Zero-config defaults

Reads VOYAGE_API_KEY and VOYAGE_BASE_URL from the environment automatically.

Type-safe & tested

Strict PHP 8.3+ types, PHPStan analysis, and a full Pest test suite on every push.
This package covers Voyage AI’s text embeddings endpoint. Multimodal embeddings, contextualized chunk embeddings, and reranking are not yet part of this package’s surface.

Build docs developers (and LLMs) love