---
title: Claude Code | RunAPI
description: 安裝 Claude Code，將其連接至 RunAPI，選擇模型，並驗證配置。
url: https://runapi.ai/zh-HK/docs/resources/tool-integrations/claude-code.md
canonical: https://runapi.ai/zh-HK/docs/resources/tool-integrations/claude-code
locale: zh-HK
---

> HTML 版本: https://runapi.ai/zh-HK/docs/resources/tool-integrations/claude-code
> 智能代理網站索引: https://runapi.ai/llms.txt

# Claude Code

## 概覽

Claude Code 是一款適用於終端的智能編碼工具。本指南
安裝 CLI，將其 Anthropic 相容請求指向 RunAPI，
選擇 RunAPI 模型並驗證連接。

## 開始之前

* 使用 [Claude Code 官方設定指南][1]所支援的平台。
* 依照[身份驗證指南](https://runapi.ai/zh-HK/docs/guides/authentication.md)建立標準 RunAPI API 金鑰。切勿將其提交至代碼庫。
* 從[模型目錄](https://runapi.ai/zh-HK/models)複製支援 Anthropic Messages 的模型識別碼。



[1]: https://code.claude.com/docs/en/setup

## 安裝

在 macOS、Linux 或 WSL 上使用官方原生安裝程式，然後確認
指令可正常使用：

```shell
curl -fsSL https://claude.ai/install.sh | bash
claude --version
```

如需 Homebrew、WinGet 及特定平台要求，請使用
[官方安裝指南][1]。



[1]: https://code.claude.com/docs/en/setup

## 配置 RunAPI

首次測試時，請在當前 shell 中匯出 Base URL、API 金鑰及模型：

```shell
export ANTHROPIC_BASE_URL=https://runapi.ai
export ANTHROPIC_API_KEY=YOUR_RUNAPI_API_KEY
export ANTHROPIC_MODEL=YOUR_RUNAPI_MODEL_ID
```

若要將這些值套用至您用戶的每個 Claude Code 會話，請將其置於 `~/.claude/settings.json` 中的 `env` 物件內：

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://runapi.ai",
    "ANTHROPIC_API_KEY": "YOUR_RUNAPI_API_KEY",
    "ANTHROPIC_MODEL": "YOUR_RUNAPI_MODEL_ID"
  }
}
```

請勿將真實金鑰存入 `.claude/settings.json`，該檔案用於可能被提交的專案設定。有關配置範圍及優先順序，請使用 [Claude Code 設定參考][1]。



[1]: https://code.claude.com/docs/en/settings

## 選擇模型

將 `YOUR_RUNAPI_MODEL_ID` 替換為[模型目錄](https://runapi.ai/zh-HK/models)中的確切識別符。`ANTHROPIC_BASE_URL` 用於變更請求的傳送目標，並不用於選擇模型。您亦可以 `claude
--model YOUR_RUNAPI_MODEL_ID` 啟動單次對話，或在對話期間執行 `/model`。

## 驗證

執行安裝及配置檢查，然後傳送一個簡短提示：

```shell
claude --version
claude doctor
claude
```

在 Claude Code 內，執行 `/status` 以確認已載入的設定及使用中的模型。對 `Describe this repository in one
sentence.` 的正常回應確認 RunAPI 連接正常運作。

## 疑難排解

* **找不到 `claude`：** 請重新開啟終端機並按照[官方安裝疑難排解][1]進行操作。
* **設定未載入：** 請使用 `claude doctor` 驗證 `~/.claude/settings.json`，然後使用 `/status` 檢查已載入的來源。
* **身份驗證失敗：** 請確認 `ANTHROPIC_API_KEY` 包含一個有效的 RunAPI 金鑰。請透過[身份驗證指南](https://runapi.ai/zh-HK/docs/guides/authentication.md)建立或輪換金鑰。
* **模型不可用：** 請從[模型目錄](https://runapi.ai/zh-HK/models)複製確切的識別碼，然後開始新的會話。已恢復的會話可能保留其先前的模型。
* **請求使用了另一個端點：** 請在更改環境變數後開啟新的終端機，並檢查是否存在優先級更高的 Claude Code 設定。



[1]: https://code.claude.com/docs/en/troubleshoot-install

## 後續步驟

使用 [LLM API 快速入門](https://runapi.ai/zh-HK/docs/guides/llm-api/quickstart.md) 了解協定行為，使用 [Anthropic Messages API 參考](https://runapi.ai/zh-HK/docs/api/anthropic/messages.md) 查看請求欄位。若要將 RunAPI 工具新增至 Claude Code，請繼續參閱 [MCP 概覽](https://runapi.ai/zh-HK/docs/resources/mcp.md)。

---

## RunAPI 的更多內容

- [首頁](https://runapi.ai/zh-HK/.md)
- [模型目錄](https://runapi.ai/zh-HK/models.md)
- [收費](https://runapi.ai/zh-HK/pricing.md)
- [服務商](https://runapi.ai/zh-HK/models)
- [文件](https://runapi.ai/zh-HK/docs/guides)
- [SDK](https://runapi.ai/zh-HK/sdk.md)
- [CLI](https://runapi.ai/zh-HK/cli.md)
- [MCP Server](https://runapi.ai/zh-HK/mcp.md)
- [Claude Code 與 Cursor](https://runapi.ai/zh-HK/claude-code-vs-cursor.md)
- [Cursor API 設定](https://runapi.ai/zh-HK/cursor-api-setup.md)
- [RunAPI 與 OpenRouter](https://runapi.ai/zh-HK/openrouter-alternative.md)
- [企業版](https://runapi.ai/zh-HK/contact.md)
- [聯絡](https://runapi.ai/zh-HK/contact.md)
- [條款](https://runapi.ai/zh-HK/terms.md)
- [私隱](https://runapi.ai/zh-HK/privacy.md)
- [智能代理網站索引](https://runapi.ai/llms.txt)

聯絡我們: contact@runapi.ai

## 結構化資料

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-HK",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-HK/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-HK",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-HKicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-HK",
    "@type": "TechArticle",
    "headline": "Claude Code",
    "description": "安裝 Claude Code，將其連接至 RunAPI，選擇模型，並驗證配置。",
    "url": "https://runapi.ai/zh-HK/docs/resources/tool-integrations/claude-code",
    "mainEntityOfPage": "https://runapi.ai/zh-HK/docs/resources/tool-integrations/claude-code"
  }
]
```
