如何使用 LiteLLM 让 Claude Code 调用 GitHub Copilot 提供的 Claude 模型

3 月 16 日
 SayHelloHi

创建 Python 虚拟环境

  1. 安装uv

  2. uv venv

安装 LiteLLM

uv pip install litellm[proxy]

配置 config.yaml

litellm_settings:
  drop_params: true

model_list:
  - model_name: claude-opus-4-6
    litellm_params:
      model: github_copilot/claude-opus-4.6
  - model_name: claude-sonnet-4-6
    litellm_params:
      model: github_copilot/claude-sonnet-4.6  

配置 Claude Code

  1. 打开 ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-996",
    "ANTHROPIC_BASE_URL": "http://localhost:4000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "permissions": {
    "allow": [],
    "deny": []
  },
  "model": "sonnet[1m]",
  "enabledPlugins": {
    "playwright@claude-plugins-official": true,
    "og-image@og-image-skill": true
  }
}

启动 LiteLLM

litellm --config config.yaml

注意:启动后会有设备码,你需要打开 Github 网页输入设备码授权

参考

https://docs.litellm.ai/docs/providers/github_copilot#usage---litellm-proxy

2631 次点击
所在节点    问与答
3 条回复
ClericPy
3 月 16 日
这个方案之前 v2 里没搜到,在老外那边搜到过

谢谢分享,cc-switch 这段时间貌似也有个 pr 合了就是这功能
FarAhead
3 月 16 日
Codex 支持这么用吗?
SayHelloHi
3 月 17 日
@FarAhead

看官方文档 理论上是可以的 老铁可以试一试~

# Point to your LiteLLM Proxy server
export OPENAI_BASE_URL=http://0.0.0.0:4000

# Use your LiteLLM API key (if you've set up authentication)
export OPENAI_API_KEY="sk-1234"


https://docs.litellm.ai/docs/tutorials/openai_codex#4-configure-codex-to-use-litellm-proxy

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/1198768

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX