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

# Claude Code 安装与配置

> 安装 Claude Code，并配置为使用吉吉API。

## 环境准备

<Info>
  * **系统要求**：macOS 13.0+、Windows 10 1809+、Ubuntu 20.04+、Debian 10+ 或 Alpine Linux 3.19+，内存 4 GB 以上
  * **Node.js**：使用官方安装脚本、Homebrew 或 WinGet 安装时不需要
  * **Git for Windows**：可选。安装后 Claude Code 使用 Git Bash 执行命令，否则使用 PowerShell
</Info>

## 安装

<Tabs>
  <Tab title="macOS">
    **方法一：官方安装脚本（推荐）**

    ```bash theme={null}
    curl -fsSL https://claude.ai/install.sh | bash
    ```

    官方脚本安装的版本会在后台自动更新。

    **方法二：Homebrew**

    ```bash theme={null}
    brew install --cask claude-code
    ```
  </Tab>

  <Tab title="Windows">
    **方法一：官方安装脚本（推荐）**

    在 PowerShell 中运行：

    ```powershell theme={null}
    irm https://claude.ai/install.ps1 | iex
    ```

    在 CMD 中运行：

    ```bat theme={null}
    curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
    ```

    <Tip>
      提示符以 `PS C:\` 开头的是 PowerShell，没有 `PS` 的是 CMD。不需要以管理员身份运行。
    </Tip>

    **方法二：WinGet**

    ```powershell theme={null}
    winget install Anthropic.ClaudeCode
    ```
  </Tab>

  <Tab title="Linux">
    **官方安装脚本（推荐）**

    ```bash theme={null}
    curl -fsSL https://claude.ai/install.sh | bash
    ```

    也可以通过 apt、dnf、apk 安装，参考 [官方文档](https://code.claude.com/docs/en/setup)。
  </Tab>
</Tabs>

安装完成后，**打开一个新的终端窗口**，确认安装成功：

```bash theme={null}
claude --version
```

## 创建 API Key

在 [API 密钥](https://www.jiji.cc/keys) 页面新建一个 Key，分组选择包含 Claude 模型的分组。详见 [快速开始](/quickstart)。

## 配置

编辑配置文件，文件不存在时新建：

* **macOS/Linux**：`~/.claude/settings.json`
* **Windows**：`C:\Users\你的用户名\.claude\settings.json`

```json settings.json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://www.jiji.cc",
    "ANTHROPIC_AUTH_TOKEN": "your-api-key-here",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

<Warning>
  将 `your-api-key-here` 替换为你的 API Key。请求地址**不要**加 `/v1`。
</Warning>

| 配置项 | 说明 |
| - | - |
| `ANTHROPIC_BASE_URL` | 吉吉API 请求地址 |
| `ANTHROPIC_AUTH_TOKEN` | 你的 API Key |
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | 关闭遥测、错误上报等非必要请求，减少国内网络下的连接报错。同时会关闭自动更新，需要定期运行 `claude update` |

<Note>
  如果 `settings.json` 中已有其他配置，只需把这三项合并进 `env`，不要覆盖整个文件。
</Note>

## 验证

在终端运行 `claude`，进入对话界面后输入 `/status`：

```bash theme={null}
claude
```

* `Anthropic base URL` 一行显示 `https://www.jiji.cc`，说明请求地址已生效
* `Auth token` 一行显示 `ANTHROPIC_AUTH_TOKEN`，说明 API Key 已生效

关闭 `/status` 后发送任意消息，能正常回复即配置完成。

## 在 VS Code 中使用

Claude Code 的 VS Code 扩展在登录检查时不读取 `~/.claude/settings.json`，需要在 VS Code 用户设置中单独配置。

<Steps>
  <Step title="打开用户设置">
    按 `Cmd+Shift+P`（Windows/Linux 为 `Ctrl+Shift+P`），运行 **Preferences: Open User Settings (JSON)**。
  </Step>

  <Step title="添加配置">
    ```json settings.json theme={null}
    {
      "claudeCode.disableLoginPrompt": true,
      "claudeCode.environmentVariables": [
        { "name": "ANTHROPIC_BASE_URL", "value": "https://www.jiji.cc" },
        { "name": "ANTHROPIC_AUTH_TOKEN", "value": "your-api-key-here" }
      ]
    }
    ```
  </Step>

  <Step title="重启 VS Code">
    重启后打开 Claude Code 面板即可使用。
  </Step>
</Steps>

<Warning>
  不要把 API Key 写进项目目录下的 `.claude/settings.json`，该文件通常会提交到代码仓库。
</Warning>

## 遇到问题

<Card title="Claude Code 常见问题" icon="circle-question" href="/claude-code/faq">
  安装、配置与错误排查
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.