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.

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:
- Open the API key section.
- Create a new API key.
- Give the key a recognizable name.
- Copy the generated key.
- 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:
- Finds your home directory.
- Opens
.claude.jsonif it exists. - Parses the existing JSON.
- Adds or updates
hasCompletedOnboarding. - 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.