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

# Claude Code

> Anthropic's terminal AI coding assistant

Claude Code is a command-line AI coding assistant developed by Anthropic. Connect it to QwenCloud via Token Plan (Personal Edition), Token Plan (Team Edition), or pay-as-you-go billing.

## Install Claude Code

<Tabs>
  <Tab title="macOS">
    1. Install or update [Node.js](https://nodejs.org/en/download/) (v18.0 or later).

    2. Run the following command in the terminal to install Claude Code.

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

    3. Run the following command to verify the installation. If a version number is displayed, the installation is successful.

    ```bash
    claude --version
    ```
  </Tab>

  <Tab title="Windows">
    To use Claude Code on Windows, install WSL or [Git for Windows](https://git-scm.com/install/windows), then run the following command in WSL or Git Bash.

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

    <Note>
      For more details, see the [Windows setup guide](https://docs.anthropic.com/en/docs/claude-code/setup#windows-setup) in the official Claude Code documentation.
    </Note>
  </Tab>
</Tabs>

### Skip login verification

Edit or create `~/.claude.json` (Windows path: `C:\Users\<username>\.claude.json`), and set `hasCompletedOnboarding` to `true` to skip the official Anthropic login verification.

```json
{
  "hasCompletedOnboarding": true
}
```

## Configure access credentials

Create `~/.claude/settings.json` (Windows path: `C:\Users\<username>\.claude\settings.json`), and add the corresponding configuration based on your selected plan.

### Token Plan (Personal Edition)

Replace YOUR\_API\_KEY with the Token Plan (Personal Edition) dedicated [API Key](https://home.qwencloud.com/api-keys). Available models: qwen3.8-max, qwen3.8-flash, qwen3.7-max, qwen3.7-plus, qwen3.6-flash, glm-5.2, deepseek-v4-pro, deepseek-v4-flash-0731. For details, see [supported models](/token-plan/personal/token-plan-personal-overview#supported-models) for Token Plan (Personal Edition).

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://token-plan.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "auto",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-flash",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-max",
    "CLAUDE_CODE_SUBAGENT_MODEL": "auto",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
  }
}
```

<Note>
  **qwen3.8-max thinking mode**:

  - **thinking**: Supports both enabled and disabled (hybrid thinking mode).
  - **temperature**: Defaults to 0.6 in thinking mode. Values below 0.6 are automatically adjusted to 0.6.
  - **reasoning\_effort**: Controls reasoning depth. Options: xhigh, medium, low. Default: xhigh.
</Note>

### Token Plan (Team Edition)

Replace YOUR\_API\_KEY with the Token Plan (Team Edition) dedicated [API Key](https://home.qwencloud.com/api-keys). For available models, see [supported models](/token-plan/team/token-plan-team-overview#supported-models) for Token Plan (Team Edition).

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://token-plan.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "auto",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-flash",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-max",
    "CLAUDE_CODE_SUBAGENT_MODEL": "auto",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
  }
}
```

<Note>
  **qwen3.8-max thinking mode**:

  - **thinking**: Supports both enabled and disabled (hybrid thinking mode).
  - **temperature**: Defaults to 0.6 in thinking mode. Values below 0.6 are automatically adjusted to 0.6.
  - **reasoning\_effort**: Controls reasoning depth. Options: xhigh, medium, low. Default: xhigh.
</Note>

### Pay-as-you-go

Replace YOUR\_API\_KEY with your [QwenCloud API Key](https://home.qwencloud.com/api-keys). For available models, see [Anthropic API compatible](/api-reference/chat/anthropic).

The following uses the Singapore (ap-southeast-1) endpoint. For another region, replace ap-southeast-1 and use an API key from that region. See [Regions and endpoints](/developer-guides/getting-started/regions).

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.7-max",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-max",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-max",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-max"
  }
}
```

### Configure Context Window Size

Claude Code uses a 200K context window by default. To handle large codebases or long conversations, you can expand the context window to 1M (1,000,000 tokens), provided the model supports that context length. Two configuration methods are available:

**Method 1: Set via environment variable**

Add `CLAUDE_CODE_MAX_CONTEXT_TOKENS` to the `env` field in `~/.claude/settings.json`:

The following uses the Singapore (ap-southeast-1) endpoint. For another region, replace ap-southeast-1 and use an API key from that region. See [Regions and endpoints](/developer-guides/getting-started/regions).

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.7-plus",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000"
  }
}
```

**Method 2: Use a model name suffix**

Append `[1m]` to the model name. This works with QwenCloud models that support a 1M context window:

The following uses the Singapore (ap-southeast-1) endpoint. For another region, replace ap-southeast-1 and use an API key from that region. See [Regions and endpoints](/developer-guides/getting-started/regions).

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.7-plus[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-plus[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-plus[1m]",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-plus[1m]"
  }
}
```

After modifying the configuration, open a new terminal window to restart Claude Code for the changes to take effect. For more environment variable details, see the [Claude Code official environment variables documentation](https://code.claude.com/docs/en/env-vars).

## Permission modes

Claude Code provides six permission modes that control whether a confirmation prompt appears before a tool performs an operation. The following table describes the behavior of each mode.

| Mode                | Behavior                                                                           |
| ------------------- | ---------------------------------------------------------------------------------- |
| `default`           | Prompts for confirmation before every operation.                                   |
| `acceptEdits`       | Approves file edits automatically. Other operations still prompt for confirmation. |
| `plan`              | Read-only planning mode. No changes are executed.                                  |
| `dontAsk`           | Does not prompt. An operation that would require a prompt is rejected directly.    |
| `bypassPermissions` | Bypasses all permission checks.                                                    |
| `delegate`          | Delegated mode.                                                                    |

### Command-line flag

Use `--permission-mode` to set the default permission mode for a session:

```bash
claude --permission-mode plan
claude --permission-mode acceptEdits
```

### Interactive command

Enter `/permissions` in a session to manage pre-approve and pre-deny rules for tools dynamically. You can configure auto-approval rules for the bash, edit, and MCP tools.

### settings.json configuration

Configure the `permissions` field in `~/.claude/settings.json` (Windows path: `C:\Users\<username>\.claude\settings.json`), the same configuration file that holds your access credentials:

```json
{
  "permissions": {
    "allow": ["Bash(git:*)", "Read", "Edit"],
    "deny": ["Bash(rm:*)"],
    "defaultMode": "default"
  }
}
```

The `allow` field approves matching tool calls automatically, and the `deny` field rejects matching tool calls automatically. Both fields support wildcards. For example, `Bash(npm:*)` matches all commands that start with `npm`. The `defaultMode` field sets the default permission mode for the session, and accepts any of the modes listed in the preceding table.

## Use CC Switch

[CC Switch](https://github.com/farion1231/cc-switch) is a community open-source desktop GUI for managing multiple API keys or billing plans. Switch between providers with one click, without editing `settings.json` manually.

### Install CC Switch

- macOS: `brew tap farion1231/ccswitch && brew install --cask cc-switch`, or download the `.dmg` from [Releases](https://github.com/farion1231/cc-switch/releases).
- Windows: download the `.msi` installer or portable `.zip` from [Releases](https://github.com/farion1231/cc-switch/releases).
- Linux: on Arch, run `paru -S cc-switch-bin`; on other distributions, download `.deb`/`.rpm`/`.AppImage` from [Releases](https://github.com/farion1231/cc-switch/releases).

### Add a provider

1. In the CC Switch main interface, select Claude Code in the top icon bar (the orange star icon), then click **+** in the upper-right corner to open **Add New Provider**. Fill in the fields based on the table below, then click **Add**.

| Billing plan                  | Configuration                                                                                                                                                                                         |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Token Plan (Personal Edition) | Provider name: QwenCloud-Token Plan (Personal Edition)<br />API Key: [get from console](https://home.qwencloud.com/api-keys)<br />Endpoint: `https://token-plan.maas.qwencloudapi.com/apps/anthropic` |
| Token Plan (Team Edition)     | Provider name: QwenCloud-Token Plan (Team Edition)<br />API Key: [get from console](https://home.qwencloud.com/api-keys)<br />Endpoint: `https://token-plan.maas.qwencloudapi.com/apps/anthropic`     |
| Pay-as-you-go                 | Provider name: QwenCloud-Pay-as-you-go<br />API Key: [get from console](https://home.qwencloud.com/api-keys)<br />Endpoint: `https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic`             |

2. Expand **Advanced Options** to configure model mapping. Set the main model and the Haiku, Sonnet, and Opus default models to the [supported models](/token-plan/overview) for your plan. Example mapping:

   - Main model: `qwen3.7-max`
   - Haiku default model: `qwen3.6-flash`
   - Sonnet default model: `qwen3.7-max`
   - Opus default model: `qwen3.7-max`

3. Return to the main interface, click **Enable** next to the provider, then start a new Claude Code session for the configuration to take effect.

### Connect Claude Code Desktop

Claude Code Desktop (Claude Desktop) and the Claude Code CLI are two separate entry points, shown in CC Switch as the **Claude Code** and **Claude Desktop** panels respectively. The desktop app reaches QwenCloud through the CC Switch local gateway: CC Switch automatically writes both the gateway address and the auth token into the desktop configuration, so you **do not enter your QwenCloud API Key in the desktop app**. The QwenCloud API Key is entered only in the CC Switch provider configuration and is injected automatically when the local router forwards the request.

<Warning>
  Do not manually enter your QwenCloud API Key in the desktop app's third-party inference configuration. The token the desktop app uses to authenticate to the CC Switch local gateway (address `http://127.0.0.1:15721/claude-desktop`) is generated and written automatically by CC Switch; entering the QwenCloud API Key here fails authentication because the token does not match. Writing the desktop third-party configuration is currently supported only on macOS and Windows.
</Warning>

1. Install Claude Code Desktop from the [Claude download page](https://claude.ai/download).

2. In CC Switch, switch to the **Claude Desktop** panel from the app switcher on the left. If the entry is not shown, go to **Settings > General** and make sure Claude Desktop is not hidden under app visibility.

3. Add the QwenCloud provider: if you have already configured a QwenCloud provider in the **Claude Code** panel, click **Import existing providers from Claude Code** to reuse it; otherwise click **+** in the upper-right to add one. Because QwenCloud model IDs (such as `qwen3.7-max`) are not the three role IDs that Claude Desktop recognizes (`claude-sonnet-* / claude-opus-* / claude-haiku-*`), turn on **Needs model mapping** and map the Sonnet, Opus, and Haiku roles to the actual QwenCloud models to request (for example, Sonnet > qwen3.7-max).

4. Enable local routing: go to **Settings > Routing > Local Routing** and turn on **Show Routing Toggle on Main Page**; return to the Claude Desktop panel and turn on the **Claude Desktop local routing** switch. The default listen address is `127.0.0.1:15721`.

5. Click **Enable** on the provider card. CC Switch automatically writes the third-party inference configuration into Claude Code Desktop.

6. Keep CC Switch running, then **fully quit and restart** Claude Code Desktop for the changes to take effect. Select the configured model from the model menu to start using it.

## Claude Code IDE plugins

After completing the CLI configuration above, you can install the Claude Code plugin in your IDE, which directly reuses the configuration in `settings.json`.

### VS Code

1. Search for `Claude Code for VS Code` in the extension marketplace and install it.
2. Restart VS Code and click the icon in the upper-right corner to open Claude Code.
3. Type `/` in the dialog box, select General config, and set the model in Selected Model.

### JetBrains

1. Search for `Claude Code` in the extension marketplace and install it.
2. Restart the IDE and click the icon in the upper-right corner to start using it.

## FAQ

### Error codes

If you encounter errors during configuration, refer to the FAQ documentation for the corresponding billing plan:

- Pay-as-you-go: [Anthropic API compatible - Error codes](/api-reference/preparation/error-messages)
- Token Plan (Personal Edition): [Token Plan FAQ](/token-plan/personal/token-plan-personal-faq)
- Token Plan (Team Edition): [Token Plan (Team Edition) FAQ](/token-plan/team/token-plan-team-faq)

### Requests return 401 invalid\_api\_key

The API key type does not match `ANTHROPIC_BASE_URL`. QwenCloud provides multiple access methods, and each access method uses a different base URL and a dedicated API key.

| Access method             | Base URL                                                      | API key                                     |
| ------------------------- | ------------------------------------------------------------- | ------------------------------------------- |
| Pay-as-you-go             | `https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic` | QwenCloud API key (starts with `sk-`)       |
| Token Plan (Team Edition) | `https://token-plan.maas.qwencloudapi.com/apps/anthropic`     | Token Plan (Team Edition) dedicated API key |

Troubleshooting steps:

1. **Check the request URL.** Check `ANTHROPIC_BASE_URL` in `~/.claude/settings.json`.
2. **Confirm the API key type.** Using the table above, confirm that your API key type matches the base URL.
3. **Correct the configuration.** When you use a QwenCloud Pay-as-you-go API key, set `ANTHROPIC_BASE_URL` to `https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic`.

### After starting Claude Code, the interface displays "Unable to connect to Anthropic services"

This error indicates that Claude Code is attempting to connect to the official Anthropic service instead of the QwenCloud server, usually because the environment variables are not configured correctly or have not taken effect. Follow these steps to troubleshoot:

1. **Check the configuration**: After starting Claude Code, run the `/status` command and verify that the values of `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` correctly point to the QwenCloud address. If the output is empty or points to a non-QwenCloud address, check whether the `settings.json` configuration is correct.

2. **Verify hasCompletedOnboarding**: Check that `hasCompletedOnboarding` is set to `true` in the `~/.claude.json` file. Otherwise, Claude Code will attempt to connect to the official Anthropic service for login verification at startup.

3. **Reopen the terminal**: After modifying the configuration file, open a new terminal window and run the `claude` command for the configuration to take effect.

4. **Update Claude Code**: If the issue persists after all the steps above, the Claude Code version may be outdated. Run `npm install -g @anthropic-ai/claude-code@latest` to update to the latest version, then try again.

### CC Switch reports "No available model list endpoint found" when adding a provider

This message comes from the connectivity check CC Switch runs when saving a provider: it probes a model list endpoint (such as `/v1/models`) against the configured request URL. QwenCloud's Anthropic-compatible endpoint (ending in `/apps/anthropic`) only provides the messages endpoint `/v1/messages` and does not provide a model list endpoint, so the probe returns 404 and CC Switch reports "No available model list endpoint found".

**This message does not affect normal use of Claude Code and can be ignored.** Claude Code sends conversations through `/v1/messages`, and the models it uses are specified directly by the model mapping in CC Switch's **Advanced options**, without relying on auto-discovery from a model list endpoint. When the request URL and API Key are configured correctly, simply click **Enable** and start a new Claude Code session to chat normally.

If you still cannot chat, verify that the request URL ends in `/apps/anthropic` without an extra `/v1`, and that you have filled in the models supported by your plan in the model mapping under Advanced options.

### Model mapping in CC Switch returns AccessDenied

If model calls fail in Claude Code with an `AccessDenied` error (HTTP 403, code: `access_denied`) after you configure the model mapping, check whether the model is marked for upcoming deprecation on the QwenCloud [Model Marketplace](https://www.qwencloud.com/models). Models marked for upcoming deprecation still appear in the list, but API calls return 403 `AccessDenied`. Follow these steps:

1. **Check whether the model is marked for deprecation.** On the QwenCloud [Model Marketplace](https://www.qwencloud.com/models), search for the model you are using and check its status label.
2. **Switch to the latest available model.** Replace the legacy model (such as `qwen-coder-turbo-0919`) in the model mapping with the latest available model (such as `qwen3.7-plus`).
3. **Reconfigure the model mapping and test.** Update the model mapping under **Advanced options** in CC Switch, click **Enable**, and start a new Claude Code session to verify.

<Note>
  Pay attention to the model lifecycle. Models marked for upcoming deprecation on the QwenCloud Model Gallery may become unavailable at any time. You can check a model's availability status there.
</Note>
