DEV Community

Arpan Dhara
Arpan Dhara

Posted on

Configure Claude Code with Agent Router Using settings.json

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": []
  }
}
Enter fullscreen mode Exit fullscreen mode

2. Configure the Anthropic API Key

Replace:

"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY"
Enter fullscreen mode Exit fullscreen mode

with your actual API key.

For example:

"ANTHROPIC_API_KEY": "sk-your-api-key-here"
Enter fullscreen mode Exit fullscreen mode

3. Configure Agent Router

The following setting tells Claude Code to send API requests through Agent Router:

"ANTHROPIC_BASE_URL": "https://agentrouter.org"
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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": []
}
Enter fullscreen mode Exit fullscreen mode

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": []
  }
}
Enter fullscreen mode Exit fullscreen mode

Once the configuration is saved, Claude Code can use the configured Agent Router endpoint and model according to your setup.

Top comments (0)