mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
1.8 KiB
1.8 KiB
parent | nav_order |
---|---|
Connecting to LLMs | 500 |
OpenRouter
Aider can connect to models provided by OpenRouter: You'll need an OpenRouter API key.
python -m pip install -U aider-chat
export OPENROUTER_API_KEY=<key> # Mac/Linux
setx OPENROUTER_API_KEY <key> # Windows, restart shell after setx
# Or any other open router model
aider --model openrouter/<provider>/<model>
# List models available from OpenRouter
aider --list-models openrouter/
In particular, many aider users access Sonnet via OpenRouter:
python -m pip install -U aider-chat
export OPENROUTER_API_KEY=<key> # Mac/Linux
setx OPENROUTER_API_KEY <key> # Windows, restart shell after setx
aider --model openrouter/anthropic/claude-3.5-sonnet
{: .tip } If you get errors, check your OpenRouter privacy settings. Be sure to "enable providers that may train on inputs" to allow use of all models.
Controlling provider selection
You can control which OpenRouter providers are used by creating a .aider.model.settings.yml
file in your home directory or project root.
See Advanced model settings
for more details about model settings files. For example:
- name: openrouter/anthropic/claude-3.5-sonnet
extra_params:
provider:
# Only use these providers, in this order
order: ["Anthropic", "Together"]
# Don't fall back to other providers
allow_fallbacks: false
# Skip providers that may train on inputs
data_collection: "deny"
# Only use providers supporting all parameters
require_parameters: true
See OpenRouter's provider routing docs for full details on these settings.