{"slug": "a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc", "title": "A step-by-step guide to running Claude Code for free using AgentRouter and IAMHC APIs", "summary": "A developer published a step-by-step guide to running Claude Code for free using alternative API endpoints from AgentRouter and IAMHC. The guide covers installation, configuration, and troubleshooting on multiple platforms, bypassing the need for a Claude Pro subscription or official Anthropic API keys.", "body_md": "A comprehensive, step-by-step guide to installing, configuring, and running **Claude Code** on PC, Linux, macOS, and Termux using alternative API endpoints.\n\n[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)\n\nClaude 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.\n\n| Feature | Provider A: AgentRouter | Provider B: IAMHC |\n|---|---|---|\nReferral Link |\nYes (\n|\n\n[IAMHC Link](https://api.iamhc.cn/))**Featured Models**`claude-opus-4-8`\n\n`DeepSeek-V4-Pro`\n\n, `glm-5.2`\n\n, `Qwen3-Coder-Next-FP8`\n\n, etc.**Free Balance / Quota****Base URL**`https://agentrouter.org`\n\n`https://api.iamhc.cn/v1`\n\n- Choose one of the providers from the list below and open the link:\n**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/)\n\n- Sign up / Register an account using your GitHub account or Email.\n- Navigate to the\n**API Key** or**Token** menu. - Generate a new API Key and copy it.\n\nInstall Node.js on your system if you haven't already. Then run the appropriate command to install Claude Code:\n\nIt is recommended to use version `2.1.112`\n\nfor optimal compatibility:\n\n```\nnpm install -g @anthropic-ai/claude-code@2.1.112\n```\n\nYou can install the latest version:\n\n```\nnpm install -g @anthropic-ai/claude-code\n```\n\nOpen the Claude Code settings file using a text editor (e.g., `nano`\n\n):\n\n```\nnano ~/.claude/settings.json\n```\n\nReplace the contents of the file with one of the configuration templates below, depending on the provider you selected in Step 1.\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_API_KEY\",\n    \"ANTHROPIC_BASE_URL\": \"https://agentrouter.org\",\n    \"ANTHROPIC_MODEL\": \"claude-opus-4-8\",\n    \"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC\": \"1\"\n  },\n  \"permissions\": {\n    \"allow\": [],\n    \"deny\": []\n  },\n  \"skipWorkflowUsageWarning\": true\n}\n{\n  \"env\": {\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_API_KEY\",\n    \"ANTHROPIC_BASE_URL\": \"https://api.iamhc.cn/v1\",\n    \"ANTHROPIC_MODEL\": \"DeepSeek-V4-Pro\",\n    \"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC\": \"1\"\n  },\n  \"permissions\": {\n    \"allow\": [],\n    \"deny\": []\n  },\n  \"skipWorkflowUsageWarning\": true\n}\n```\n\nImportant\n\n- Replace\n`YOUR_API_KEY`\n\nwith the API Key/Token you generated from the respective provider. **Available models for Provider A (AgentRouter)**:`claude-opus-4-8`\n\n(Default in template)`claude-opus-4-7`\n\n`claude-opus-4-6`\n\n`glm-5.2`\n\n`gpt-5.5`\n\n- You can replace\n`ANTHROPIC_MODEL`\n\nin Template A with any of the exact model IDs listed above.\n\n**Available models for Provider B (IAMHC)**:`DeepSeek-V4-Pro`\n\n(Default in template)`DeepSeek-V4-Flash`\n\n`glm-5.2`\n\n`glm-5.1`\n\n`glm-4.7`\n\n`Qwen3-Coder-Next-FP8`\n\n`Kimi-K2.6`\n\n`MiniMax-M3`\n\n`MiniMax-M2.7`\n\n`kat-coder-pro-v2`\n\n- You can replace\n`ANTHROPIC_MODEL`\n\nin Template B with any of the exact model IDs listed above.\n\n- Setting\n`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`\n\nto`\"1\"`\n\nhelps reduce unnecessary network traffic and telemetry.\n\n- Press\n`CTRL + X`\n\nto exit. - Press\n`Y`\n\nto confirm changes. - Press\n`ENTER`\n\nto save the file.\n\nSimply run:\n\n```\nclaude\n```\n\nIf the configuration is correct, the Claude Code terminal interface will start up successfully!\n\nIf you recently updated Claude Code and encounter errors or compatibility issues with the custom API endpoints, revert/pin to the recommended version using:\n\n```\nnpm install -g @anthropic-ai/claude-code@2.1.112\n```\n\nDouble check that `ANTHROPIC_BASE_URL`\n\ncontains the correct protocol (`https://`\n\n) and that your API key is correctly copied without leading or trailing spaces.", "url": "https://wpnews.pro/news/a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc", "canonical_source": "https://gist.github.com/kyiov/f35dbbf204195fbf249837f3c488678d", "published_at": "2026-07-11 10:26:57+00:00", "updated_at": "2026-07-11 12:51:49.624110+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-tools"], "entities": ["Claude Code", "Anthropic", "AgentRouter", "IAMHC", "Node.js"], "alternates": {"html": "https://wpnews.pro/news/a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc", "markdown": "https://wpnews.pro/news/a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc.md", "text": "https://wpnews.pro/news/a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc.txt", "jsonld": "https://wpnews.pro/news/a-step-by-step-guide-to-running-claude-code-for-free-using-agentrouter-and-iamhc.jsonld"}}