---
title: "关于如何更改 Claude Code 使用的 API 密钥"
canonical_url: "https://yangqiuyi.com/blog/kai-fa/guan-yu-ru-he-geng-gai-claude-code-shi-yong-de-api-mi-yao"
---

> Index of every page on this site: [llms.txt](https://yangqiuyi.com/llms.txt)

# 关于如何更改 Claude Code 使用的 API 密钥

## 配置步骤

1. **编辑配置文件**

在 `~/.claude/settings.json` 中添加/编辑以包含：

```json
{
    "apiKeyHelper": "~/.claude/anthropic_key.sh"
}
```

1. **创建密钥脚本**

然后在 `~/.claude/anthropic_key.sh` 中：

```bash
echo "sk-........."
```

1. **设置权限**

赋予其可执行权限：

```bash
chmod +x ~/.claude/anthropic_key.sh
```

大功告成！

## 参考

- [https://www.reddit.com/r/ClaudeAI/comments/1jwvssa/comment/mtt0urz/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button](https://www.reddit.com/r/ClaudeAI/comments/1jwvssa/comment/mtt0urz/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)

## Sitemap

See the full [sitemap](https://yangqiuyi.com/sitemap.md) for all pages.
