SayHelloHi
V2EX  ›  问与答

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

  •  
  •   SayHelloHi · Mar 16 · 2806 views
    This topic created in 232 days ago, the information mentioned may be changed or developed.

    创建 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 replies  •  2026-03-17 08:07:33 +08:00
    ClericPy
    ClericPy
    Mar 16
    1
    这个方案之前 v2 里没搜到,在老外那边搜到过

    谢谢分享,cc-switch 这段时间貌似也有个 pr 合了就是这功能
    FarAhead
    FarAhead
    Mar 16
    2
    Codex 支持这么用吗?
    SayHelloHi
    SayHelloHi
    OP
    Mar 17
    3
    @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
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4862 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 06:54 · PVG 14:54 · LAX 22:54 · JFK 01:54
    ♥ Do have faith in what you're doing.