# A step-by-step guide to running Claude Code for free using AgentRouter and IAMHC APIs

> Source: <https://gist.github.com/kyiov/f35dbbf204195fbf249837f3c488678d>
> Published: 2026-07-11 10:26:57+00:00

A comprehensive, step-by-step guide to installing, configuring, and running **Claude Code** on PC, Linux, macOS, and Termux using alternative API endpoints.

[Overview](https://gist.github.com/starred.atom#overview)[Step 1: Register an Account](https://gist.github.com/starred.atom#step-1-register-an-account)[Step 2: Install Claude Code](https://gist.github.com/starred.atom#step-2-install-claude-code)[Step 3: Configuration](https://gist.github.com/starred.atom#step-3-configuration)[Step 4: Running Claude Code](https://gist.github.com/starred.atom#step-4-running-claude-code)[Troubleshooting & Version Pinning](https://gist.github.com/starred.atom#troubleshooting--version-pinning)

Claude Code normally requires an active Claude Pro subscription or official Anthropic API keys. By routing requests through compatible third-party API proxy services, you can run Claude Code for free or at a significantly lower cost using alternative routing endpoints.

| Feature | Provider A: AgentRouter | Provider B: IAMHC |
|---|---|---|
Referral Link |
Yes (
|

[IAMHC Link](https://api.iamhc.cn/))**Featured Models**`claude-opus-4-8`

`DeepSeek-V4-Pro`

, `glm-5.2`

, `Qwen3-Coder-Next-FP8`

, etc.**Free Balance / Quota****Base URL**`https://agentrouter.org`

`https://api.iamhc.cn/v1`

- Choose one of the providers from the list below and open the link:
**AgentRouter (with referral - Get +$50 USD bonus):**[https://bit.ly/3Tf0TJj](https://bit.ly/3Tf0TJj)** IAMHC (no referral):**[https://api.iamhc.cn/](https://api.iamhc.cn/)

- Sign up / Register an account using your GitHub account or Email.
- Navigate to the
**API Key** or**Token** menu. - Generate a new API Key and copy it.

Install Node.js on your system if you haven't already. Then run the appropriate command to install Claude Code:

It is recommended to use version `2.1.112`

for optimal compatibility:

```
npm install -g @anthropic-ai/claude-code@2.1.112
```

You can install the latest version:

```
npm install -g @anthropic-ai/claude-code
```

Open the Claude Code settings file using a text editor (e.g., `nano`

):

```
nano ~/.claude/settings.json
```

Replace the contents of the file with one of the configuration templates below, depending on the provider you selected in Step 1.

```
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://agentrouter.org",
    "ANTHROPIC_MODEL": "claude-opus-4-8",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "permissions": {
    "allow": [],
    "deny": []
  },
  "skipWorkflowUsageWarning": true
}
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://api.iamhc.cn/v1",
    "ANTHROPIC_MODEL": "DeepSeek-V4-Pro",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "permissions": {
    "allow": [],
    "deny": []
  },
  "skipWorkflowUsageWarning": true
}
```

Important

- Replace
`YOUR_API_KEY`

with the API Key/Token you generated from the respective provider. **Available models for Provider A (AgentRouter)**:`claude-opus-4-8`

(Default in template)`claude-opus-4-7`

`claude-opus-4-6`

`glm-5.2`

`gpt-5.5`

- You can replace
`ANTHROPIC_MODEL`

in Template A with any of the exact model IDs listed above.

**Available models for Provider B (IAMHC)**:`DeepSeek-V4-Pro`

(Default in template)`DeepSeek-V4-Flash`

`glm-5.2`

`glm-5.1`

`glm-4.7`

`Qwen3-Coder-Next-FP8`

`Kimi-K2.6`

`MiniMax-M3`

`MiniMax-M2.7`

`kat-coder-pro-v2`

- You can replace
`ANTHROPIC_MODEL`

in Template B with any of the exact model IDs listed above.

- Setting
`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`

to`"1"`

helps reduce unnecessary network traffic and telemetry.

- Press
`CTRL + X`

to exit. - Press
`Y`

to confirm changes. - Press
`ENTER`

to save the file.

Simply run:

```
claude
```

If the configuration is correct, the Claude Code terminal interface will start up successfully!

If you recently updated Claude Code and encounter errors or compatibility issues with the custom API endpoints, revert/pin to the recommended version using:

```
npm install -g @anthropic-ai/claude-code@2.1.112
```

Double check that `ANTHROPIC_BASE_URL`

contains the correct protocol (`https://`

) and that your API key is correctly copied without leading or trailing spaces.
