Claude Code
A tour of all choices, all errors, and all ideas that made sense.

One afternoon I was trying to get Claude Code to run without having to pay an Anthropic subscription. What was initially going to be a 20-minute task, eventually became a nightmare of going up the WSL internals, Python version errors, PowerShell profile quirks, and bash path escaping nightmares.
This is the article I would have desired prior to my commencement.
By that point, I had a fully operational setup: Claude Code CLI running in VS Code, powered by Gemini 2.5 Flash as a free backend, with a clean bash terminal, a single .env file as the source of truth, and a setup that is ready to build agentic AI systems right out of the box.
This is how it actually works and why all these decisions were taken.
What Claude Code is at All?
Anthropic has an AI coding assistant called Claude Code – a CLI and an extension of VS Code (and other code editors) that allows you to provide natural language instructions and have an AI agent write, edit and explain code in your project. Imagine it like a pair programmer that resides in your terminal.
The snag:
it is set to operate with an Anthropic subscription or API billing. By default, it will request you to log in and pay.
But the most important thing that can make everything possible is the following:
Claude Code is simply a client which talks to the Anthropic API format. You can send it back to any LLM which is capable of interpreting that format.
Instead, Claude Code will communicate with Gemini, Ollama, or whatever other compatible backend set by three environment variables ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, and ANTHROPIC_MODEL.
The Free (and Which One Works Without a Card) Options.
I laid out all the possible free options before deciding on a course of action:
Ollama (local) — Free forever and ever, executes models on your machine. The snag: it requires heavy hardware. The realistic RAM of models good enough to actually assist in coding is 32GB+. This did not make the cut with me, with no dedicated VRAM and a 128MB GPU.
OpenRouter through claude-code-router — Choose among a rotating selection of free models (DeepSeek R1, Qwen, Llama) without any credit card. Free accounts receive 50 requests/day; increase the use of the account by adding $10 in credits and the limit increases to 1,000. A little more installation than Google AI Studio, but it is worth it in case you desire model variety. I simply opted to use Gemini because it is simple.
Ollama Cloud architecture – Ollama has now implemented Ollama cloud variants, which do not run on your computer, but rather on theirs. Still needs Ollama installed as the client/proxy.
Google AI Studio (Gemini) = Free version, only a Google account. No credit card. No minimum top-up. You can create an API key and get an API key at aistudio.google.com, where you can sign in.
Winner: Google AI Studio. Gemini 2.5 Flash can, the free version is generous, and there is no barrier to entry.

The Installation: A Mistake I Made.
I added the VS Code extension of Claude Code and thought that I was finished. I wasn’t.
There is a difference between the Claude Code VS Code extension and the CLI.
VS Code extension is a UI panel – a sidebar, keyboard shortcuts, a more pleasant interaction. It does not do anything in itself. The actual engine is the CLI, installed via npm:
npm install -g @anthropic-ai/claude-code
The -g flag is installed worldwide. Now execute it, and it can be executed anywhere, and claude will be both in every terminal on your computer. This does not need to be run within your project folder.
Verify it worked:
claude –version
Note: Claude Code just changed its npm use to a native installer and will present a deprecation warning. By the time of this writing, a known bug is that the native installer stalls in the integrated terminal of VS Code in Windows. In the meantime, keep with the npm install.
Gesturing Claude Code to Gemini.
Once the CLI is installed, the next step is to redirect CLI away to paid API of Anthropic. It is accomplished purely via environment variables – no code modifications, no configuration files to track down
The three variables you need:
ANTHROPIC_API_KEY=AIza-YOUR-GEMINI-KEY-HERE
ANTHROPIC_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
ANTHROPIC_MODEL=gemini-2.5-flash
Get your free Gemini API key from aistudio.google.com — takes about 30 seconds.
The First-Run Login Screen Problem
Here’s something the docs don’t mention clearly: on first run, Claude Code shows a login screen even when these variables are set. It wants to authenticate with Anthropic.
The workaround: temporarily add a fourth variable:ANTHROPIC_AUTH_TOKEN=AIza-YOUR-GEMINI-KEY-HERE
Same key, different variable name. This makes Claude Code detect it as a “custom API key” and ask if you want to use it — select Yes. Once your session is established, remove ANTHROPIC_AUTH_TOKEN. Keeping both variables causes a conflict warning on subsequent runs.
One .env File, Not Hardcoded Anywhere
Putting API keys directly in shell configs or VS Code settings is a bad habit. The right approach: a single .env file at your project root, loaded automatically.
ANTHROPIC_API_KEY=AIza-YOUR-GEMINI-KEY-HERE
ANTHROPIC_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
ANTHROPIC_MODEL=gemini-2.5-flash
To auto-load it whenever a terminal opens, add a Load-Env function to your PowerShell profile. Open it with:
notepad $PROFILE
Then paste:
function Load-Env {
$envFile = Join-Path (Get-Location) ".env"
if (Test-Path $envFile) {
Get-Content $envFile | ForEach-Object {
if ($_ -match "^\s*([^#][^=]+)=(.+)$") {
[System.Environment]::SetEnvironmentVariable(
$matches[1].Trim(),
$matches[2].Trim(),
"Process"
)
}
}
Write-Host ".env loaded" -ForegroundColor Green
} else {
Write-Host ".env file not found at: $envFile" -ForegroundColor Red
}
}
Load-Env
One of its gotchas:
VS Code has its own PowerShell profile, independent of the normal PowerShell terminal. Always open notepad $PROFILE inside the integrated terminal of VS Code, and not on its own PowerShell window. They indicate various files.