> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aihubmax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code CLI

> Connect Claude Code CLI to AihubMax

## Overview

[Claude Code](https://docs.anthropic.com/en/docs/claude-code) is Anthropic's official command-line tool that brings Claude's intelligence directly into your terminal. It can understand your codebase, edit files, run commands, and help you build software faster.

By connecting Claude Code CLI to [AihubMax](https://api.aihubmax.com/console), you can access Claude's full capabilities through AihubMax's reliable API infrastructure — **direct network access from China**, **pay-as-you-go with no balance expiration**, and **transparent, traceable channels**.

<Info>
  We provide a dedicated endpoint optimized for Claude Code CLI. Use `https://api.aihubmax.com` as the Base URL for the best experience.
</Info>

## Prerequisites

<CardGroup cols={2}>
  <Card title="Node.js 18+" icon="node-js">
    Required for installing Claude Code via npm. [Download Node.js →](https://nodejs.org/en/download/)
  </Card>

  <Card title="Git" icon="git-alt">
    Git is required for Claude Code to function properly. [Download Git →](https://git-scm.com/downloads)
  </Card>

  <Card title="AihubMax API Key" icon="key">
    You need a valid AihubMax API Key. See the installation steps below for how to obtain one. [Go to AihubMax →](https://api.aihubmax.com/console)
  </Card>

  <Card title="Python (Optional)" icon="python">
    Some advanced features may require a Python environment. [Download Python →](https://www.python.org/downloads/)
  </Card>
</CardGroup>

After installation, open a terminal (PowerShell on Windows) to verify your environment:

```bash theme={null}
node -v
git --version
```

<Tip>
  **Windows users**: If you encounter errors running commands, open PowerShell as **Administrator** and run the following command, then select `A`:

  ```bash theme={null}
  Set-ExecutionPolicy RemoteSigned
  ```

  ![Windows Execution Policy Setting](https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260328203750072.png)
</Tip>

## Installation & Configuration

<Steps>
  <Step title="Step 1: Install Claude Code CLI">
    Choose your installation method based on your operating system:

    <Tabs>
      <Tab title="Windows (npm)">
        Open a **new** PowerShell window and run:

        ```bash theme={null}
        npm install -g @anthropic-ai/claude-code
        ```
      </Tab>

      <Tab title="macOS / Linux (Recommended)">
        ```bash theme={null}
        curl -fsSL https://claude.ai/install.sh | bash
        ```
      </Tab>

      <Tab title="macOS / Linux (npm)">
        ```bash theme={null}
        npm install -g @anthropic-ai/claude-code
        ```
      </Tab>
    </Tabs>

    Verify the installation:

    ```bash theme={null}
    claude --version
    ```
  </Step>

  <Step title="Step 2: Get Your API Key">
    Go to the [AihubMax Console](https://api.aihubmax.com/console) and complete the following:

    1. **Create an account**: Register at [api.aihubmax.com](https://api.aihubmax.com/console)
    2. **Create an API key**: On the API Keys page, click "Create Key"

    <Warning>
      When creating a key, you **must select the "Claude-Max" group**. This is the official channel dedicated to Claude Code for the best experience. Other groups may not support Claude Code or may have feature limitations.
    </Warning>
  </Step>

  <Step title="Step 3: Configure Environment">
    We recommend using **CC-Switch** for one-click configuration, or you can manually edit the configuration file.

    <Tabs>
      <Tab title="CC-Switch (Recommended)">
        [CC-Switch](https://github.com/farion1231/cc-switch/releases) is a configuration tool built for Claude Code that supports one-click API Key import.

        1. Download and install from [CC-Switch GitHub Releases](https://github.com/farion1231/cc-switch/releases):
           * **Windows**: Download `CC-Switch-xxxx-Windows.msi` and install
           * **macOS**: Download `CC-Switch-xxxx-macOS.dmg` and install
        2. Open the API Keys page in the AihubMax Console, and click the **"Import to CCS"** button to automatically complete the configuration

        ![Import to CC-Switch from AihubMax](https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260329003930220.png)
      </Tab>

      <Tab title="Settings File (Manual)">
        Create or edit the Claude Code settings file `~/.claude/settings.json` (Windows: `%USERPROFILE%\.claude\settings.json`):

        ```json theme={null}
        {
          "env": {
            "ANTHROPIC_AUTH_TOKEN": "sk-your-foxapi-api-key",
            "ANTHROPIC_BASE_URL": "https://api.aihubmax.com",
            "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
          }
        }
        ```
      </Tab>

      <Tab title="Environment Variables (Manual)">
        Add the following to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.):

        ```bash theme={null}
        export ANTHROPIC_AUTH_TOKEN="sk-your-foxapi-api-key"
        export ANTHROPIC_BASE_URL="https://api.aihubmax.com"
        export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
        ```

        After adding, run `source ~/.zshrc` (or the corresponding config file) to apply.
      </Tab>
    </Tabs>

    <Warning>
      The `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` setting is **required**. It prevents Claude Code from sending telemetry and other non-essential requests to Anthropic's servers. Without this setting, those requests will fail due to lacking an official API Key, which may cause errors.
    </Warning>
  </Step>

  <Step title="Step 4: Install VSCode Extension (Optional)">
    If you use VSCode, you can install the official extension for a better integrated experience:

    1. Download and install [VSCode](https://code.visualstudio.com/)
    2. Search for **Claude Code** in the extension marketplace. Make sure the author is **Anthropic**

    ![Verify the author is Anthropic](https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260328204844201.png)

    3. After installation, you'll see the Claude Code panel in the VSCode sidebar

    ![Claude Code panel in VSCode](https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260328204857007.png)

    <Tip>
      If the side panel doesn't appear, the environment variables may not be configured correctly, or your **AihubMax account may have insufficient balance**.
    </Tip>

    <div style={{display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px'}}>
      <img src="https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260329011614823.png" alt="Environment not configured or insufficient balance" />

      <img src="https://zdaif.oss-cn-hangzhou.aliyuncs.com/asset/img/pages/aihubmax/20260329011621373.png" alt="Panel after successful configuration" />
    </div>
  </Step>

  <Step title="Step 5: Start Using">
    Launch Claude Code in your project directory:

    ```bash theme={null}
    cd /path/to/your/project
    claude
    ```

    This opens an interactive session where you can chat with Claude about your codebase.

    You can also run one-off commands:

    ```bash theme={null}
    claude "Explain the architecture of this project"
    ```
  </Step>
</Steps>

## Verify the Connection

Run the following command to confirm Claude Code is correctly routing through AihubMax:

```bash theme={null}
claude "Hello, please confirm you are working properly."
```

If configured correctly, Claude will respond normally. If you see an error, check the [Troubleshooting](#troubleshooting) section below.

## Usage Examples

<AccordionGroup>
  <Accordion title="Explore a codebase">
    ```bash theme={null}
    claude "Give me an overview of this project's architecture"
    ```
  </Accordion>

  <Accordion title="Fix a bug">
    ```bash theme={null}
    claude "There's a bug in the login flow where users get redirected to a 404 page after authentication. Find and fix it."
    ```
  </Accordion>

  <Accordion title="Write tests">
    ```bash theme={null}
    claude "Write unit tests for the UserService class"
    ```
  </Accordion>

  <Accordion title="Refactor code">
    ```bash theme={null}
    claude "Refactor the database queries in src/repositories to use parameterized queries"
    ```
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Error: Authentication failed or 401 Unauthorized">
    * Double-check your `ANTHROPIC_AUTH_TOKEN` value. It should be your AihubMax API Key (starts with `sk-`).
    * Ensure your API key has not expired and has sufficient balance.
    * Verify the key has access to Claude models on your AihubMax account.
  </Accordion>

  <Accordion title="Error: Connection refused or timeout">
    * Verify `ANTHROPIC_BASE_URL` is set to `https://api.aihubmax.com` (no trailing slash).
    * Check your network connection and ensure you can reach `api.aihubmax.com`.
    * If you are behind a corporate proxy, ensure the proxy allows HTTPS traffic to `api.aihubmax.com`.
  </Accordion>

  <Accordion title="Claude Code still tries to connect to Anthropic directly">
    * Make sure `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is set to `1`.
    * If using `settings.json`, ensure the JSON syntax is valid (no trailing commas, proper quoting).
    * Restart your terminal after making changes to environment variables or settings.
  </Accordion>

  <Accordion title="Settings file not taking effect">
    * Confirm the file is located at `~/.claude/settings.json` (not inside your project directory).
    * Validate the JSON format using a tool like `jq`:
      ```bash theme={null}
      cat ~/.claude/settings.json | jq .
      ```
    * Ensure there are no conflicting environment variables set in your shell profile that might override the settings file.
  </Accordion>
</AccordionGroup>

## Security Best Practices

<Note>
  * **Never commit your API key** to version control. If using environment variables, add them to your shell profile rather than project files.
  * **Use dedicated keys** when possible. AihubMax allows you to create multiple API keys — use a dedicated key for Claude Code so you can revoke it independently if needed.
  * **Monitor usage** on the AihubMax Console to detect any unexpected consumption.
</Note>
