技能 running-claude-code-via-litellm-copilot
📦

running-claude-code-via-litellm-copilot

低風險 ⚙️ 外部命令🌐 網路存取📁 檔案系統存取

通過 LiteLLM 代理將 Claude Code 路由至 GitHub Copilot

通過本地 LiteLLM 代理將 Claude Code 請求路由至 GitHub Copilot,以降低 Anthropic API 成本。本技能提供配置代理繞過方案的逐步設置說明。

支援: Claude Codex Code(CC)
📊 70 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「running-claude-code-via-litellm-copilot」。 I need help creating the LiteLLM config.yaml file

預期結果:

這是使用 claude-opus-4.5 的 GitHub Copilot 最小配置.yaml。在啟動 LiteLLM 之前,將其放在您的工作目錄中。model_name 欄位定義了 Claude Code 將請求的內容。model 欄位使用 github_copilot 提供者前綴。drop_params 設置刪除 Copilot 不理解的 Anthropic 特定欄位。

正在使用「running-claude-code-via-litellm-copilot」。 How do I verify my setup is working correctly?

預期結果:

使用兩個終端:在終端 A 中保持 LiteLLM 運行,然後在終端 B 中啟動 claude。發送一個小請求,如簡單的代碼解釋。觀察終端 A 中的傳入請求日誌,顯示 github_copilot 路由。如果看到請求流經並獲得回應,您的設置就正常工作了。

安全審計

低風險
v1 • 3/29/2026

Static analysis flagged 99 patterns but all are false positives. The scanned files are markdown documentation containing code examples and instructions, not executable code. Backticks detected are markdown formatting for code blocks. References to shell commands, PowerShell, URLs, and file paths are instructional content for users to execute manually. No actual cryptographic operations, network calls, or filesystem access code exists. The skill is documentation-only guidance for setting up a LiteLLM proxy between Claude Code and GitHub Copilot.

2
已掃描檔案
333
分析行數
4
發現項
1
審計總數
低風險問題 (1)
Documentation Contains Command Examples
The skill documentation includes shell command examples and PowerShell snippets for users to execute. These are instructional, not executable code, but users should verify commands before running them in their environment.
審計者: claude

品質評分

41
架構
100
可維護性
87
內容
32
社群
88
安全
91
規範符合性

你能建構什麼

注重成本的開發者

開發者希望利用現有的 GitHub Copilot 訂閱來降低直接 Anthropic API 支出,同時保持 Claude Code 工作流程。

DevOps 工程師故障排除

DevOps 工程師需要調試為何 Claude Code 請求無法到達 LiteLLM 代理或從 GitHub Copilot 返回認證錯誤。

技術探索者

技術精通的用戶希望了解代理架構,並設置具有多種 AI 後端選項的靈活本地開發環境。

試試這些提示

基本設置問題
我想通過 LiteLLM 設置 Claude Code 與 GitHub Copilot 配合使用。有哪些基本步驟可以開始?
配置幫助
幫助我創建一個使用 claude-opus-4.5 模型的 GitHub Copilot LiteLLM config.yaml 文件。
連接故障排除
Claude Code 啟動但 LiteLLM 沒有收到傳入請求。我將 ANTHROPIC_BASE_URL 設置為 http://localhost:4000。我應該檢查什麼?
高級標頭配置
我的請求到達 GitHub Copilot 但被拒絕。我需要在 LiteLLM 配置中添加自定義標頭(如 editor-version 或 user-agent)嗎?

最佳實務

  • 在對 settings.json 進行持久更改之前,先使用臨時環境變數進行測試
  • 保持 ANTHROPIC_MODEL 值與 LiteLLM config.yaml 中的 model_name 相同,以確保正確路由
  • 在初始設置期間保持 LiteLLM 終端可見,因為日誌提供最快的調試反饋

避免

  • 不要替換整個 ~/.claude/settings.json 文件 - 只合併本工作流程所需的 env 鍵
  • 不要將 ANTHROPIC_AUTH_TOKEN 視為真正的 Copilot 憑證 - 它是 Claude Code 期望的本地佔位符
  • 不要在第一次嘗試時添加自定義標頭覆蓋 - 使用基本提供者流程,僅在特定錯誤表明需要時才添加標頭

常見問題

此工作流程是否受到 GitHub 正式支援?
不支援。這是使用 LiteLLM 作為本地代理的社群發現的繞過方案。在使用此方法之前,您應自行評估 GitHub Copilot 服務條款和使用限制。
ANTHROPIC_AUTH_TOKEN 需要真正的 Anthropic API 金鑰嗎?
不需要。ANTHROPIC_AUTH_TOKEN 是一個本地佔位符,因為 Claude Code 期望非空值。LiteLLM 通過單獨的裝置授權流程處理與 GitHub Copilot 的實際認證。
如果 LiteLLM 停止運行會發生什麼?
Claude Code 將無法連接,因為 ANTHROPIC_BASE_URL 指向您的本地 LiteLLM 實例。使用此設置使用 Claude Code 時,必須在配置的連接埠上保持 LiteLLM 運行。
為什麼需要與 GitHub Copilot 進行裝置授權?
LiteLLM 代表您向 GitHub Copilot 進行認證。第一個請求會觸發 GitHub 的裝置授權流程,您通過瀏覽器批准訪問。然後 LiteLLM 在本地存儲憑證以供後續請求使用。
我可以通過此設置使用任何 Claude 模型嗎?
您可以使用 GitHub Copilot 公開的任何模型。ANTHROPIC_MODEL 中的模型名稱必須與 LiteLLM config 中的 model_name 完全匹配。Copilot 的可用模型可能隨時間變更。
如果我收到 model-not-found 或 404 錯誤該怎麼辦?
首先驗證 ANTHROPIC_MODEL 與 config.yaml 中的 model_name 完全匹配(包括大小寫和連字符)。然後確認 LiteLLM 正在運行並接收請求。最後檢查您的 GitHub Copilot 帳戶是否有權訪問所請求的模型。