Claude Code for FREE | No Ollama, No GPU, No $200/M Subscription Needed (OpenRouter Setup)
How to Use Claude Code for Free with OpenRouter
Introduction to Using Claude Code
- The video introduces a method to use Claude Code without the need for a Pro or Max plan by utilizing OpenRouter.
- It highlights the limitations of running local models through Ollama, which require high-end hardware and can be cumbersome to manage.
Advantages of OpenRouter
- OpenRouter allows users to access cloud-based models directly, eliminating the need for local hosting and complex setups.
- Users only need to configure a few environment variables, making it more accessible than local model management.
Setting Up OpenRouter
- To start, users must create an account on openrouter.ai and generate an API key in the settings section.
- There are two configuration methods: global setup via shell profile or project-specific setup using a JSON file.
Global vs. Project-Level Configuration
- For global configuration, users edit their shell profile to include four specific lines related to API keys and URLs.
- It's crucial that the anthropic API key line is explicitly empty; otherwise, it may conflict with OpenRouter settings.
Project-Specific Setup Instructions
- The project-level setup involves creating a
.Claudefolder in the project directory and adding asettings.local.jsonfile with necessary environment variables.
- This method keeps configurations isolated from other projects, ensuring no global changes affect different workspaces.
Exploring Free Model Options on OpenRouter
- Users can find free models by searching on openrouter.ai/models; many options are available from various providers like Nvidia and RCAI.
- A built-in router called
openrouter/freerandomly selects free models but lacks control over which model is used.
Popular Models for Coding Tasks
- The video discusses how actual usage data reveals popular models suitable for coding tasks based on token consumption metrics.
- Models like MiniMax M2.5 are highlighted as effective choices due to their performance in real-world applications.
Cost Considerations for Advanced Models
- Pricing details reveal that top-tier coding models like Claude Sonnet 4.6 have significant costs per million tokens, emphasizing budget considerations when selecting models.
Understanding Cost-Effective AI Model Usage
Cost Efficiency of Mid-Tier Models
- The affordable mid-tier models on OpenRouter cost under $2 for a million tokens in and out, making them economical for extensive use.
- Users can maximize the utility of these models without incurring significant expenses, especially during long sessions or when executing multiple requests.
Configuration Steps for Using Models
- To utilize a model, copy its ID from the OpenRouter page and add it as an environment variable in your settings file. Use "anthropic model" to set this variable.
- If issues arise with the initial key, users can try using "anthropic default sonnet model" as an alternative. Additionally, Claude Code's sub-agent model can be configured for specific tasks.
Demonstration of Model Functionality
- A demonstration is provided using VS Code where the project is set up with the OpenRouter key and selected model before starting a session by typing "Claude." This confirms successful connection through OpenRouter.
- Users can verify their connection status by running "/status," which displays the base URL and authentication token being utilized. Real-time request tracking is available via the OpenRouter activity dashboard.
Practical Application: Building a SaaS Landing Page
- The AI is tasked with creating a modern SaaS landing page that includes various sections like hero, features, pricing tiers, and footer while maintaining a clean design aesthetic with dark colors.
- The AI autonomously generates HTML and CSS files based on user prompts without requiring step-by-step instructions from the user, showcasing its capability to handle complex tasks efficiently.
Analyzing Session Costs
- After completing a session that involved setup confirmation and building a landing page, users can review detailed logs in their OpenRouter activity to see costs associated with each request made during that session.
- Even extensive coding sessions remain inexpensive; typically costing less than one dollar unless large-scale operations are performed—highlighting flexibility since users only pay for what they actually use without being locked into subscriptions.