If you want to use Agent Router as the API endpoint for Claude Code, you can configure the connection directly through Claude Code's settings.json file.
This configuration sets:
- Your Anthropic API key
- Agent Router as the API base URL
- The Claude model you want to use
- Claude Code permission rules
1. Create or open settings.json
Depending on your Claude Code setup, create or edit your settings.json configuration file.
The basic configuration looks like this:
{
"env": {
"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL": "https://agentrouter.org",
"ANTHROPIC_MODEL": "claude-opus-5"
},
"permissions": {
"allow": [],
"deny": []
}
}
2. Configure the Anthropic API Key
Replace:
"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY"
with your actual API key.
For example:
"ANTHROPIC_API_KEY": "sk-your-api-key-here"
3. Configure Agent Router
The following setting tells Claude Code to send API requests through Agent Router:
"ANTHROPIC_BASE_URL": "https://agentrouter.org"
Instead of communicating directly with the default Anthropic API endpoint, Claude Code will use the configured base URL.
4. Select the Claude Model
Set the model you want Claude Code to use:
"ANTHROPIC_MODEL": "claude-opus-5"
The model name must match a model supported by your Agent Router configuration.
If your Agent Router account uses a different model identifier, replace the value accordingly.
5. Configure Permissions
The permissions section controls which operations Claude Code is allowed or denied.
The minimal configuration is:
"permissions": {
"allow": [],
"deny": []
}
You can later add specific permissions according to your Claude Code workflow.
Complete settings.json
Here is the complete configuration:
{
"env": {
"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY",
"ANTHROPIC_BASE_URL": "https://agentrouter.org",
"ANTHROPIC_MODEL": "claude-opus-5"
},
"permissions": {
"allow": [],
"deny": []
}
}
Once the configuration is saved, Claude Code can use the configured Agent Router endpoint and model according to your setup.
Top comments (0)