Router One
Back to Blog

Claude Code Setup Guide: Getting Started in 2 Minutes

PublishedRouter One Team

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, per-key spend and rate controls, and the request-level 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 a Per-Key Spend Cap

Open Dashboard → API Keys and set maxSpend on the key used by Claude Code. The key stops spending when it reaches that cap. If several developers or projects share one wallet, give each one a separate key so its usage and exposure stay isolated.

Use a Separate API Key per Project

If you work across multiple projects, create a separate API key for each one. Name the key after its project, then use the dashboard's per-key view to compare token usage and cost; Router One does not expose a separate project-level usage dimension.

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 and metered, while the key's maxSpend and rate controls bound that workload. You get the same Claude experience with visibility into what you are spending and how you are using it.

Explore the Router One dashboard to see request analytics and configure per-key spend and rate controls. If you are using other AI tools beyond Claude Code, give each tool its own key and route it through the same gateway.

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

Related canonical pages

This article belongs to the Claude Code China cluster. These pages are the commercial page, setup docs, evidence source, and trust references.

Related reads