Router One
Back to Blog

Claude Code Setup Guide: Getting Started in 2 Minutes

|Router One Team
claude-codetutorialsetupanthropic

Claude Code is Anthropic's official CLI tool for working with Claude directly in your terminal. By default, it connects straight to the Anthropic API — which works, but gives you no visibility into spending, no budget controls, and no fallback if the API goes down.

Connecting Claude Code through Router One takes about two minutes and gives you real-time usage tracking, automatic budget controls, and the full observability layer that comes with the platform. Here is exactly how to set it up.

Prerequisites

Before you start, make sure you have:

That is it. No additional dependencies or tools required.

Step 1: Get Your Router One API Key

Log in to the Router One dashboard and navigate to the API Keys section. Click Create New Key and give it a descriptive name like "claude-code-personal" or "claude-code-work".

Copy the generated API key. You will need it in the next step. The key starts with sk- and is only shown once, so save it somewhere secure.

While you are in the dashboard, note your available balance. Router One uses a prepaid credit model, so make sure you have sufficient funds loaded for your expected usage.

Step 2: Export the Router One Environment Variables

Claude Code can read the Anthropic-compatible endpoint and credentials from your shell environment. This keeps the setup simple and aligns with the official CLI workflow.

Step 3: Point Claude Code at Router One

Export the following variables in your current shell:

export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_API_KEY=sk-your-router-one-api-key
export ANTHROPIC_AUTH_TOKEN=sk-your-router-one-api-key

Replace sk-your-router-one-api-key with the actual API key you copied in Step 1.

What each variable does:

  • ANTHROPIC_BASE_URL — Tells Claude Code to send requests to Router One's Anthropic-compatible gateway instead of directly to Anthropic.
  • ANTHROPIC_API_KEY — Supplies your Router One API key for authenticated requests.
  • ANTHROPIC_AUTH_TOKEN — Some Claude Code flows also look for this token; setting it to the same Router One key keeps the environment consistent.

If you want this setup to persist across terminal sessions, add the same exports to your shell profile (~/.zshrc or ~/.bashrc).

Step 4: Verify It Works

Open a new terminal window and launch Claude Code:

claude

Send a simple message to confirm the connection is working:

> Hello, can you confirm this is working?

If you get a normal response, your setup is complete. All requests are now flowing through Router One.

To double-check, go back to the Router One dashboard and look at the Usage section. You should see the request you just made, including the model used, tokens consumed, and cost.

Tips for Getting the Most Out of This Setup

Monitor Your Usage in Real Time

The Router One dashboard shows every Claude Code request in real time — tokens consumed, cost per request, model used, and response latency. This is especially useful if you use Claude Code heavily for development work, where token usage can add up quickly during long coding sessions.

Bookmark your dashboard and check it periodically to understand your usage patterns.

Set Up Budget Alerts

Navigate to the Budget section in the Router One dashboard and configure spending alerts. Set a soft warning at 80 percent of your desired monthly budget and a hard limit at 100 percent. This prevents any surprise charges, especially useful if you are using Claude Code on a team where multiple developers share the same organization.

Use Project-Level API Keys

If you work across multiple projects, consider creating a separate API key for each one. This lets you track Claude Code usage per project in the Router One dashboard, making it easy to see which projects consume the most tokens and allocate costs accordingly.

Check Your Balance Before Long Sessions

Claude Code sessions for complex refactoring or large codebases can consume significant tokens. A quick glance at your Router One balance before starting a major session helps you avoid interruptions mid-task.

Secure Your API Key

For production or shared machines, keep the Router One key in your shell profile rather than retyping it in every terminal:

export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_API_KEY="sk-your-router-one-api-key"
export ANTHROPIC_AUTH_TOKEN="sk-your-router-one-api-key"

Troubleshooting

"Authentication failed" error — Double-check that your API key is correct and that your Router One account has a positive balance. Keys are case-sensitive.

"Connection refused" error — Verify ANTHROPIC_BASE_URL is exactly https://api.router.one with no trailing slash or extra path segments.

Slow responses — Router One adds minimal overhead (typically under 10ms). If responses feel slow, check the Router One dashboard for latency metrics. The issue is more likely upstream provider latency than the gateway itself.

Settings not taking effect — Open a new terminal window after exporting the variables, or run the export commands again in your current shell before launching claude.

What Happens Next

With Claude Code connected through Router One, every request is tracked, metered, and protected by your budget controls. You get the same Claude experience with full visibility into what you are spending and how you are using it.

Explore the Router One dashboard to see detailed analytics, set up team budgets, and configure alerts. If you are using other AI tools beyond Claude Code, they can be routed through Router One as well — one platform for all your LLM usage.

Sign up or log in at router.one to get started.

Claude Code Setup Guide: Getting Started in 2 Minutes | Router One