TheDocumentation 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.
VoyageAI facade is a final static class in the AiSdk namespace that gives you a concise, zero-boilerplate entry point to the VoyageAI provider. Instead of constructing a VoyageAIProvider and VoyageAIOptions by hand, you call VoyageAI::create() once and then use VoyageAI::model() anywhere in your application. The facade stores a single provider instance as a private static property — the singleton — which can be replaced with create() or cleared entirely with reset().
Class Signature
Methods
VoyageAI::create()
Creates a new VoyageAIProvider from the given configuration array, stores it as the default singleton, and returns it. Calling create() a second time replaces the existing singleton.
Configuration array passed directly to
VoyageAIOptions::fromArray(). Supports apiKey, baseUrl, headers, and sdk keys. If apiKey is omitted the VOYAGE_API_KEY environment variable is used.VoyageAIProvider — the newly created and registered provider instance.
create() unconditionally overwrites the singleton. If you need to preserve an existing provider, read it from VoyageAI::default() before calling create() again.VoyageAI::default()
Returns the current default VoyageAIProvider. If no provider has been created yet, it lazily calls VoyageAI::create() with an empty config — which means the VOYAGE_API_KEY environment variable must be set, or a RuntimeException is thrown.
Returns VoyageAIProvider — the singleton provider.
VoyageAI::model()
Resolves a model through the default provider and returns a Model instance ready to be used with Generate::embedding(). This is the most commonly used method — it delegates to VoyageAI::default()->model($modelId).
The Voyage AI model identifier, for example
'voyage-4-large', 'voyage-3-lite', or any future opaque model ID string. The SDK does not validate this string against a fixed list; any non-empty string is accepted.AiSdk\Contracts\Model — a VoyageAIEmbeddingModel instance bound to the given ID.
VoyageAI::reset()
Sets the singleton back to null. The next call to default() or model() after reset() will lazily recreate the provider (or throw if no API key is available).
Returns void
Singleton Lifecycle
The diagram below summarises how the singleton is managed across the four methods.create()
Builds a fresh
VoyageAIProvider and stores it as the singleton. Always replaces whatever was there before.default()
Returns the singleton. If it is
null, calls create([]) first (lazy initialisation).model()
Thin shortcut: calls
default() and then delegates to the provider’s model() method.reset()
Sets the singleton to
null. The next call to default() or model() starts fresh.