# Code Tools 使用教程

Code Tools 可以喺 Cherry Studio 入面直接啟動同管理多種 AI 編程 CLI 工具，例如 Claude Code、Qwen Code、Gemini CLI、OpenAI Codex、iFlow CLI、GitHub Copilot CLI、Kimi CLI 同 OpenCode。本教程以 Cherry Studio v1.9.9 為例，帶你完成一次完整配置。

***

### 操作步驟

#### 1. 確認 Cherry Studio 版本

請先確認 Cherry Studio 已升級到而家正式版。你可以前往 [客戶端下載](/docs/zhong-wen-fan-ti/cherry-studio/download.md)、[GitHub Releases](https://github.com/CherryHQ/cherry-studio/releases) 或者 [官方網站](https://cherryai.com.cn/download) 下載安裝包。

#### 2. 進入 Code Tools 界面

頂部導航模式：撳界面頂部嘅 `+` 號打開啟動台，然後撳 **Code**。

<figure><img src="/files/49d08d51b2ba6deeada4e11e23ca9a00612ae95f" alt=""><figcaption><p>撳頂部 + 打開啟動台</p></figcaption></figure>

<figure><img src="/files/2788e7e4b23f6b8a2cacceba9ab23e3dc885e043" alt=""><figcaption><p>喺啟動台入面撳 Code</p></figcaption></figure>

{% hint style="info" %}
左側導航模式下，可直接撳左側導航欄入面嘅 **Code** 按鈕進入呢個頁面。
{% endhint %}

#### 3. 選擇 CLI 工具

根據你嘅需求同手上持有嘅 API Key，揀一個要用嘅 Code Agent 工具。目前支援以下幾種：

* **Claude Code**
* **Qwen Code**
* **Gemini CLI**
* **OpenAI Codex**
* **iFlow CLI**
* **GitHub Copilot CLI**
* **Kimi CLI**
* **OpenCode**

<figure><img src="/files/06b23f6b1c25dd3e82efb38b7725da6c586f3eec" alt=""><figcaption><p>揀 Code Agent 工具</p></figcaption></figure>

#### 4. 選擇 Agent 調用嘅模型

喺模型下拉列表入面，揀同所選 CLI 工具兼容嘅模型。 *（詳細嘅模型兼容性說明，請參考下方嘅「重要注意事項」）*

<figure><img src="/files/2cbcbc0e83d5f6bfe39683b4d733967687d2d3c0" alt=""><figcaption><p>選擇模型</p></figcaption></figure>

#### 5. 指定工作目錄

撳 **選擇目錄** 按鈕，為 Agent 指定一個工作目錄。Agent 將會有權訪問呢個目錄下所有文件同子目錄，以便理解項目上下文、讀取文件同執行代碼。

<figure><img src="/files/d9eda3fa7d20c52cf4428695f5ed0a2ebd72a3b3" alt=""><figcaption><p>指定工作目錄</p></figcaption></figure>

#### 6. 設置環境變量

* **自動配置**：你喺第 4 步（模型）同第 5 步（工作目錄）入面嘅選擇，會自動生成相應嘅環境變量。
* **自定義添加**：如果你嘅 Agent 或項目需要其他特定嘅環境變量（例如 `PROXY_URL` 等），可以喺呢個區域自定義添加。

<figure><img src="/files/a60387e8281cbe7cca52cda382063b415783ced0" alt=""><figcaption><p>環境變量配置</p></figcaption></figure>

#### 7. 更新選項

* **內置可執行文件**：Cherry Studio 已整合上述 Code Agent 嘅可執行文件，通常唔需要手動安裝 CLI。
* **自動更新**：如果想 CLI 工具一直保持最新版本，可以剔選 **檢查更新並安裝最新版本**。剔選之後，每次啟動時程式都會聯網檢查並更新可執行工具包。

<figure><img src="/files/33299d9fcaa069052cdb18115a0e3645537d0ab2" alt=""><figcaption><p>更新選項</p></figcaption></figure>

#### 8. 啟動 Agent

所有配置完成後，撳 **啟動** 按鈕。Cherry Studio 會自動調用系統自帶嘅 Terminal（終端）工具，並喺入面載入好所有環境變量，然後運行你揀嘅 Code Agent。你而家可以喺彈出嘅終端窗口入面同 AI Agent 互動。

<figure><img src="/files/2e97de62aa2e6b9685a8c5a60989d5035914b72e" alt=""><figcaption><p>喺終端入面運行 Code Agent</p></figcaption></figure>

***

### 重要注意事項

1. **模型兼容性說明**：
   * **Claude Code**：需要揀支援 Anthropic API Endpoint 格式嘅模型。優先使用 Claude 系列模型；部分官方平台亦都會提供 Claude Code 兼容模型，具體以模型下拉列表同服務商說明為準。
   * **Qwen Code**：支援 OpenAI Chat Completions API 格式嘅模型，推薦使用 Qwen Coder 系列模型，以獲得更好嘅代碼生成效果。
   * **Gemini CLI**：需要揀 Google Gemini 系列模型。
   * **OpenAI Codex**：需要揀同 OpenAI / Codex 兼容嘅 GPT 系列模型，具體以而家帳號同模型服務商支援為準。
   * **iFlow CLI** / **GitHub Copilot CLI** / **Kimi CLI** / **OpenCode**：需揀同其平台協議互相兼容嘅 API 模型，通常由對應服務商官方渠道或 API 聚合網關提供。
   * **注意**：第三方網關（如 One API、New API 等）就算可以轉發同名模型，都未必兼容對應 CLI 嘅認證方式、Endpoint 格式或者工具調用協議。若啟動失敗，請優先使用該 CLI 官方支援嘅模型服務。
2. **依賴同環境衝突**：
   * Cherry Studio 內部整合咗獨立嘅 Node.js 運行環境、Code Agent 可執行文件同環境變量配置，旨在提供一個開箱即用嘅純淨環境。
   * 如果你喺啟動 Agent 時遇到依賴衝突或者古怪嘅錯誤，可以考慮暫時 **卸載或禁用系統內已安裝嘅相關依賴**（如全局安裝嘅 Node.js 或特定工具鏈），以排除衝突。
3. **API Token 消耗警告**：
   * **Code Agent 對 API Token 嘅消耗量非常大**。喺處理複雜任務時，Agent 為咗思考、規劃同生成代碼，可能會產生大量請求，導致 Token 快速消耗。
   * 請務必根據自己嘅 API 額度同預算，**量力而為**，密切留意 Token 使用情況，以防止預算超支。

希望本教程可以幫你快速上手 Cherry Studio 強大嘅 Code Agent 功能！

***

### 💡 獲取幫助同提交反饋

如果您喺配置或使用過程中遇到任何疑問、Bug 或有功能改進建議，請參考 [反饋同建議](/docs/zhong-wen-fan-ti/question-contact/suggestions.md) 入面提供嘅官方渠道。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cherry-ai.com/docs/zhong-wen-fan-ti/advanced-basic/code-tools.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
