Close Menu
  • AI Tools
    • Claude AI
    • ChatGPT
    • Cursor AI
    • GitHub Copilot
  • Programming
    • Python
    • JavaScript
    • Software Engineering
  • Web Development
    • HTML Tutorial
    • CSS Tutorial
    • Tailwind CSS
    • React JS
  • Roadmaps & Careers
    • Freelancing
  • About
  • Contact
Facebook X (Twitter) Instagram
Skill Trek
Facebook X (Twitter) Instagram Pinterest
  • AI Tools
    • Claude AI
    • ChatGPT
    • Cursor AI
    • GitHub Copilot
  • Programming
    • Python
    • JavaScript
    • Software Engineering
  • Web Development
    • HTML Tutorial
    • CSS Tutorial
    • Tailwind CSS
    • React JS
  • Roadmaps & Careers
    • Freelancing
  • About
  • Contact
Subscribe
Skill Trek
Home»AI Tools»Claude AI»How to Use Claude Code for Free with Agent Router API in VS Code
Claude AI

How to Use Claude Code for Free with Agent Router API in VS Code

Md Al MamunBy Md Al MamunSeptember 3, 2026No Comments8 Mins Read
Share Facebook Bluesky Threads Pinterest Twitter LinkedIn Tumblr Email
Follow Us
Google News Flipboard
Share
Facebook Bluesky Pinterest Threads Email Copy Link

Want to use Claude Code with powerful Claude models such as Claude Opus without paying for a separate Claude Code subscription?

In this tutorial, I’ll show you how to configure Claude Code in VS Code using the Agent Router API. We’ll connect Claude Code to Agent Router, configure the API credentials locally, and then start using Claude Code directly from your project terminal.

claude code free using agent router.

This tutorial is intended for educational purposes. The configuration shown here does not bypass or modify Claude Code’s official subscription system. Instead, it configures Claude Code to communicate with an API-compatible service using your own API credentials.

Important: API credits, supported models, pricing, and availability can change. Check Agent Router’s current terms and dashboard before using the service.

What You’ll Learn

By the end of this tutorial, you’ll know how to:

  • Install Claude Code
  • Create an Agent Router account
  • Get API credits
  • Generate an Agent Router API key
  • Configure Claude Code inside a VS Code project
  • Configure Claude Code’s local settings
  • Complete the local onboarding configuration
  • Start a Claude Code session from the terminal
  • Use Claude Code to build and modify projects

What Is Claude Code?

Claude Code is an AI coding agent that can work directly with your software projects.

Instead of copying individual files into a chatbot, you can run Claude Code from your project’s terminal and ask it to perform development tasks such as:

  • Understanding an existing codebase
  • Creating files
  • Modifying existing code
  • Debugging errors
  • Refactoring code
  • Writing tests
  • Adding features
  • Explaining unfamiliar code
  • Running development commands
  • Building complete applications

For example, instead of manually creating a React component, you could ask Claude Code:

Create a responsive dashboard page with a sidebar, navigation bar,
statistics cards, and a recent activity table.

Claude Code can inspect your project and work with the files directly.


What Is Agent Router?

Agent Router provides an API endpoint that can be used to access supported AI models through API credentials.

For this setup, we’ll configure Claude Code to send requests through Agent Router instead of directly using Anthropic’s API endpoint.

According to the setup described in this tutorial, Agent Router provides $175 in API credits for eligible/new accounts. The exact credit amount, eligibility requirements, supported models, and expiration terms may change, so verify the offer in your Agent Router account.


Before You Start

You’ll need:

  • VS Code
  • Node.js installed on your computer
  • A Claude Code installation
  • An Agent Router account
  • An Agent Router API key
  • A project you want to work on

We’ll use macOS/Linux commands as well as Windows PowerShell commands where necessary.


Step 1: Install Claude Code

The first step is to install Claude Code on your computer.

Open your terminal and install Claude Code using the currently recommended installation method from the official Claude Code documentation.

After installation, verify that the claude command is available:

claude

If Claude Code starts successfully, you’re ready for the next step.

You can also check whether the command is available with:

claude --version

If the command isn’t recognized, make sure Claude Code is installed correctly and that its executable is available in your system PATH.


Step 2: Create an Agent Router Account

Next, create an account on Agent Router.

After signing up and completing any required verification, open your Agent Router dashboard.

Depending on the current promotion and account eligibility, you may receive API credits that can be used with supported models, including Claude models.

For example, the current offer described in this tutorial provides $175 of API credits for eligible users.

These credits are not the same thing as an official Claude subscription. They are API credits provided by the API service.


Step 3: Create an API Key

Once you’ve created your Agent Router account, you’ll need an API key.

From your Agent Router dashboard:

  1. Open the API key section.
  2. Create a new API key.
  3. Give the key a recognizable name.
  4. Copy the generated key.
  5. Store it securely.

Your API key will look something similar to:

sk-xxxxxxxxxxxxxxxxxxxxxxxx

Never publish your API key

Do not:

  • Put your API key on GitHub
  • Commit it to your repository
  • Include it in screenshots
  • Share it in YouTube videos
  • Paste it into blog posts
  • Put it directly into frontend JavaScript

Treat an API key like a password.

For this tutorial, we’ll use:

YOUR_AGENT_ROUTER_API_KEY

instead of exposing a real credential.


Step 4: Open Your Project in VS Code

Now open the project you want to work on in VS Code.

For example:

my-project/
├── src/
├── package.json
├── README.md
└── ...

Open the integrated terminal in VS Code.

You can use:

Terminal → New Terminal

Or use the keyboard shortcut provided by your operating system.


Step 5: Create the Claude Code Local Settings File

Inside your project, create the following directory:

.claude

Inside that directory, create:

settings.local.json

Your project should now look like:

my-project/
├── .claude/
│   └── settings.local.json
├── src/
├── package.json
└── README.md

The .claude/settings.local.json file will contain the environment configuration Claude Code needs for this setup.

Add the following configuration:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://agentrouter.org",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_AGENT_ROUTER_API_KEY",
    "ANTHROPIC_API_KEY": "",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}

Replace:

YOUR_AGENT_ROUTER_API_KEY

with your own Agent Router API key.

Why are we using these variables?

The important settings are:

ANTHROPIC_BASE_URL

This tells Claude Code which API endpoint to communicate with.

ANTHROPIC_AUTH_TOKEN

This provides the authentication credential for the API request.

ANTHROPIC_API_KEY

It’s left empty in this configuration because we’re using the authentication mechanism specified by the Agent Router setup.

CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY

This enables model discovery through the configured gateway.


Step 6: Configure Claude Code’s Local Onboarding State

There is another configuration file used by Claude Code:

~/.claude.json

The ~ represents your home directory.

The following command creates/sets the onboarding property on macOS/Linux:

echo '{"hasCompletedOnboarding": true}' > ~/.claude.json

However, this command overwrites the file if it already exists.

A safer approach is to update the existing JSON while preserving other properties:

node -e "const fs=require('fs'), path=require('path'), p=path.join(process.env.HOME, '.claude.json'); let data={}; try{data=JSON.parse(fs.readFileSync(p,'utf8'))}catch(e){} data.hasCompletedOnboarding=true; fs.writeFileSync(p, JSON.stringify(data, null, 2));"

This version:

  1. Finds your home directory.
  2. Opens .claude.json if it exists.
  3. Parses the existing JSON.
  4. Adds or updates hasCompletedOnboarding.
  5. Writes the configuration back to the file.

Windows PowerShell Configuration

If you’re using Windows with PowerShell, you can use:

echo '{"hasCompletedOnboarding": true}' > "$env:USERPROFILE\.claude.json"

Again, this simple command can overwrite an existing file.

The safer Node.js version is:

node -e "const fs=require('fs'), path=require('path'), p=path.join(process.env.USERPROFILE, '.claude.json'); let data={}; try{data=JSON.parse(fs.readFileSync(p,'utf8'))}catch(e){} data.hasCompletedOnboarding=true; fs.writeFileSync(p, JSON.stringify(data, null, 2));"

This preserves existing properties in .claude.json while setting:

{
  "hasCompletedOnboarding": true
}

Step 7: Start Claude Code

Now return to your VS Code terminal.

Make sure you’re inside your project directory.

Then run:

claude

Claude Code should start a session using the configuration you’ve created.

At this point, you can begin interacting with your project.

For example:

Analyze this project and explain its architecture.

Claude Code can inspect the project and provide an overview.

You could then ask:

Find the main authentication flow and explain how it works.

Or:

Add a dark mode toggle to this application.

Step 8: Start Building a Project

Now comes the fun part.

Instead of simply asking Claude questions, you can use Claude Code as an AI development agent.

For example, suppose you want to build a simple task management application.

You could start with:

Build a full-stack task management application.

Requirements:
- React frontend
- Node.js backend
- REST API
- Create, update, delete, and complete tasks
- Responsive UI
- Use clean project structure
- Add appropriate error handling
- Explain the changes you make

Claude Code can inspect the project, create the required files, implement features, and help you iterate on the application.

You can then continue with requests such as:

Add user authentication.

Then:

Add JWT-based authentication to the backend.

Then:

Create login and registration pages in the frontend.

And finally:

Run the tests and fix any errors you find.

This is where Claude Code becomes particularly useful: you can maintain an ongoing development conversation with your project rather than repeatedly copying code between an editor and a chatbot.

Important: Protect Your API Key

One of the most important things to understand when working with API-based AI tools is credential security.

If your .claude/settings.local.json contains your API key, don’t accidentally commit it to Git.

Add the local configuration to .gitignore if appropriate:

.claude/settings.local.json

You should also check your Git status before committing:

git status

And make sure your secret configuration isn’t included.

If an API key is accidentally exposed publicly, revoke it and generate a new one immediately.


Is This Bypassing Claude Code’s Official Subscription?

No.

The purpose of this configuration is to configure Claude Code to communicate with an API-compatible gateway using credentials from another API provider.

It does not provide a way to bypass, crack, or unlock a paid Claude subscription.

You’re using API credits provided by the configured API service.

The availability of specific Claude models depends on the provider, your account, credits, and the provider’s current policies.

Share. Facebook Pinterest Telegram Bluesky Threads Email Copy Link
Previous ArticleHow to Use DeepSeek v4 Flash Free in VS Code
Next Article How to Use Claude Code for Free using Ollama in VS Code
Md Al Mamun
  • Website
  • Facebook
  • X (Twitter)
  • Instagram
  • LinkedIn

a full-stack developer and educator with a community of over 144,000 learners across YouTube, Udemy, and Facebook. With years of hands-on experience in building modern web applications, I specialize in making complex topics easy to understand through clear, structured explanations and real-world examples.

Related Posts

How to Use Claude Code for Free using Ollama in VS Code

September 3, 2026

How to Get the Usage Limit and Token bar in Claude Code

August 25, 2026

How to Connect GitHub to Claude Code (Step-by-Step)

August 24, 2026

How to Use Canva with Claude: A Complete Beginner’s Guide

August 14, 2026

How to Set Up Omni Route with Claude Code

August 13, 2026
Add A Comment
Leave A Reply Cancel Reply

Recent Posts

  • How to Connect OpenCode to Roblox Studio Using MCP
  • How to Check Ubuntu Version: 3 Easy Methods
  • How to Install Ubuntu on VirtualBox in Windows 11
  • How to Use Claude Code for Free using Ollama in VS Code
  • How to Use Claude Code for Free with Agent Router API in VS Code

Recent Comments

No comments to show.

Archives

  • September 2026
  • August 2026

Categories

  • AI Tools
  • Claude AI
  • Google Antigravity
  • Programming
  • Roadmaps & Careers
Facebook X (Twitter) Instagram Pinterest
© 2026 SkillTrek. All Rights Preserved by Md Al Mamun.

Type above and press Enter to search. Press Esc to cancel.