
5 Settings for Building a $0/Month AI Development Environment with Claude Code × OpenRouter Free Models
- Claude
- AI
- OpenRouter
TL;DR
- You can use free models via OpenRouter simply by replacing Claude Code's ANTHROPIC_API_KEY
- You can instantly switch to Qwen3, Gemini Flash, Llama4, and other models with the claude --model flag
- Introducing three rotation strategies to avoid free-tier rate limits
- Monthly cost: $0 (when using only free models)
Background
The cost of AI coding assistants is becoming a significant expense for individual developers and small teams. Claude Code is powerful, but the typical setup involves a claude.ai Pro subscription ($20/month and up) plus pay-as-you-go API charges.
However, OpenRouter offers many free models with the :free suffix, such as google/gemini-flash-1.5-8b:free and qwen/qwen3-235b-a22b:free. Because Claude Code supports custom endpoint configuration, combining them enables a zero-cost AI development environment.
This article explains the actual setup procedure, model selection guidelines, and methods for dealing with rate limits.
Prerequisites
| Item | Version / Requirements |
|---|---|
| Claude Code | v1.x (npm: @anthropic-ai/claude-code) |
| Node.js | 18+ |
| OpenRouter account | Free registration (https://openrouter.ai) |
| OS | macOS / Linux / WSL2 |
1. Understand the Basic Structure of OpenRouter
OpenRouter is a proxy service that functions as an OpenAI-compatible API. The endpoints are as follows:
Free models have the :free suffix. As of May 2026, the major free models are as follows:
| Model ID | Features | Context |
|---|---|---|
| google/gemini-flash-1.5-8b:free | Fast, lightweight, and suited for code completion | 1M tokens |
| google/gemini-2.0-flash-exp:free | Gemini 2.0 series, multimodal | 1M tokens |
| qwen/qwen3-235b-a22b:free | Extremely large-scale, high-accuracy code generation | 128K tokens |
| meta-llama/llama-4-scout:free | Meta's latest model, with strong instruction-following capabilities | 512K tokens |
| mistralai/mistral-small-3.1-24b-instruct:free | Mistral, lightweight and low-latency | 128K tokens |
Note: Since free model availability may change, check the latest list at https://openrouter.ai/models?order=newest&supported_parameters=free .
2. Configuring a Custom Endpoint for Claude Code
Claude Code allows you to change the destination of the Anthropic API through environment variables.
2-1. Basic Settings (Append to the Shell Configuration File)
2-2. Verification
If a response is returned normally, the setup is complete.
2-3. Project-specific settings (using direnv)
If you want to use different models across multiple projects, direnv is useful:
3. Three limitations of free models and how to handle them
Free models have limitations. Be aware of them for practical use.
Limitation 1: Rate limits (RPM/RPD)
Free models often have limits of around 20 RPM (Requests Per Minute) and 200 RPD (Requests Per Day).
Solution: Shell wrapper with exponential backoff
Constraint 2: Context length limit
Qwen3-235b supports 128K tokens, but this may not be enough for large codebases.
Solution: Reduce context with .claudeignore
Simply placing this file in the project root allows Claude Code to automatically exclude the specified files.
Constraint 3: Model uptime
Free models may experience provider congestion depending on the time of day, resulting in more timeouts.
Solution: Model rotation script
4. Model Selection Guide by Use Case
Not all free models are equally capable. Using them according to their intended purposes will improve quality.
4-1. Code Completion and File Editing → Gemini Flash 1.5 8B
It responds quickly and is well suited for short code modifications at the sed/awk level. It is ideal for the “diff generation” task, which is called most frequently in Claude Code.
4-2. Design/architecture consultation → Qwen3-235B
High reasoning quality as a large-scale model. It is well suited to tasks requiring thought, such as “How should this code be redesigned?” and “What is the time complexity of this algorithm?”
4-3. Long-form code generation/complex refactoring → Llama 4 Scout
Its long context of 512K tokens is highly useful. It is well suited for use cases where it reads an entire repository and produces an “overall optimal refactoring plan.”
5. Automate model-selection hints with CLAUDE.md
If you place CLAUDE.md in the project root, Claude Code will read it when the session starts. Writing model-selection instructions there can help the AI itself choose an appropriate model.
Result: Cost comparison
| Configuration | Estimated monthly cost |
|---|---|
| Claude Pro + pay-as-you-go API | $20–$80 |
| Pay-as-you-go OpenAI GPT-4o (medium-scale use) | $15–$50 |
| OpenRouter free models only | $0 |
| OpenRouter free + paid models mixed | $1–$10 (pay only for important tasks) |
Summary
- Simply set ANTHROPIC_BASE_URL to https://openrouter.ai/api/v1, and Claude Code will run through OpenRouter
- Models with the :free suffix enable a fully functional AI development environment for ¥0 per month
- Handle rate limits with an exponential backoff wrapper and model rotation
- Use Gemini Flash (speed), Qwen3-235B (quality), and Llama4 (long-form text) according to your needs
- A hybrid strategy—falling back to paid models only for production use or important decisions—is the practical solution
As of 2026, free models have reached a practical level of quality and are comparable to paid models when generating boilerplate, adding tests, and performing small-scale refactoring. Start by trying them with just 10 minutes of setup.
Reference links
- Official OpenRouter documentation
- OpenRouter model list (free filter)
- Official Claude Code documentation
- Official direnv
✍️ Author of this article: Jimolab Co., Ltd.
Jimolab develops many AI-powered SaaS products based in Hachioji. The technical validation described in this article is also a byproduct of that development process.
- 🌐 Official website: https://locallab.jp
- 🔍 AI SEO optimization SaaS: lookupai.jp
- 📺 YouTube: @locallab_llc
- ✉️ Contact: info@locallab.jp
If you found this interesting, please also follow us on our various social media platforms!
Go to list of users who liked
Go to list of comments
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
