V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
SayHelloHi
V2EX  ›  问与答

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

  •  
  •   SayHelloHi · 1 天前 · 498 次点击

    创建 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

    3 条回复    2026-03-17 08:07:33 +08:00
    ClericPy
        1
    ClericPy  
       1 天前
    这个方案之前 v2 里没搜到,在老外那边搜到过

    谢谢分享,cc-switch 这段时间貌似也有个 pr 合了就是这功能
    FarAhead
        2
    FarAhead  
       1 天前
    Codex 支持这么用吗?
    SayHelloHi
        3
    SayHelloHi  
    OP
       1 天前
    @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
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3297 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:18 · PVG 20:18 · LAX 05:18 · JFK 08:18
    ♥ Do have faith in what you're doing.