使用本指南將 Claude Code 連接到 CometAPI。 官方參考資料:Documentation Index
Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
Use this file to discover all available pages before exploring further.
模型可用性會隨時間變動。若要查看目前的 Claude model ID,請查閱
CometAPI Models page。
先決條件
- 從你的 dashboard 取得一組 CometAPI 金鑰(以
sk-開頭) - 已安裝 Git
- 支援的作業系統:macOS、Linux 或 Windows
安裝 Claude Code
設定 CometAPI 端點
建立或編輯設定檔:- macOS / Linux:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json
sk-your-cometapi-key 替換為你實際的 CometAPI 金鑰,然後啟動 Claude Code:
疑難排解
settings.json 沒有生效?
- 完全重新啟動你的終端機(關閉所有視窗後重新開啟)
- 若仍然無法運作,建立
~/.claude.json並加入: - 作為備用方式,直接匯出環境變數:
Invalid API Key 或 Please run /login?
請檢查 ~/.claude/settings.json 是否存在,且 JSON 格式是否有效(沒有尾隨逗號、引號正確)。可在 jsonlint.com 驗證。
先前已登入 Anthropic 官方服務?
Claude Code 會優先使用快取中的官方憑證。在 Claude Code 內執行 /logout,將其關閉後再重新啟動。若仍然失敗:
offline?
Claude Code 會透過 Google 檢查連線狀態。offline 只是表示無法連上 Google——這不會影響 CometAPI 的使用。
Fetch / 網頁瀏覽失敗?
Claude Code 的 Fetch 功能會先呼叫 Anthropic 的原生服務,而這需要直接的網際網路存取。你可能需要設定系統層級的代理。