> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-staging.joytokens.ai/llms.txt.

# Claude Code

> 使用 Claude Code 接入 JoyToken

## 前提条件

| 项目                | 值                                            |
| ----------------- | -------------------------------------------- |
| 命令                | `claude`                                     |
| 模型                | `auto`（不可配置）                                 |
| JoyToken Base URL | `https://api-staging.joytokens.ai/anthropic` |
| API Key 环境变量      | `ANTHROPIC_API_KEY`                          |

## 配置

把 `sk-xxx` 替换成你的 JoyToken API Key：

```bash
export ANTHROPIC_BASE_URL="https://api-staging.joytokens.ai/anthropic"
export ANTHROPIC_API_KEY="sk-xxx"
```

## 启动

```bash
cd /path/to/your/project
claude --model auto
```

## 验证

```bash
claude --model auto -p "Reply with exactly: pong"
```

成功时，输出包含 `pong`。

## 常见错误

| 错误                  | 处理方式                                           |
| ------------------- | ---------------------------------------------- |
| `401 Unauthorized`  | 检查 `ANTHROPIC_API_KEY` 是否为有效的 JoyToken API Key |
| Claude Code 调用了其他地址 | 检查当前 shell 是否已设置 `ANTHROPIC_BASE_URL`          |
| 模型不存在               | 使用 `--model auto` 启动 Claude Code               |

## 相关资源

* [Claude Code LLM Gateway 配置](https://code.claude.com/docs/en/llm-gateway)
* [JoyToken 环境](/zh/user-guide/environments)