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.

Model selection in the aisdk/voyageai package is intentionally open-ended. VoyageAI::model(string $modelId) accepts any string, sends it to Voyage’s API unchanged, and lets the API report an error if the model doesn’t exist. There is no internal allowlist to update when Voyage releases new models — if Voyage’s API accepts it, this package accepts it.

Basic Usage

use AiSdk\Generate;
use AiSdk\VoyageAI;

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

Notable Models

The examples in the README and test suite reference the following model. This is not an exhaustive list — it reflects what is used in this package’s own documentation and tests.

voyage-4-large

Voyage AI’s flagship large embedding model. Supports custom output dimensions via ->dimensions(int), which maps to Voyage’s output_dimension request field. Well suited for high-accuracy retrieval tasks where vector quality matters more than latency or storage cost.
The list above is illustrative, not exhaustive. Visit Voyage AI’s official model documentation for the current catalogue of available models, their context lengths, default dimensions, and supported output_dimension ranges.

Model ID Pass-Through

The package does not validate model IDs at construction time. This means that models released after this package was published work without any code change on your end:
// A hypothetical future model — works as-is if Voyage's API accepts it
$result = Generate::embedding('Some text')
    ->model(VoyageAI::model('future-voyage-model'))
    ->run();
The test suite covers this explicitly:
expect(VoyageAI::model('future-voyage-model')->modelId())->toBe('future-voyage-model');
If the model ID is invalid, Voyage’s API returns an error response. The SDK surfaces that as an exception rather than silently swallowing it.

Dimensions Support

Not every Voyage model accepts a custom output_dimension. For models that do, you can request a smaller vector to reduce storage and compute costs:
$result = Generate::embedding('A document')
    ->model(VoyageAI::model('voyage-4-large'))
    ->dimensions(256)   // maps to output_dimension=256 in the request body
    ->run();
When ->dimensions() is omitted, no output_dimension field is sent and Voyage returns the model’s default vector length.
Passing a dimension value that a given model does not support will result in an error from Voyage’s API. Check Voyage AI’s documentation for the minimum and maximum output_dimension values each model accepts before setting custom dimensions in production.

Build docs developers (and LLMs) love