> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/welcome/cn/ai-gateway/ai-gateway-integration/claude-code.md).

# Claude Code

将 Claude Code 与 AI 网关集成，可在简化配置和使用方式的同时，以统一且灵活的方式访问 Claude 系列模型。

你可以查看 [**帮助文档**](https://code.claude.com/docs/en/overview) 了解更多详情。

## 安装

使用 npm 全局安装 Claude Code：

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

在继续之前，请确保已正确安装 Node.js 和 npm。

## 配置

Claude Code 会从本地配置文件中读取运行时配置。

1. 打开（或创建）配置文件：

```bash
vim ~/.claude/settings.json
```

2. 添加如下配置，并将其中的值替换为你自己的 AI 网关信息：

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://gateway.theturbo.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxxxxxxxxxxxxx"
  }
}
```

* **ANTHROPIC\_BASE\_URL**\
  AI 网关暴露的、与 Claude 兼容的 API Endpoint。
* **ANTHROPIC\_AUTH\_TOKEN**\
  创建 AI 网关实例时生成的 API 密钥。

## 使用方式

完成配置后，你可以通过多种方式使用 Claude Code：

**启动交互式会话**

```bash
claude
```

**直接发送单条提示词**

```bash
claude "Explain the difference between HTTP and HTTPS."
```

所有请求都会通过 AI 网关进行路由，从而实现集中式的访问控制、日志记录和模型管理。
