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.
VoyageAIOptions is an immutable configuration value-object that carries every setting the VoyageAI provider needs to communicate with the Voyage AI API. Constructing a VoyageAIOptions instance is the only way to supply an API key, a custom base URL, extra HTTP headers, or a test-friendly HTTP client to the SDK. All properties are declared public readonly, so the object is safe to share and cache — changing settings always means creating a new instance.
Class Declaration
Constants
'https://api.voyageai.com/v1' — the production Voyage AI REST endpoint. Used as the default value for $baseUrl and as the fallback in fromArray() when neither the baseUrl config key nor the VOYAGE_BASE_URL environment variable is set.'voyageai' — the canonical string identifier for this provider within the PHP AI SDK. Returned by VoyageAIProvider::name() and used as the key for provider-scoped options in Generate::embedding()->providerOptions('voyageai', [...]).Constructor Parameters
Your Voyage AI API key (begins with
pa-). This is the only required parameter. It is included in every outbound HTTP request via the Authorization: Bearer {apiKey} header. Never commit this value to source control; use an environment variable instead.The root URL for all API requests. Override this when routing through an API gateway, a caching proxy, or a local mock server. Trailing slashes are stripped automatically by
fromArray(); when using the constructor directly, pass a clean URL without a trailing slash.Arbitrary HTTP headers to merge into every outgoing request alongside the
Authorization header. Useful for adding tracing headers (X-Request-ID), custom routing headers required by a proxy, or any other static header your infrastructure needs.An optional
AiSdk\Support\Sdk instance that wraps a PSR-18 HTTP client and a PSR-17 HTTP factory. When null (the default), the provider uses the SDK’s auto-discovered HTTP client. Pass an Sdk instance backed by a fake client to intercept HTTP calls in tests without making real network requests.fromArray() Static Factory
VoyageAIOptions. The factory method handles environment-variable fallbacks and URL normalisation so you don’t have to.
An associative array with any of the keys:
apiKey, baseUrl, headers, sdk. All keys are optional — the factory reads environment variables when keys are absent.| Config key | Env variable fallback | Hard default |
|---|---|---|
apiKey | VOYAGE_API_KEY | (throws if missing) |
baseUrl | VOYAGE_BASE_URL | DEFAULT_BASE_URL |
headers | — | [] |
sdk | — | null |
If neither
config['apiKey'] nor the VOYAGE_API_KEY environment variable is set, fromArray() throws a RuntimeException. Set the environment variable or pass the key explicitly.baseUrl value — whether from the config array or the environment variable — has its trailing slash stripped before being stored, so joining it with a path such as /embeddings always produces a well-formed URL.
authHeaders() Method
Authorization header and any custom headers supplied at construction time.
