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

> HTML 版本: https://runapi.ai/zh-TW/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-TW/docs/guides/authentication.md)建立一組標準 RunAPI API 金鑰。請勿將其提交至儲存庫。
* 從[模型目錄](https://runapi.ai/zh-TW/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-TW/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-TW/docs/guides/authentication.md)建立或輪換金鑰。
* **模型無法使用：** 請從[模型目錄](https://runapi.ai/zh-TW/models)複製正確的識別碼，然後開始新的工作階段。已恢復的工作階段可能會保留先前的模型。
* **請求使用了其他端點：** 請在變更環境變數後重新開啟終端機，並檢查是否存在優先順序更高的 Claude Code 設定。



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

## 後續步驟

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

---

## RunAPI 的更多內容

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

聯絡我們: contact@runapi.ai

## 結構化資料

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