<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prosper Doko on Medium]]></title>
        <description><![CDATA[Stories by Prosper Doko on Medium]]></description>
        <link>https://medium.com/@prosperdoko?source=rss-2762d721cdf5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QagZhGWRDV4wjtelUCaWHg.jpeg</url>
            <title>Stories by Prosper Doko on Medium</title>
            <link>https://medium.com/@prosperdoko?source=rss-2762d721cdf5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 10:13:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prosperdoko/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Use Claude Code for Free with OpenRouter (Step-by-Step Guide)]]></title>
            <link>https://medium.com/coding-nexus/how-to-use-claude-code-for-free-with-openrouter-step-by-step-guide-86592f6bd447?source=rss-2762d721cdf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/86592f6bd447</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[open-router]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[Prosper Doko]]></dc:creator>
            <pubDate>Mon, 11 May 2026 14:30:16 GMT</pubDate>
            <atom:updated>2026-05-18T03:26:54.703Z</atom:updated>
            <content:encoded><![CDATA[<p>A practical walkthrough for developers who want the full Claude Code experience without paying Anthropic token costs. Setup, real example, limitations, troubleshooting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81I4I6g2HTeZ-M-PWaNB2w.png" /><figcaption>AI generated</figcaption></figure><h3>Why This Setup Exists</h3><p>Claude Code has become one of the most useful coding tools available. It reads your project, edits files, runs commands, and reasons through tasks across multiple turns. The workflow is excellent. The bill, less so.</p><p>If you use Claude Code seriously, you’ve probably watched your Anthropic credits drain faster than expected, especially on prototyping work where most of what you’re asking the model to do is repetitive scaffolding.</p><p>There’s a way around this. Claude Code is built to talk to Anthropic’s API by default, but it reads a few environment variables on startup that let you redirect every request somewhere else. Combine that with OpenRouter, which exposes an Anthropic-compatible endpoint and hosts dozens of free open-source models, and you get the same CLI experience running on someone else’s infrastructure.</p><p>This guide walks through the full setup, shows a real coding task running on a free model, and lists the tradeoffs nobody mentions in the hype posts.</p><h3>How Claude Code Talks to Models</h3><p>Before the steps, a quick mental model of what’s actually happening.</p><p>Claude Code is a Node.js CLI installed via npm. When you run claude, it starts a session and sends your prompts (plus tool call results, file contents, and so on) to an API endpoint. By default that endpoint is api.anthropic.com, and the requests are authenticated with your Anthropic API key.</p><p>The CLI checks for these environment variables at startup:</p><ul><li>ANTHROPIC_BASE_URL — where to send requests</li><li>ANTHROPIC_AUTH_TOKEN — what credential to send</li><li>ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL — which model to use for each tier</li><li>CLAUDE_CODE_SUBAGENT_MODEL — which model to use for background sub-tasks</li></ul><p>Change those values, and Claude Code happily sends its requests to OpenRouter, which forwards them to whichever free model you picked. Everything else about the experience stays the same.</p><h3>What You Need Before Starting</h3><ul><li>Node.js 18 or newer</li><li>A terminal (macOS, Linux, or Windows with WSL)</li><li>An OpenRouter account (free signup, no card required)</li><li>About 10 minutes</li></ul><h3>Step 1: Install Claude Code</h3><p>Open your terminal and run:</p><pre>npm install -g @anthropic-ai/claude-code</pre><p>If you hit permission errors, do not use sudo. Instead, point npm at a folder you actually own:</p><pre>mkdir -p ~/.npm-global<br>npm config set prefix &#39;~/.npm-global&#39;<br>echo &#39;export PATH=&quot;$HOME/.npm-global/bin:$PATH&quot;&#39; &gt;&gt; ~/.zshrc<br>source ~/.zshrc</pre><p>Verify the install:</p><pre>claude --version</pre><p>If you see a version number, you’re good.</p><h3>Step 2: Create an OpenRouter API Key</h3><p>Go to <a href="https://openrouter.ai/">openrouter.ai</a> and sign up. Google login works fine.</p><p>Once you’re in, open the user menu in the top right and click <strong>Keys</strong>. Click <strong>Create Key</strong>, give it a name like claude-code-local, and copy the key it generates. It starts with sk-or-v1-.</p><p>A few things worth knowing:</p><ul><li>This key acts like a password. Don’t paste it into screenshots, GitHub issues, or anywhere public.</li><li>If you leak one by accident, revoke it from the Keys page and create a new one. Takes ten seconds.</li><li>You don’t need to add credit to use free models. But topping up even $10 raises your free-tier rate limits substantially, which becomes useful later.</li></ul><h3>Step 3: Pick a Free Model</h3><p>OpenRouter has a list of free models that’s worth browsing. Go to <a href="https://openrouter.ai/models">openrouter.ai/models</a> and filter for “free.”</p><p>Here are the ones that work best with Claude Code right now:</p><p>Model Slug Context Best For MiniMax M2.5 minimax/minimax-m2.5:free 196K Agentic coding, tool use Z.ai GLM 4.5 Air z-ai/glm-4.5-air:free 131K Fast agentic workflows OpenAI gpt-oss-120b openai/gpt-oss-120b:free 131K Reasoning-heavy work NVIDIA Nemotron 3 Super nvidia/nemotron-3-super:free 262K Large codebases inclusionAI Ring-2.6-1T inclusionai/ring-2.6-1t:free 262K Tool use, long tasks</p><p>The :free suffix matters. Without it, you&#39;ll get charged at the model&#39;s regular rate. Always copy the slug exactly as listed on OpenRouter.</p><p>For Claude Code specifically, the agent-tuned models (MiniMax M2.5, Ring-2.6–1T, GLM Air, gpt-oss-120b) tend to handle tool calls more reliably. The general models are fine for conversation but sometimes flub the structured format Claude Code expects when it asks the model to read a file or run a command.</p><p>If you want the most capable free option for coding, MiniMax M2.5 is currently the strongest pick. It scores 80% on SWE-Bench Verified and was specifically trained for agentic workflows like Claude Code. One important detail: when using it with Claude Code, MiniMax recommends keeping reasoning mode off for best performance. The default config below handles this correctly.</p><h3>Step 4: Create the Config File</h3><p>Claude Code reads configuration from ~/.claude/settings.json (global, all projects) or .claude/settings.local.json (per-project).</p><p>For most cases, the per-project file is the better choice. It lets you use different models for different projects and keeps the config out of your home directory.</p><p>In your project root:</p><pre>mkdir -p .claude<br>touch .claude/settings.local.json</pre><p>Open the file and paste this in:</p><pre>{<br>  &quot;env&quot;: {<br>    &quot;ANTHROPIC_BASE_URL&quot;: &quot;https://openrouter.ai/api&quot;,<br>    &quot;ANTHROPIC_AUTH_TOKEN&quot;: &quot;sk-or-v1-YOUR_KEY_HERE&quot;,<br>    &quot;ANTHROPIC_DEFAULT_OPUS_MODEL&quot;: &quot;minimax/minimax-m2.5:free&quot;,<br>    &quot;ANTHROPIC_DEFAULT_SONNET_MODEL&quot;: &quot;minimax/minimax-m2.5:free&quot;,<br>    &quot;ANTHROPIC_DEFAULT_HAIKU_MODEL&quot;: &quot;minimax/minimax-m2.5:free&quot;,<br>    &quot;CLAUDE_CODE_SUBAGENT_MODEL&quot;: &quot;minimax/minimax-m2.5:free&quot;<br>  }<br>}</pre><p>Replace sk-or-v1-YOUR_KEY_HERE with your actual OpenRouter key. Replace the model slug with whichever model you chose.</p><p>Now add the file to .gitignore so you don&#39;t commit your API key by accident:</p><pre>echo &quot;.claude/settings.local.json&quot; &gt;&gt; .gitignore</pre><p>This is not optional. Leaked API keys on GitHub get scraped by bots within minutes.</p><h3>Step 5: Log Out and Log Back In</h3><p>Claude Code caches the authentication session when it starts. If you’ve used claude before with your Anthropic account, that session is still active. Editing the config file does nothing until you force a fresh login.</p><p>If Claude Code is already running, type:</p><pre>/logout</pre><p>Then:</p><pre>/login</pre><p>If Claude Code isn’t running, just launch it:</p><pre>claude</pre><p>The login flow will pick up the new environment variables and authenticate against OpenRouter instead.</p><h3>Step 6: Test That It’s Working</h3><p>Inside Claude Code, send a simple message:</p><pre>What model are you running?</pre><p>You should get a response identifying the OpenRouter model. If it says it’s Claude (Sonnet, Opus, Haiku), the config didn’t load. Run /logout and /login again.</p><p>If you see a 401 Unauthorized error, check:</p><ul><li>No leading or trailing spaces in your API key in the JSON file</li><li>The key hasn’t been revoked from your OpenRouter dashboard</li><li>ANTHROPIC_BASE_URL has no trailing slash and no /v1 at the end</li></ul><p>If everything looks fine and it still fails, restart your terminal entirely. Some shells cache environment state in ways that aren’t obvious.</p><h3>What You Give Up</h3><p>This setup is genuinely useful, but it’s not a free replacement for paid Claude. Here’s the honest list of tradeoffs.</p><h3>Response Speed</h3><p>Free models run on shared infrastructure. Latency is unpredictable. A response that takes 3 seconds in the morning might take 30 seconds at 9 PM EST when US developers are all online. If you’re used to paid Claude’s snappy responses, the free tier will feel slow some days.</p><h3>Rate Limits</h3><p>OpenRouter caps free-tier requests per day per model. Typical limits sit between 50 and 200 requests, depending on the model and how much traffic it’s getting. You’ll hit them eventually if you use Claude Code intensively.</p><p>Two workarounds:</p><ul><li>Switch to a different free model when you hit the limit (limits are per-model)</li><li>Add a small credit balance to your OpenRouter account. Even $5 raises free-tier limits considerably, and you don’t actually spend the balance on free models.</li></ul><h3>Tool Call Reliability</h3><p>This is the biggest practical difference. Claude Code relies heavily on tool calls (reading files, running bash, editing code, searching). Anthropic’s models are trained extensively on this exact format. Open-source models sometimes produce malformed tool calls, especially the generalist ones.</p><p>Claude Code retries automatically, but you’ll occasionally see it get stuck in a loop or give up on a task that the paid model would have handled in one shot. The agent-optimized models (Ring, GLM Air, gpt-oss) handle this much better.</p><h3>Complex Multi-File Work</h3><p>For anything that requires the model to track state across 10+ files, reason about architecture, or perform a careful refactor, paid Claude still wins clearly. Free models lose the thread on long tasks. The best workflow is to use the free setup for everyday coding and switch back to paid Claude for the hard problems.</p><h3>Privacy</h3><p>Your prompts route through OpenRouter, then through whatever provider hosts the model. Read OpenRouter’s privacy docs and each model’s terms. Don’t send proprietary code, customer data, secrets, or anything sensitive through this setup.</p><h3>When This Setup Is Worth It</h3><p>This works well if you’re:</p><ul><li>Learning Claude Code and don’t want to commit to a subscription yet</li><li>Building side projects where occasional model weirdness doesn’t matter</li><li>In a region or budget where $20 a month is real money</li><li>Curious about how different open models compare inside an agent loop</li></ul><p>It’s not a good fit if you’re:</p><ul><li>Doing client work on deadlines that can’t afford failed turns</li><li>Working on code that legally can’t leave your infrastructure</li><li>Easily frustrated by the unpredictability of free-tier services</li></ul><h3>Troubleshooting Common Issues</h3><h3>“401 Unauthorized” or “Invalid API key”</h3><p>The OpenRouter key in your config is wrong, has been revoked, or has invisible whitespace around it. Open the JSON file, delete the key value, retype it carefully, save, and run /logout then /login.</p><h3>Claude Code identifies itself as a Claude model</h3><p>The config didn’t load. This is almost always because you didn’t restart the session. Run /logout and /login. If that doesn&#39;t work, fully quit your terminal and start a new one.</p><h3>Tool calls fail repeatedly</h3><p>Switch to an agent-tuned model. minimax/minimax-m2.5:free, inclusionai/ring-2.6-1t:free, and z-ai/glm-4.5-air:free handle tool calls much more reliably than generalist models. If you&#39;re already on one of those, try a different one to rule out a temporary provider issue.</p><h3>“Rate limit exceeded” errors</h3><p>You’ve hit the free-tier daily limit on your current model. Switch to a different free model in your config file and /logout then /login. Or top up your OpenRouter account with a small balance to raise the limits.</p><h3>Responses are extremely slow</h3><p>Free models share infrastructure. Peak hours are worse. If response times stay slow for over an hour, try a different free model. Some providers throttle harder than others during high traffic.</p><h3>How to revert to paid Claude</h3><p>Delete or rename .claude/settings.local.json, then /logout and /login. Claude Code will fall back to your normal Anthropic authentication.</p><h3>Key Takeaways</h3><ul><li>Claude Code reads environment variables that let you redirect every request to an Anthropic-compatible endpoint</li><li>OpenRouter exposes such an endpoint and offers a catalog of free open-source models</li><li>The full setup takes about 10 minutes and one config file</li><li>The /logout and /login step is essential. Most failures trace back to skipping it</li><li>Free models work well for everyday coding, scaffolding, and learning. They struggle on complex multi-file refactors and long reasoning chains</li><li>Keep paid Claude for serious work, use the free setup for the rest</li></ul><p>If you build something with this setup, drop the model you ended up using in the comments. The free model landscape changes fast, and what works best today might not be the right pick in six weeks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86592f6bd447" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-nexus/how-to-use-claude-code-for-free-with-openrouter-step-by-step-guide-86592f6bd447">How to Use Claude Code for Free with OpenRouter (Step-by-Step Guide)</a> was originally published in <a href="https://medium.com/coding-nexus">Coding Nexus</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>