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.
VoyageAIProvider is the central provider class for the aisdk/voyageai package. It sits at the intersection of the PHP AI SDK’s provider contract and the Voyage AI API — accepting a VoyageAIOptions configuration object, advertising its name to the SDK dispatcher, and producing VoyageAIEmbeddingModel instances on demand. You will rarely need to instantiate it directly; the VoyageAI facade handles that for you. However, understanding the class is useful when you want to compose the SDK manually, inject it into a DI container, or write unit tests that work at the provider level.
Class Declaration
VoyageAIProvider extends BaseProvider (from aisdk/core) and implements EmbeddingProviderInterface. The BaseProvider base class exposes the public model(string $modelId): Model method that routes model-ID resolution to the correct protected method — embeddingModel() in this case.
Because
VoyageAIProvider only implements EmbeddingProviderInterface and not a chat or completion provider interface, calling model() with a non-embedding model ID will delegate to the base class, which will throw unless the base class has a suitable handler. Voyage AI exclusively offers embedding models.Constructor
VoyageAIOptions instance and promotes it to a public readonly property. Once constructed, the options (API key, base URL, headers, and optional HTTP client) cannot be changed — create a new provider to use different settings.
A fully-configured
VoyageAIOptions object. Use VoyageAIOptions::fromArray() for the most ergonomic construction, or instantiate it directly when you need precise control over every field.Methods
name(): string
Returns the canonical provider name string used internally by the PHP AI SDK to identify this provider in metadata, error messages, and provider-scoped options.
Returns 'voyageai' (the value of VoyageAIOptions::PROVIDER_NAME).
model(string $modelId): Model (inherited from BaseProvider)
Resolves a model identifier to a concrete VoyageAIEmbeddingModel instance. This method is defined on BaseProvider and delegates to the protected embeddingModel() implementation in VoyageAIProvider.
Any Voyage AI embedding model identifier, e.g.
'voyage-4-large', 'voyage-3-lite', 'voyage-code-3'. The SDK accepts any non-empty string and does not validate against a fixed list, allowing forward compatibility with new models.AiSdk\Contracts\Model — a VoyageAIEmbeddingModel bound to $modelId and the provider’s VoyageAIOptions.
Direct Instantiation
While theVoyageAI facade is the recommended entry point, you can instantiate VoyageAIProvider directly when you need explicit control — for example, in a service container binding or a custom bootstrapping class.
EmbeddingProviderInterface
VoyageAIProvider implements EmbeddingProviderInterface from aisdk/core. This interface signals to the SDK that the provider can produce embedding models and that provider-scoped options sent under the 'voyageai' key (via ->providerOptions('voyageai', [...])) will be forwarded to the underlying HTTP request.
Supported
Text embedding generation via
Generate::embedding()Not Supported
Chat completions, image generation, or other non-embedding modalities
