This page walks you through installingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/openrouter/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/openrouter into your project, configuring your API key, and confirming that the package loads without errors so you are ready to make your first request.
Install the package
Run the following command in your project root. Composer will resolve and install
aisdk/openrouter along with its dependencies — aisdk/core and aisdk/openai-compatible.Set your API key
The SDK reads your OpenRouter API key from the In your shell (for scripts and CI):Via the config array (for runtime or framework integration):
OPENROUTER_API_KEY environment variable. You can obtain a key from openrouter.ai/keys.In a .env file (recommended for local development):Configure the base URL (optional)
By default the SDK sends requests to You can also pass it directly in the config array:If neither the environment variable nor the config key is set, the SDK defaults to
https://openrouter.ai/api/v1. If you need to override this — for example to point at a proxy or a staging environment — set the OPENROUTER_BASE_URL environment variable:https://openrouter.ai/api/v1.