Skip to content
AKRAmit Kumar Raikwar
All posts
AI12 min read

How to use Claude Code for free, and what you trade for it

Claude Code is not on Anthropic's free plan. Four routes get you a coding agent in your terminal at zero cost, including pointing Claude Code at a third-party relay. Here is the command for each one and the bill it sends instead.

Claude CodeAIDeveloper toolsPricingAPI

Claude Code is not on Anthropic's free plan. It starts at Pro, which is $17 a month billed annually or $20 billed monthly (Anthropic, Pricing, retrieved 29 August 2026). The free tier gets you Claude in a browser and nothing in your terminal.

So every answer to "how to use Claude Code for free" is one of four things: a small pot of trial credits, a different agent whose vendor publishes a free quota, a gateway your employer already pays for, or a third-party server that accepts Claude Code's requests and answers them out of its own pocket. The last one is what people usually mean, and it has terms worth reading before you send your repository through it.

This walks all four with the exact commands and the specific cost of each. One disclosure first. The relay I use as the worked example is agentrouter.org, and the sign-up link near the end is a referral link, so I get credit if you use it. Everything I say about the trade-offs is checkable against their published terms and Anthropic's documentation, both of which I quote and date.

Claude Code has no free tier

Anthropic's pricing page lists Claude Code under Pro and above. Pro is $17 a month on the annual plan, $200 billed up front, or $20 billed monthly. A Team standard seat is $20 a month billed annually and $25 monthly. The Free plan's feature list does not include Claude Code (Anthropic, Pricing, retrieved 29 August 2026).

The other paid route is an API key, which carries no subscription and bills per token. That rate matters for the free question, because it sets the scale of what a relay is giving away.

# Claude API list price, per million tokens.
# Source: Anthropic, Pricing, retrieved 29 Aug 2026.
#
#   model              input     output
#   Claude Fable 5       $10        $50
#   Claude Opus 5         $5        $25
#   Claude Opus 4.8       $5        $25
#   Claude Opus 4.6       $5        $25
#   Claude Sonnet 5       $2        $10
#   Claude Haiku 4.5      $1         $5
#
# A cache hit costs 0.1x the input rate. A long
# Claude Code session reads far more cache than
# fresh input, which is why the output column and
# the session length decide the bill.

Read the output column first. Claude Code is an agent, so most of what you pay for is output tokens and cache reads accumulated across a long session. Anthropic's own cost documentation puts enterprise Claude Code usage at around $13 per developer per active day and $150 to $250 per developer per month, with 90 percent of users staying under $30 per active day (Anthropic, Manage costs effectively, retrieved 29 August 2026).

Set that against $20 a month for Pro. Anyone using Claude Code daily is buying the subscription at a heavy discount to metered price, which is worth knowing before you spend a weekend chasing free.

Anthropic's own figure for metered Claude Code use is $150 to $250 per developer per month. Pro is $20. The subscription is the discount.

Route one, a third-party relay

Claude Code will talk to any server that speaks the Anthropic API format. That is a documented feature rather than a hole. Anthropic ships ANTHROPIC_BASE_URL so an organisation can put its own gateway between developers and the model, and Claude Code does not care whether the thing at the other end is Anthropic (Anthropic, Other LLM gateways, retrieved 29 August 2026).

A free relay uses that same door. You register, collect a key, set a base URL and a credential, and Claude Code starts sending your requests somewhere else. AgentRouter describes itself as a public-benefit site for AI coding and says it provides a free quota. Its Claude Code guide gives three variables.

# Point Claude Code at an Anthropic-format relay.
# Source: AgentRouter, Claude Code guide,
# retrieved 29 Aug 2026.

export ANTHROPIC_BASE_URL="https://agentrouter.org"
export ANTHROPIC_AUTH_TOKEN="ak-your-key-here"
export ANTHROPIC_MODEL="claude-opus-4-6"

claude

# Windows PowerShell:
#   $env:ANTHROPIC_BASE_URL="https://agentrouter.org"
#   $env:ANTHROPIC_AUTH_TOKEN="ak-your-key-here"
#   $env:ANTHROPIC_MODEL="claude-opus-4-6"
#
# No /v1 on the base URL. The /v1 path on the same
# domain is the OpenAI-format endpoint, used by
# Codex. Mixing the two is the first failure.

Three details in that block matter. The base URL takes no /v1 suffix, because the Anthropic-format endpoint sits at the root while the /v1 path on the same domain serves the OpenAI format. The key is prefixed ak- and comes from the console token page. And the model IDs on offer are claude-opus-4-6 as the default, plus claude-opus-4-7 and claude-opus-4-8 (AgentRouter, Claude Code guide, retrieved 29 August 2026).

That last list is the most informative line on the page, and I come back to it below.

What the relay route costs you

Four costs, each one written down somewhere you can check.

First, your Claude subscription stops being used. Anthropic is explicit: while a gateway credential variable or an apiKeyHelper is active, the credential replaces the subscription login for that session, and the subscription's usage limits do not apply. Setting ANTHROPIC_BASE_URL alone does not do this, since a saved claude.ai login stays the active credential. Adding the token is what switches it (Anthropic, Other LLM gateways, retrieved 29 August 2026). If you already pay for Pro, a relay does not stack on top of it.

Second, Claude Code turns features off when the endpoint is not Anthropic's. MCP tool search is disabled by default on a non-first-party host, and you set ENABLE_TOOL_SEARCH=true only if the proxy forwards tool_reference blocks. Remote Control is disabled as of v2.1.196 whenever the base URL points somewhere other than api.anthropic.com. Automatic model fallback on third-party providers depends on ANTHROPIC_DEFAULT_FABLE_MODEL naming an ID the provider serves (Anthropic, Environment variables, retrieved 29 August 2026).

Third, nobody is on the hook when it breaks. Anthropic's gateway page says it plainly: Anthropic does not endorse, maintain or audit third-party gateway products, and does not support routing Claude Code to non-Claude models through any gateway. The same page adds that Claude Code gains capabilities with each release, and a gateway that does not forward them breaks the matching features.

Fourth, every prompt leaves your machine and lands on someone else's server. Claude Code puts file contents, diffs, command output and error text in the request body, so a relay reads your codebase in the ordinary course of answering you. I read AgentRouter's terms page on 29 August 2026 and found no privacy, retention or logging provisions in it. What it does publish is a list of things you may not do.

# AgentRouter, Terms of Use, retrieved 29 Aug 2026.
# Seven categories of prohibited use:
#
#   1. training, fine-tuning or distilling other models
#   2. mass registration, batch credit farming by script
#   3. fake calls to farm rewards or usage records
#   4. selling, leasing or sharing accounts and credits
#   5. forged referral relationships
#   6. bypassing rate or concurrency limits, long
#      uninterrupted polling, stress testing
#   7. non-programming use: role-play chat, high-frequency
#      single-turn encyclopedia queries, batch SEO
#      articles, marketing copy and content-farm text
#
# Sanctions listed: quota adjustment, call restriction,
# suspension, termination. Appeals go to an email address.

Item seven deserves a second read if you write for a living. Batch generation of SEO articles, marketing copy or content-farm text is prohibited, alongside role-play chat and high-frequency encyclopedia queries. The service is scoped to programming and says so.

The quota is not published either, and the terms explain why. Limits and model availability are adjusted based on "the genuine and sustained usage patterns of each account," the evaluation mechanisms are "not publicly disclosed to prevent malicious circumvention," dormant accounts "may have their idle resources reclaimed or reduced," and the platform "reserves the final right of interpretation." That is a defensible way to run a free service and a bad thing to put a client deadline on.

You are not getting Anthropic cheaper. You are getting a different counterparty, with a quota it will not publish and terms it can reinterpret.

How to tell what you are talking to

You cannot verify from the client which weights answered your request. The response says whatever the server chose to say. What you can check is the configuration and the shape of the offering, and both carry information.

Start with /status inside Claude Code. An Auth token or API key line naming ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY or an apiKeyHelper confirms a gateway credential is active. A Login method line naming a claude.ai account means your subscription is still serving the session (Anthropic, Connect Claude Code to an LLM gateway, retrieved 29 August 2026).

# What you can check from inside the client.

/status   # Auth token, API key or claude.ai login
/model    # which model ID this session sends
/usage    # token counts, priced locally at list rate

# What you cannot check from the client:
# which weights served the reply.

Then read the model list. AgentRouter offers Opus 4.6, 4.7 and 4.8. Anthropic's pricing page on the same day lists Claude Opus 5 and Claude Fable 5 as current, with 4.6 through 4.8 still served at $5 in and $25 out per million tokens. A relay's catalogue works as a lag indicator: it tells you which generation the upstream supply is drawn from.

Breadth is the other signal. The same domain serves gpt-5.6, gpt-5.5 and glm-5.2 on its OpenAI-format endpoint (AgentRouter, Codex guide, retrieved 29 August 2026). One endpoint fronting three vendors is an aggregator, and an aggregator's supply for any single model can change without the model ID changing.

One number to distrust while you are there. Claude Code computes the dollar figure in /usage locally from token counts at Anthropic's list price, not from anything the server reported (Anthropic, Manage costs effectively, retrieved 29 August 2026). On a relay it is a token meter wearing a currency symbol.

The test that does tell you something is behavioural. Keep one well-specified task you have run before, on a repository you know, and run it on both routes. Count the turns, watch whether it holds a plan across tool calls, and see whether it gives up. That behaviour is the property you are buying, and it is the first thing a model swap degrades.

Route two, a free tier somebody publishes

Google gives Gemini CLI away on a personal Google account at 60 requests a minute and 1,000 requests a day, on Gemini 3 models with a 1 million token context window and no API key to manage (google-gemini/gemini-cli, README, retrieved 29 August 2026).

# Gemini CLI, free tier on a personal Google account.
# 60 requests/min, 1,000 requests/day, 1M context.
# Source: google-gemini/gemini-cli README,
# retrieved 29 Aug 2026.

npm install -g @google/gemini-cli
gemini

# Or without installing:
#   npx @google/gemini-cli
# Or on macOS and Linux:
#   brew install gemini-cli

GitHub Copilot Free includes the Copilot CLI, capped at 2,000 completions a month, with model access through automatic selection only and no model picker (GitHub, Plans for GitHub Copilot, retrieved 29 August 2026). Its chat allowance is described as an allowance of GitHub AI Credits with no published number for the Free plan, which is worth knowing before you plan around it.

Neither of these is Claude Code. The agent loop differs, the tool set differs, and the model differs. What they have that a relay does not is a published number, a vendor who is also the operator, and no interaction with your Claude subscription. If the goal is a working coding agent in your terminal at zero cost, this is the version of it that holds up.

Route three, the credits you already have

Anthropic gives new API users a small amount of free credits to test the API, per its own pricing FAQ. The amount is not published there. It is enough to answer whether Claude Code fits how you work, which is the question a trial should answer.

Two API features cost nothing on top of tokens and cut the bill on the paid route. Each organisation gets 1,550 free hours a month of code execution, billed at $0.05 an hour per container beyond that, and free entirely when used alongside web search or web fetch. The web fetch tool carries no additional charge at all (Anthropic, Pricing, retrieved 29 August 2026).

If you work somewhere that already runs a gateway, the free route is to ask for a credential. It is the same mechanism as the relay, with the bill going to an employer who agreed to it. Anthropic's connect page tells you to start claude, open /status and read the auth line before configuring anything, because an administrator may have distributed the settings already.

The arithmetic that decides this

# Which route fits which situation.
#
#   situation                        route
#   learning, no budget             Gemini CLI free tier
#   evaluating Claude Code          Anthropic trial credits
#   daily paid work                 Pro, $17 to $20 a month
#   spiky and low volume            API key, per token
#   employer runs a gateway         ask for a credential
#   throwaway repo, no secrets      third-party relay
#
# Anthropic's metered figure for Claude Code use:
# $150 to $250 per developer per month.

Where I land, after running Claude Code daily on client work: a relay is a sandbox rather than a workspace. I would point one at a scratch repository to watch how a model handles a task. I would not point one at a client codebase under an NDA, because the terms I would be relying on reserve the final right of interpretation to the platform and say nothing about what happens to the request body.

For learning, a published free tier beats an undisclosed one. A thousand requests a day from Google is a number you can plan a week around. A quota adjusted on criteria nobody will show you is not a number at all.

For paid work the arithmetic settles it. $20 a month against Anthropic's own $150 to $250 metered figure makes the subscription the cheapest way to use Claude Code that exists. The free routes are for the period before you know whether you need it.

Getting back to your subscription

This is the step people get stuck on, and it has one trap. Unsetting the shell variables is not always enough, because a settings file env block beats your shell: when the same variable is set in both, the settings file value applies (Anthropic, Environment variables, retrieved 29 August 2026).

# Back to your Claude subscription.
unset ANTHROPIC_AUTH_TOKEN
unset ANTHROPIC_BASE_URL
unset ANTHROPIC_MODEL

claude

# Still routing to the relay? A settings file beats
# the shell. Check the env block in each of these:
#   ~/.claude/settings.json
#   .claude/settings.json        (checked into git)
#   .claude/settings.local.json  (gitignored)
#
# Then run /status and read the Login method line.

One more thing before you paste a key anywhere. .claude/settings.json is checked into source control and shared with everyone on the project, so a token in it is a token in your git history. Put it in .claude/settings.local.json, which is gitignored, or in ~/.claude/settings.json. Claude Code also sets CLAUDECODE=1 in Bash tools, hooks, the status line and stdio MCP subprocesses, so anything in that environment is inherited by every child process it spawns.

If you have read the trade-offs and still want to test the relay route on a scratch repository, the AgentRouter sign-up is at https://agentrouter.org/register?aff=C6P1 and the setup page is at https://agentrouter.org/docs/claude-code.html. That register link is a referral link. Use the plain domain instead if you would rather not credit me for it.

Four free routes to a coding agent exist and all four send a bill. Trial credits cost you the evaluation window. A published free tier costs you the model. An employer's gateway costs you the employer. A relay costs you the counterparty, the features Claude Code switches off, and whatever your prompts are worth to whoever is operating it. Pick the bill you are willing to pay, and learn the unset command before you need it.

Frequently asked questions

Is Claude Code free?
No. Anthropic's pricing page lists Claude Code from Pro upwards, at $17 a month billed annually or $20 billed monthly, and the Free plan's feature list does not include it. New API users get a small amount of free credits to test the API, which is a trial rather than a tier. Anything else described as free Claude Code is either a third-party server answering Claude Code's requests or a different coding agent entirely.
Can you use Claude Code without a Claude subscription?
Yes, two ways. An API key bills per token with no subscription, at $5 per million input tokens and $25 per million output for Claude Opus 5. Or set ANTHROPIC_BASE_URL plus a credential variable to route through a gateway, which is how both corporate gateways and third-party relays work. Anthropic notes that once a credential variable or apiKeyHelper is active, your claude.ai subscription is not used for that session and its usage limits do not apply, so the two do not stack.
Is it safe to use a third-party Claude Code proxy?
Treat it as sending your codebase to a stranger, because that is the mechanism. Claude Code puts file contents, diffs and command output in the request body, so the proxy reads your project in order to answer. Anthropic states that it does not endorse, maintain or audit third-party gateway products, and Claude Code disables MCP tool search and Remote Control when the base URL is not api.anthropic.com. AgentRouter's terms page, read on 29 August 2026, publishes prohibited uses and enforcement but no privacy, retention or logging provisions. A scratch repository is a reasonable place to try one. A client codebase under an NDA is not.
What is the best free alternative to Claude Code?
Gemini CLI, if you want a quota somebody publishes. Google's free tier on a personal Google account is 60 requests a minute and 1,000 requests a day on Gemini 3 models with a 1 million token context window. GitHub Copilot Free includes the Copilot CLI with 2,000 completions a month and automatic model selection only, though the chat allowance has no published number for the Free plan. Neither is Claude Code, and the agent loop is where you will notice the difference before the model.
How do I switch Claude Code back to my subscription?
Unset ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL and ANTHROPIC_MODEL in your shell, then relaunch claude. If it still routes to the relay, check the env block in ~/.claude/settings.json, .claude/settings.json and .claude/settings.local.json, because a settings file value beats a shell variable when both set the same key. Run /status afterwards and read the Login method line to confirm a claude.ai account is serving the session.

Written by Amit Kumar Raikwar, full-stack engineer & product designer in Indore, India. If you want something built, start here.

Working on something?

Let's build it together.

I take projects from an empty Figma file to a live product. Fixed scope, weekly demos, code you own.