Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Use AgentRouter credits with Claude Code

A quick setup for running Claude Code through AgentRouter's free API credits on macOS, Linux, or Windows.

Your normal Claude Code setup stays untouched. These instructions route only the terminal session where you set the AgentRouter variables.

What you need

  • An AgentRouter account with free credits
  • An AgentRouter API token
  • Claude Code installed on your computer

AgentRouter expects requests from a supported coding agent. Use Claude Code for this setup rather than a regular chat client.

1. Create your AgentRouter token

  1. Open agentrouter.org and sign in.
  2. Open API Token from the dashboard sidebar.
  3. Create a new token and give it a clear name such as claude-code.
  4. Choose an expiration date, or select no expiration if this is a disposable token.
  5. Give the token enough quota for your available credits. If the dashboard offers Unlimited quota, enable it so the token can use the full account balance.
  6. Copy the token when it appears. It starts with sk-.

Check the model list in your AgentRouter account before continuing. The examples below use claude-opus-5, but you should replace it if your dashboard shows a different model name.

2. Install Claude Code

macOS or Linux

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell

irm https://claude.ai/install.ps1 | iex

You can also use npm on any supported platform:

npm install -g @anthropic-ai/claude-code

The npm method currently requires Node.js 22 or newer.

Confirm the installation:

claude --version

3. Connect Claude Code to AgentRouter

macOS or Linux

Open a new terminal and run:

export ANTHROPIC_BASE_URL="https://agentrouter.org/"
export ANTHROPIC_AUTH_TOKEN="YOUR_AGENTROUTER_TOKEN"
unset ANTHROPIC_API_KEY
claude --model claude-opus-5

Windows PowerShell

$env:ANTHROPIC_BASE_URL = "https://agentrouter.org/"
$env:ANTHROPIC_AUTH_TOKEN = "YOUR_AGENTROUTER_TOKEN"
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
claude --model claude-opus-5

Replace YOUR_AGENTROUTER_TOKEN with the token you copied. Do not include quotation marks inside the token itself.

The base URL should stay at the domain root. Do not add /v1.

Optional launch helpers

This repository includes small launch scripts that ask for your token without saving it to a config file.

macOS or Linux

chmod +x scripts/start-agentrouter.sh
./scripts/start-agentrouter.sh

Choose another available model when needed:

AGENTROUTER_MODEL="your-model-name" ./scripts/start-agentrouter.sh

Windows PowerShell

.\scripts\Start-AgentRouter.ps1

Or choose another model:

.\scripts\Start-AgentRouter.ps1 -Model "your-model-name"

4. Confirm the route

Inside Claude Code, run:

/status

Check that the API endpoint points to agentrouter.org. If it shows Anthropic's normal API endpoint, quit Claude Code and launch it again from the terminal where you set the variables.

5. Try a real task

Open a disposable folder and start Claude Code:

mkdir agentrouter-test
cd agentrouter-test
claude --model claude-opus-5

Then ask:

Create a small Python script that prints the current time, run it, and fix any errors.

If Claude creates and runs the script, the setup works. Check AgentRouter's Usage log to confirm that the request used your credits.

Daily use

Run Claude Code from the project you want it to work on:

cd path/to/your/project
claude --model claude-opus-5

Claude Code can build projects, fix bugs, edit documents, analyze local data, and automate repetitive file work. Remember that prompts, file contents, and command output sent to the model pass through AgentRouter.

Stop using AgentRouter

Close that terminal, or remove the variables from the current shell.

macOS or Linux

unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_MODEL

Windows PowerShell

Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_AUTH_TOKEN -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_MODEL -ErrorAction SilentlyContinue

The next normal Claude Code session will use your usual login or provider again.

Troubleshooting

401 unauthorized client detected

Launch the request through Claude Code. AgentRouter may reject ordinary chat clients or unsupported request formats.

/status shows the normal Anthropic endpoint

The variables were not applied to the Claude Code process. Quit it, set the variables again in the same terminal, and relaunch.

If ANTHROPIC_API_KEY is already set, remove it for the AgentRouter session because it can override the custom token.

Model not found

Copy the exact model name shown in your AgentRouter dashboard. Available models can change between accounts.

The token stops after a small amount of usage

Check the token's own quota. A token-level cap can stop requests even when the account still has credits.

Windows variables do not carry into another terminal

The $env: commands affect only the current PowerShell window. Run Claude Code in that window, or use the included PowerShell helper.

Notes

  • AgentRouter is a third-party relay. Avoid sending private repositories, credentials, client data, or anything you would not share with that service.
  • AgentRouter's dashboard is the source of truth for remaining credits and usage.
  • Free-credit offers, available models, pricing, and access rules can change.
  • Use a separate AgentRouter token so you can revoke it without affecting anything else.

Official links

License

MIT

About

Use AgentRouter free API credits with Claude Code on macOS, Linux, and Windows.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages