aisdk/voyageai

Official Voyage AI provider for the PHP AI SDK.

Maintainers

Package info

github.com/phpaisdk/voyageai

pkg:composer/aisdk/voyageai

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.5.0 2026-07-11 17:55 UTC

This package is auto-updated.

Last update: 2026-07-11 18:05:08 UTC


README

Official Voyage AI provider for the PHP AI SDK.

Installation

composer require aisdk/voyageai

Text Embeddings

use AiSdk\Generate;
use AiSdk\VoyageAI;

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

$vector = $result->output->vector;
$vectors = $result->embeddings;

The v0.5 API covers Voyage's text embeddings endpoint. Multimodal, contextualized chunk embeddings, and reranking use different API contracts and are not part of this package surface yet.

Configuration

Variable Description Default
VOYAGE_API_KEY API key for authentication Required
VOYAGE_BASE_URL Base URL for API requests https://api.voyageai.com/v1
VoyageAI::create([
    'apiKey' => 'pa-...',
    'baseUrl' => 'https://api.voyageai.com/v1',
    'headers' => ['X-Custom-Header' => 'value'],
]);

Provider-Specific Options

Voyage's documented text embedding fields pass through unchanged:

$result = Generate::embedding('A search query')
    ->model(VoyageAI::embedding('voyage-4-large'))
    ->providerOptions('voyageai', [
        'input_type' => 'query',
        'truncation' => true,
        'output_dtype' => 'float',
    ])
    ->run();

dimensions() maps to Voyage's output_dimension field. Model IDs pass through unchanged so Voyage's API remains the source of truth for model availability and supported dimensions.

The portable SDK result is a float vector, so v0.5 accepts Voyage's output_dtype: float only and rejects base64 encoding. Quantized and bit-packed output need a separate result contract rather than being mislabeled as ordinary float dimensions.

Testing

composer test

Links