The Tech ArchiveThe Tech ArchiveThe Tech Archive
Small BusinessMarketingDevelopers
ArticlesTopicsSeriesAbout

Get the practical AI brief

Verified, no-hype AI tips you can actually use - in your inbox. Free.

No spam. We verify what we send. Unsubscribe anytime.

The Tech ArchiveThe Tech Archive

The Tech Archive

AI news, analysis & explainers

AboutSmall BusinessMarketingDevelopersArticlesTopicsSeriesMethodologyAI DisclosureCorrections

© 2026 All rights reserved.

Back to home
0 readers reading
  1. Home
  2. Articles
  3. Artificial Intelligence
  4. How to Use Claude Code for Free in 2026: 5 Methods That Actually Work

Contents

How to Use Claude Code for Free in 2026: 5 Methods That Actually Work
Artificial Intelligence

How to Use Claude Code for Free in 2026: 5 Methods That Actually Work

Claude Code costs $20–200/month on a subscription — but you can run it free with OpenRouter, Ollama, free API credits, or student/FOSS programs. Here's every method that works.

Sham

Sham

AI Engineer & Founder, The Tech Archive

15 min read
0 views
August 1, 2026

Claude Code is the most capable terminal-based AI coding agent available in 2026 — and yes, you can use it without paying Anthropic a dime. The agent shell is open-source and free to install; what you pay for is the model behind it. By redirecting Claude Code to free or alternative model providers, you get the full agent experience — file editing, git workflows, multi-file refactoring — at zero cost. This guide covers five legitimate, tested methods to do exactly that, with exact setup commands and honest tradeoffs for each.

Last verified: 2026-08-01 · Best overall: OpenRouter free models · Best for unlimited use: Ollama local · Best for trying Claude: $5 free API credits · Pricing/limits change often — last checked Aug 2026.

Can you use Claude Code for free?

Yes. Claude Code is free to install (open-source on GitHub at 139K+ stars), and you can redirect it to free model providers instead of paying for an Anthropic subscription. The cheapest subscription that includes Claude Code is Claude Pro at $20/month; the free Claude.ai tier gives only 2–5 prompts per 5-hour window — enough to test, not to work. The methods below bypass that limit entirely.

The key mechanism is simple: Claude Code respects a single environment variable called ANTHROPIC_BASE_URL. Set it to any API endpoint that speaks the Anthropic Messages API protocol, and Claude Code talks to that provider instead of Anthropic's servers. This is officially documented by Anthropic and is not a hack — it exists for enterprise proxy, AWS Bedrock, and Google Vertex AI routing. A similar approach works with other free AI coding agents — see our guide on Omniroute + OpenCode for free AI coding for a parallel setup using a different agent harness.

The 5 free methods compared

Method Cost Setup time Models available Rate limits Best for
OpenRouter free models $0 5 min 28+ free models (Llama 3.3 70B, Nemotron Ultra, Ling-3.0 Flash, etc.) 50 req/day (1,000 after $10) Best overall — real models, no hardware
Ollama local LLM $0 15 min Any open model you can run locally Unlimited (your hardware is the limit) Privacy, offline use, unlimited runs
Free Anthropic API credits $0 2 min Claude Sonnet 4.6, Opus 4.6, Haiku 4.5 (actual Anthropic models) ~$5 worth (~3–8 sessions) Trying real Claude models risk-free
Student / FOSS maintainer programs $0 10 min (application) Full Claude Pro or Max 20x Pro or Max limits Students and open-source maintainers
LiteLLM proxy + free cloud keys $0 20 min Any provider with a free tier (Gemini, GLM, etc.) Provider-dependent Multi-provider routing with failover

Method 1: How to set up Claude Code with OpenRouter free models

OpenRouter is a unified AI API gateway that offers an "Anthropic Skin" — a native Anthropic Messages API-compatible endpoint. Claude Code speaks its own protocol directly to OpenRouter with no local proxy required. OpenRouter hosts 28+ free models as of August 2026, including strong coding models like NVIDIA Nemotron 3 Ultra, Poolside Laguna S 2.1, and Cohere North Mini Code.

Step-by-step setup

1. Install Claude Code (if you haven't already):

# Native installer (recommended)
curl -fsSL https://claude.ai/install.sh | sh

# Or via npm (legacy, deprecated)
npm install -g @anthropic-ai/claude-code

2. Create a free OpenRouter account and API key:

  • Go to openrouter.ai and sign up (no credit card required for free models)
  • Navigate to API Keys in your dashboard and generate a new key (starts with sk-or-)
  • Copy the key

3. Set four environment variables (add to ~/.zshrc or ~/.bashrc for persistence):

export OPENROUTER_API_KEY="sk-or-your-key-here"
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""

Critical detail: ANTHROPIC_API_KEY must be set to an empty string, not omitted. If unset, Claude Code falls back to authenticating against Anthropic directly and ignores your OpenRouter setup entirely.

4. If you previously logged in with an Anthropic account, run /logout once inside Claude Code, then relaunch to avoid cached credentials overriding your environment variables. Verify your setup with /status:

> /status
Auth token: ANTHROPIC_AUTH_TOKEN
Anthropic base URL: https://openrouter.ai/api

5. (Optional) Route to specific models. By default Claude Code requests Claude models through OpenRouter (which routes to Anthropic's API and bills you per token). To use free models instead, override the model slots:

export ANTHROPIC_DEFAULT_SONNET_MODEL="meta-llama/llama-3.3-70b-instruct:free"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="meta-llama/llama-3.3-70b-instruct:free"

Or try openrouter/free — a special router that automatically selects from available free models based on your request's requirements.

What you get for free on OpenRouter (August 2026)

Free model Context Best for
NVIDIA Nemotron 3 Ultra (free) 1M tokens Long-running agentic workflows, multi-step reasoning
InclusionAI Ling-3.0-flash (free) 262K tokens Token-efficient coding, production-scale tasks
Poolside Laguna S 2.1 (free) 262K tokens Software engineering, agentic coding (70.2% Terminal-Bench)
NVIDIA Nemotron 3 Super (free) 262K tokens Programming, high-throughput inference
Cohere North Mini Code (free) 256K tokens Code generation, terminal tasks
Meta Llama 3.3 70B Instruct (free) 131K tokens General-purpose chat, stable long-term use

Rate limits: 20 requests/minute, 50 requests/day on the free tier. After adding $10 in credits (one-time, never expires), the daily limit rises to 1,000 requests. A 5.5% fee applies to credit purchases with a $0.80 minimum.

The honest tradeoff

Free models on OpenRouter are not frontier-level. They lack the deep codebase reasoning that Claude Sonnet or Opus provide. But for scaffolding, boilerplate, bug fixes, test generation, and experimentation, they are genuinely usable. The pattern that works: use free models for exploration and prototyping, then switch to paid Claude for the 20% of work that demands frontier reasoning.


Method 2: How to run Claude Code with a local model via Ollama

If you want truly unlimited, offline, and private AI coding — run an open-source model locally with Ollama. Claude Code connects to Ollama's Anthropic-compatible API endpoint with a single environment variable. No internet connection required after setup.

Step-by-step setup

1. Install Ollama:

# macOS / Linux
curl -fsSL https://ollama.com/install.sh | sh

# Windows: download from ollama.com

2. Pull a coding-capable model:

# Qwen 2.5 Coder 32B — strong coding model, needs ~20GB RAM
ollama pull qwen2.5-coder:32b

# Or Qwen 2.5 Coder 7B — lighter, runs on 8GB RAM machines
ollama pull qwen2.5-coder:7b

# Or Llama 3.3 70B if you have 48GB+ RAM
ollama pull llama3.3:70b

3. Point Claude Code at Ollama:

export ANTHROPIC_BASE_URL="http://localhost:11434"
export ANTHROPIC_API_KEY="ollama"
export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen2.5-coder:32b"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen2.5-coder:7b"

4. Launch Claude Code in your project directory and start coding.

Hardware reality check

Model RAM needed Speed Coding quality
Qwen 2.5 Coder 7B 8 GB Fast (~40 tok/s on M1) Good for small tasks
Qwen 2.5 Coder 32B 24 GB Moderate (~10 tok/s) Strong — handles multi-file work
Llama 3.3 70B 48 GB Slow (~3 tok/s) Excellent — near-frontier reasoning

Ollama runs models entirely on your machine. There are zero rate limits, no API costs, no data leaving your device. The tradeoff is speed — local inference is slower than API calls, and smaller models produce lower-quality code than Claude Sonnet. For a deeper dive into running AI models locally — including quantized models that fit in as little as 1 GB of memory — see our guide on running local AI models on any device.


Method 3: How to use $5 in free Anthropic API credits

New Anthropic API accounts receive approximately $5 in free credits — enough for 3–8 real Claude Code sessions with actual Claude models. This is the best way to experience Claude Code with frontier models before deciding whether to subscribe.

Step-by-step setup

1. Create an Anthropic API account at console.anthropic.com (separate from a Claude.ai chat account).

2. Generate an API key under API Keys in the console dashboard.

3. Set your API key:

export ANTHROPIC_API_KEY="sk-ant-your-key-here"

# Do NOT set ANTHROPIC_BASE_URL — leave it unset to use Anthropic's default endpoint

4. Run Claude Code and track your spend with the /cost command:

> /cost
Session cost: $0.84 (Sonnet 4.6, 45K input + 12K output tokens)

What $5 buys you

A typical Claude Code session with Sonnet 4.6 consumes 50,000–200,000 tokens. At Sonnet's rate of $3 per million input tokens and $15 per million output tokens, a session costs roughly $0.30–$1.00. That gives you about 5–15 sessions — enough for a few days of evaluation work.

Model Input price (per MTok) Output price (per MTok) Sessions from $5
Claude Sonnet 4.6 $3 $15 ~5–10
Claude Opus 4.6 $5 $25 ~3–5
Claude Haiku 4.5 $1 $5 ~15–20

Use Sonnet (not Opus) during your trial to maximize session count. Reserve Opus for the one complex multi-file refactor that demands deep reasoning.


Method 4: Free Claude Code for students and open-source maintainers

Anthropic runs two programs that grant full Claude Code access at no cost.

Claude for Education (students)

Students at partner universities get free Claude Pro access, which includes full Claude Code CLI. Check claude.com/education for the current list of partner institutions. If your university is listed, sign in with your .edu email.

Alternatively, the GitHub Student Developer Pack bundles Claude model access — apply at education.github.com/pack with a valid student ID or enrollment proof.

Claude for Open Source (maintainers)

Anthropic's Claude for Open Source program, launched in February 2026, grants qualifying open-source maintainers six months of Claude Max 20x (a $1,200 value) completely free. Max 20x gives roughly 20x the Pro usage allowance with priority access during peak demand.

Eligibility: You must be an active maintainer of a public open-source project with meaningful community impact. Check Anthropic's website for current requirements and application deadlines.


Method 5: LiteLLM proxy for multi-provider routing

LiteLLM is an open-source proxy that translates between different AI API formats. It lets you route Claude Code to any provider with a free tier — Google Gemini, Zhipu GLM, MiniMax — with automatic failover between them.

Quick setup

1. Install LiteLLM:

pip install litellm[proxy]

2. Create a config file (litellm_config.yaml):

model_list:
  - model_name: claude-sonnet
    litellm_params:
      model: gemini/gemini-2.0-flash
      api_key: your-google-api-key
  - model_name: claude-haiku
    litellm_params:
      model: glm/glm-4-flash
      api_key: your-glm-api-key

3. Start the proxy:

litellm --config litellm_config.yaml --port 4000

4. Point Claude Code at it:

export ANTHROPIC_BASE_URL="http://localhost:4000"
export ANTHROPIC_API_KEY="any-string-here"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku"

LiteLLM translates Claude Code's Anthropic-format requests into the target provider's format. If one provider rate-limits you, LiteLLM can fail over to another. This is more complex than OpenRouter but gives you full control over routing and costs.


Which free method should you pick?

Your choice depends on what you are building and your hardware:

Choose OpenRouter (Method 1) if you want the fastest setup with no hardware requirements. You get access to 28+ free models, 50 requests/day (1,000 after a one-time $10 credit), and no complexity beyond four environment variables.

Choose Ollama (Method 2) if you need unlimited, offline, or private use. Your hardware is the only ceiling — no rate limits, no API bills, no data leaving your machine. Requires at least 8 GB RAM for a usable coding model.

Choose free API credits (Method 3) if you want to try actual Claude models (Sonnet, Opus, Haiku) before committing to a subscription. Best for a few days of evaluation — not long-term use.

Choose student/FOSS programs (Method 4) if you qualify. Six months of Max 20x is the most generous free option available, but it requires enrollment or maintainer status.

Choose LiteLLM (Method 5) if you want multi-provider routing with failover and already have free API keys from Google, Zhipu, or another provider. More setup, but maximum flexibility.

A practical free stack looks like this: OpenRouter free models as your daily driver for scaffolding and experimentation, a local Ollama model for private or offline work, and the $5 in free Anthropic credits reserved for the complex task that genuinely needs Claude Sonnet. If you are curious how Claude Code compares to alternatives on speed and memory, see our jcode vs Claude Code comparison. For autonomous features that let you walk away from the terminal while Claude Code works, check our Claude Agent OS auto mode guide.

What this means for you

If you are a developer, builder, or small business experimenting with AI coding agents, the cost barrier to Claude Code is effectively zero. You do not need a $20/month Pro subscription or a $100/month Max plan to get started. The OpenRouter route gives you a working agentic coding environment in five minutes with no credit card. Reserve paid Claude subscriptions for the work that demands frontier-level reasoning — the vast majority of coding tasks (scaffolding, boilerplate, tests, bug fixes, documentation) run fine on free models.

FAQ

Q: Is Claude Code actually free?

A: Claude Code is free to install — the source code is open on GitHub at github.com/anthropics/claude-code. What costs money is the AI model that powers it. Anthropic's free Claude.ai tier includes very limited Claude Code access (2–5 prompts per 5-hour window). However, you can redirect Claude Code to free model providers like OpenRouter or Ollama using the ANTHROPIC_BASE_URL environment variable and pay nothing at all.

Q: How do I point Claude Code at a different API provider?

A: Set the ANTHROPIC_BASE_URL environment variable to your provider's API endpoint, and ANTHROPIC_AUTH_TOKEN (or ANTHROPIC_API_KEY) to your API key. For OpenRouter, set ANTHROPIC_BASE_URL="https://openrouter.ai/api" and ANTHROPIC_API_KEY to an empty string. This is officially documented by Anthropic and supports any API that speaks the Anthropic Messages API format. The variable is read once at process startup — change it and you must restart Claude Code.

Q: What are the best free models for coding on OpenRouter?

A: As of August 2026, the strongest free coding models on OpenRouter are Poolside Laguna S 2.1 (70.2% on Terminal-Bench 2.1), NVIDIA Nemotron 3 Ultra (1M context, strong multi-step reasoning), InclusionAI Ling-3.0-flash (262K context, token-efficient), and Cohere North Mini Code (optimized for agentic coding and terminal tasks). Meta Llama 3.3 70B Instruct is a reliable general-purpose option with 131K context.

Q: Can I use Claude Code without any internet connection?

A: Yes — install Ollama, pull a local model (such as Qwen 2.5 Coder 7B or 32B), and set ANTHROPIC_BASE_URL to http://localhost:11434. Claude Code will run entirely on your machine with no network calls. You need at least 8 GB RAM for a usable coding model, and the model quality will be lower than Claude Sonnet — but there are zero rate limits, no API costs, and full privacy.

Q: Does using Claude Code with OpenRouter break Anthropic's terms of service?

A: No. Redirecting Claude Code to a custom API endpoint via ANTHROPIC_BASE_URL is a documented, supported feature — it exists for enterprise proxy, AWS Bedrock, and Google Vertex AI routing. Anthropic publishes the environment variable in their official CLI documentation. You are simply pointing the open-source agent shell at a different model provider. The agent code is open-source; you are free to run it with any backend you choose.

Q: How much does Claude Code cost if I do pay for it?

A: Anthropic's pricing as of mid-2026: Claude Pro is $20/month ($17/month billed annually), Claude Max 5x is $100/month (5x Pro usage), and Claude Max 20x is $200/month (20x Pro usage). Pay-as-you-go API billing is $3 per million input / $15 per million output tokens for Sonnet 4.6, and $5/$25 for Opus 4.6. A typical coding session uses 50,000–200,000 tokens, costing roughly $0.30–$1.00 per session on Sonnet. For a broader look at cutting your AI bill across an entire organization, see our enterprise AI token cost optimization guide.

Sources
  • Anthropic Claude Code GitHub Repository — open-source agent, 139K+ stars
  • Anthropic CLI Documentation — ANTHROPIC_BASE_URL — official env var docs
  • Anthropic Pricing — claude.com/pricing — Pro $20/mo, Max $100-200/mo
  • Anthropic API Pricing — platform.claude.com — Sonnet 4.6 $3/$15 MTok, Opus 4.6 $5/$25 MTok
  • OpenRouter Blog: How to Use Claude Code with OpenRouter — setup guide, Anthropic Skin, model routing
  • OpenRouter Free Models Collection — 28+ free models, August 2026
  • OpenRouter Free Tier Rate Limits — 50 req/day free, 1,000 after $10 credits
  • npm: @anthropic-ai/claude-code — v2.1.220, 7.8M weekly downloads
  • Claude Code Advanced Setup Docs — native installer, env var configuration
  • Codera: Claude Code Open Source Guide — build from source, BYOK, Bedrock/Vertex
Updates & Corrections
  • 2026-08-01 — Initial publication. Verified all pricing, model names, and environment variable names against primary sources (Anthropic docs, OpenRouter blog, npm registry). Free model list current as of August 2026; OpenRouter rotates models frequently — always check openrouter.ai/models before building.

Get the practical AI brief

Verified, no-hype AI tips you can actually use - in your inbox. Free.

No spam. We verify what we send. Unsubscribe anytime.

Tags

#AI coding#free-ai-tools#Developer Tools#"Claude Code"#"OpenRouter"

Discussion

0 comments
Sham

Sham

AI Engineer & Founder, The Tech Archive

AI engineer (Azure AI-102/AI-900). Writes practical, tested, hype-free guides on using AI for real work and small business at The Tech Archive.

Related Articles

View all
How to Set Up Google Antigravity 2.0 as an Agent Operating System (2026)
Artificial Intelligence

How to Set Up Google Antigravity 2.0 as an Agent Operating System (2026)

16 min
Macaron-V1: How Mixture-of-LoRA Turns One AI Model Into Four Specialists (2026)
Artificial Intelligence

Macaron-V1: How Mixture-of-LoRA Turns One AI Model Into Four Specialists (2026)

15 min
What Comes After RLHF? The Shift From AI Assistance to AI Automation (2026)
Artificial Intelligence

What Comes After RLHF? The Shift From AI Assistance to AI Automation (2026)

15 min
Gemma 4 QAT: How to Run Google's 1GB Local AI Model on Any Device (2026)
Artificial Intelligence

Gemma 4 QAT: How to Run Google's 1GB Local AI Model on Any Device (2026)

14 min
Why Data Quality Is the Compute Multiplier AI Builders Are Missing in 2026
Artificial Intelligence

Why Data Quality Is the Compute Multiplier AI Builders Are Missing in 2026

15 min
AI Agent Post-Training in 2026: How Models Learn Skills on the Job
Artificial Intelligence

AI Agent Post-Training in 2026: How Models Learn Skills on the Job

16 min