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.

Voyage AI exposes several fields on its text embeddings endpoint that have no equivalent in the portable SDK API. You can forward any of these fields by calling ->providerOptions('voyageai', [...]) on the embedding builder. The key–value pairs are merged directly into the JSON request body and sent to Voyage’s API unchanged — the SDK does not whitelist them, so any field Voyage documents will be forwarded.

Example

The following example shows the most commonly used provider options together:
use AiSdk\Generate;
use AiSdk\VoyageAI;

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

Supported Provider Options

input_type
string
Tells Voyage AI how to tokenize and encode the input. Use 'document' when indexing content and 'query' when embedding a search query. Omitting this field lets Voyage choose a default. Using the correct value improves retrieval quality because Voyage trains document and query encoders differently.
truncation
bool
When true, inputs that exceed the model’s maximum context length are silently truncated before embedding. When false (the default), an oversized input causes the API to return an error. Set to true in production pipelines where input length is not guaranteed.
output_dtype
string
Controls the numeric representation of the returned vectors. The only value accepted by this adapter is 'float'. Passing any other value (e.g. 'binary', 'ubinary', 'int8', 'uint8') raises an AiSdk\Exceptions\InvalidArgumentException before the request is sent, because quantized and bit-packed types require a different result contract than the SDK’s standard float-vector response.
output_dimension
int
Requests a specific vector length from Voyage AI. This field is set automatically when you call ->dimensions(int $n) on the embedding builder — you do not need to pass it through providerOptions() directly. For example, ->dimensions(512) results in "output_dimension": 512 in the JSON request body sent to https://api.voyageai.com/v1/embeddings.

Constraints

Only output_dtype: float is accepted. Passing any other value — including 'binary', 'ubinary', 'int8', or 'uint8' — throws an AiSdk\Exceptions\InvalidArgumentException with a message containing 'only output_dtype: float' immediately, without making a network request. Quantized output types need a dedicated result contract and are not yet part of this adapter’s surface.
Setting encoding_format: base64 is rejected for the same reason. Voyage’s base64 path returns packed bytes, not an ordinary float array, so the portable output->vector field cannot be populated correctly. Passing this option throws an AiSdk\Exceptions\InvalidArgumentException with a message containing 'do not support base64' before the request is sent.

Query vs. Document Input Type

When building a retrieval system you will typically embed documents at index time and queries at search time. Use a different input_type for each:
use AiSdk\Generate;
use AiSdk\VoyageAI;

// At indexing time — embed each document in your corpus
$docResult = Generate::embedding([
        'PHP is a popular server-side scripting language.',
        'Voyage AI specialises in embedding models.',
    ])
    ->model(VoyageAI::model('voyage-4-large'))
    ->providerOptions('voyageai', ['input_type' => 'document'])
    ->run();

// At search time — embed the user's query
$queryResult = Generate::embedding('What language powers most websites?')
    ->model(VoyageAI::model('voyage-4-large'))
    ->providerOptions('voyageai', ['input_type' => 'query'])
    ->run();
Only output_dtype and encoding_format are actively blocked. Every other field you put inside the providerOptions array is forwarded to Voyage’s API as-is, so newly documented Voyage fields work automatically without a package update.

Build docs developers (and LLMs) love