How-To Guide

How to Use Claude Code in 2026 (and Route It Cheaper)

Claude Code is Anthropic's command-line coding agent — it reads your repo, plans, edits files, and runs commands from the terminal. This guide covers installing and setting it up, the workflow that gets the most out of it, the cost reality of running a flagship agent on big tasks, and the part most guides skip: how to route it to cheaper models with claude-code-router or a gateway so a large job doesn't run up a flagship-priced bill.

How to use Claude Code — install, set up, use, and route it cheaper to cut cost

What Claude Code is

Claude Code is Anthropic's command-line coding agent. You run it in a project directory and it reads the codebase, plans changes, edits files, and runs commands directly from the terminal — an agentic alternative to pasting snippets into a chat window. By default it's powered by Claude's flagship Opus models, which is why it's capable and also why it can get expensive on large tasks.

How this is sourced. Install/usage reflects Anthropic's Claude Code docs; the routing approach uses the open-source claude-code-router and gateway base-URL override. Cost figures use live prices from the DataLLM Lab catalog, June 2026, modeled against the token assumptions noted below. See also our LLM routing guide.

Install & set up

  1. Install the CLI — e.g. npm install -g @anthropic-ai/claude-code (or the official installer per Anthropic's docs).
  2. Run it in your project: claude
  3. Authenticate with a Claude subscription, or an Anthropic API key: export ANTHROPIC_API_KEY=...
  4. Approve as it goes — Claude Code asks before editing files or running commands, so you stay in control.

Using it well

Describe what you want in plain language — "add input validation to the signup form and write tests," "find and fix the failing test," "refactor this module to use the new API." Claude Code proposes a plan, edits the relevant files, and can run your tests or commands, iterating until the task is done. It's at its best on multi-file, repo-aware tasks where a chat window would lose context: end-to-end features, cross-module refactors, and debugging that spans several files. Give it a clear goal and let it read the project rather than pasting snippets.

The cost problem

Because Claude Code defaults to Opus, a large agentic task — reading lots of files, multiple iterations — can consume a lot of tokens at flagship rates ($5/$25 per million). For heavy users, a month of intensive use can run into the hundreds or low thousands of dollars. On a heavy coding-agent workload (modeled at 100M input + 20M output tokens/month), all-flagship usage is around $1,000/month. The fix isn't to stop using it; it's to route the easy parts to cheaper models and keep the flagship for the hard steps.

How claude-code-router works

claude-code-router is an open-source proxy that sits between Claude Code and the model providers. Claude Code talks to it as if it were Anthropic; the router then decides which model actually handles each request — a cheap model (DeepSeek, Qwen) for routine calls, a flagship for the hard ones — based on rules you configure. It works by pointing Claude Code's base URL at the router, so no change to how you use the CLI; only the backend changes.

Route it cheaper (worked config)

Two ways to cut Claude Code's cost without losing quality on the hard steps:

# Route Claude Code through a gateway (or claude-code-router) instead of direct
export ANTHROPIC_BASE_URL="https://www.datallmlab.com/v1"
export ANTHROPIC_API_KEY="$DATALLMLAB_API_KEY"
claude   # now its requests go through the gateway, where routing applies

The savings

Routing the easy majority of an agent's work to a cheap model and reserving a flagship for hard steps is the same cost-routing pattern that cuts general LLM spend by 60%+:

Claude Code cost: flagship vs routed100M input + 20M output tokens, June 2026All flagship (Opus 4.7)$1,000Cost-routed (70/30)$321All cheap (DeepSeek V3.2)$30
Chart: DataLLM Lab — modeled monthly cost for a 100M/20M-token agent workload, June 2026. All-flagship is ~$1,000; a 70/30 cheap-to-flagship split is ~$320; all-cheap is ~$30. The same lever applies to Claude Code's traffic.

Tips to keep it cheap & effective

Route Claude Code through one gateway

Point Claude Code at DataLLM Lab to route across 300+ models with live price comparison and failover — flagship only where it's needed.

FAQ

What is Claude Code?

Anthropic's command-line coding agent — it reads your repo, plans, edits files, and runs commands from the terminal. Powered by Claude (Opus by default).

How do I install and set up Claude Code?

Install the CLI (e.g. npm install -g @anthropic-ai/claude-code), run claude in your project, and authenticate with a Claude subscription or ANTHROPIC_API_KEY. It asks before edits/commands.

How much does Claude Code cost?

With a subscription, included up to limits; with an API key, per token at Claude's rates (Opus $5/$25). A heavy modeled coding workload runs ~$1,000/mo all-flagship — routing cuts that sharply.

What is claude-code-router?

An open-source proxy between Claude Code and providers that routes requests to cheaper/alternative models where a flagship isn't needed, by pointing Claude Code's base URL at it.

How do I make Claude Code cheaper?

Route it — use claude-code-router or set ANTHROPIC_BASE_URL to a gateway, then send routine work to a cheap model and reserve a flagship for hard steps. A 70/30 split drops ~$1,000 to ~$320.

Can I use Claude Code without a subscription?

Yes — authenticate with an Anthropic API key and pay per token, or point it at a gateway via ANTHROPIC_BASE_URL to run it on other providers' models.

What is Claude Code best at?

Multi-file, repo-aware tasks — cross-module refactors, end-to-end features with tests, debugging across files — where it reads the whole project rather than pasted snippets.

Does routing Claude Code hurt quality?

Not if you route by difficulty — a cheap model handles the routine majority, a flagship handles the hard steps. Quality stays high where it mattered.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.