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 resolves its configuration in a layered way: values passed to VoyageAI::create() take precedence, and any option left unset falls back to the corresponding environment variable. This means you can run the same application code in development (with an .env file) and in production (with real secrets injected by your platform) without changing a line of PHP.
Environment Variables
These variables are read automatically when the provider is initialised. Neither needs to be present if you supply the equivalent option toVoyageAI::create().
| Variable | Required | Default | Description |
|---|---|---|---|
VOYAGE_API_KEY | Yes | — | API key used to authenticate every request via the Authorization: Bearer header. |
VOYAGE_BASE_URL | No | https://api.voyageai.com/v1 | Base URL for all API requests. Override this to point at a proxy or a self-hosted compatible endpoint. |
Programmatic Configuration
CallVoyageAI::create() once at application bootstrap to configure the default provider instance. Every subsequent call to VoyageAI::model() reuses that instance automatically. You can retrieve the current default provider directly with VoyageAI::default(), which lazily calls create() with an empty config if none has been set — meaning VOYAGE_API_KEY must be present in the environment when using lazy initialisation.
Options
Your Voyage AI API key. When omitted, the value of the
VOYAGE_API_KEY environment variable is used. An InvalidArgumentException is thrown at construction time if neither is present.Base URL for all API requests. Trailing slashes are stripped automatically. Reads from
VOYAGE_BASE_URL when not provided inline.Additional HTTP headers merged into every outgoing request alongside the
Authorization header. Useful for passing proxy tokens, request-tracing headers, or any other custom metadata your infrastructure requires.Custom Headers
Headers are merged on top of the defaultAuthorization: Bearer <apiKey> header, so you can add as many extra headers as needed without losing authentication:
Provider Reset
VoyageAI::reset() clears the stored default provider instance, causing the next VoyageAI::model() call to re-initialise from scratch. This is particularly useful in test suites where each test should start from a clean slate:
