running-claude-code-via-litellm-copilot by xixu-me/skills
npx skills add https://github.com/xixu-me/skills --skill running-claude-code-via-litellm-copilot此技能用于特定的变通方案:Claude Code 保持其 Anthropic 形态的客户端行为,但实际的后端流量被发送到本地 LiteLLM 代理,然后转发给 GitHub Copilot。
请将此视为一种高级变通方案,而非官方保证的 GitHub 工作流。帮助用户在技术上取得成功,但不要承诺 GitHub 支持、政策批准或长期兼容性。
此技能以指导为先,但具备执行意识:
~/.claude/settings.json 或 shell 配置文件)之前,请先暂停。如果您需要说明哪些部分来自文章,哪些部分是根据当前 LiteLLM 文档收紧的,请在回答前阅读 references/doc-verified-notes.md。
当用户希望实现以下任何目标时,请使用此技能:
config.yamlANTHROPIC_BASE_URL、ANTHROPIC_MODEL 或 广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC不要将此技能用于:
config.yaml 开始。ANTHROPIC_MODEL 和 LiteLLM 的 model_name 一致。精确的字符串匹配比巧妙的解释更重要。ANTHROPIC_AUTH_TOKEN 视为本地占位符。Claude Code 在本地需要一个非空值,但它不是 GitHub Copilot 的凭证,不应被当作可重用的密钥。~/.claude/settings.json。只合并所需的 env 键,并保留无关的设置。当用户需要进行实际设置时,首先检查以下内容:
claude --help 成功执行uv --version 或 pip --version 成功执行4000)可用如果用户只需要指令,则陈述前提条件,而不是执行它们。
使用此规则:
对于持久设置,请确认目标文件,然后将键合并到 ~/.claude/settings.json 中。不要替换文件内容。
config.yaml从文章中的流程开始,但保持提供者命名与 LiteLLM 文档一致:
model_list:
- model_name: claude-opus-4.5
litellm_params:
model: github_copilot/claude-opus-4.5
drop_params: true
解释各字段:
model_name:Claude Code 将请求的逻辑名称model:LiteLLM 提供者路由,使用 github_copilot/<model>drop_params: true:在转发给 Copilot 之前,剥离不支持的 Anthropic 特定字段如果用户想要一个不同的 Copilot 支持模型,保持相同模式:
model_list:
- model_name: <logical-name>
litellm_params:
model: github_copilot/<copilot-model>
drop_params: true
除非用户已经遇到表明需要覆盖标头的拒绝情况,否则不要将额外的标头硬编码到默认路径中。
首选安装方式:
uv tool install "litellm[proxy]"
备用方式:
pip install "litellm[proxy]"
从包含 config.yaml 的目录启动代理:
litellm --config config.yaml --port 4000
告诉用户保持该终端打开,因为在验证期间,日志是获取信息的最快来源。
在对 GitHub Copilot 提供者首次成功请求时,LiteLLM 可能会打开设备授权流程:
存在可选的令牌位置覆盖选项:
GITHUB_COPILOT_TOKEN_DIRGITHUB_COPILOT_ACCESS_TOKEN_FILE仅当用户需要自定义令牌存储、共享环境或因凭证过期或位置错误而进行故障排除时,才提及这些。
对于临时的 PowerShell 会话:
$env:ANTHROPIC_AUTH_TOKEN = "sk-any-string"
$env:ANTHROPIC_BASE_URL = "http://localhost:4000"
$env:ANTHROPIC_MODEL = "claude-opus-4.5"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claude
对于临时的 Bash 或 Zsh 会话:
export ANTHROPIC_AUTH_TOKEN="sk-any-string"
export ANTHROPIC_BASE_URL="http://localhost:4000"
export ANTHROPIC_MODEL="claude-opus-4.5"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claude
对于持久配置,将这些键合并到 ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-any-string",
"ANTHROPIC_BASE_URL": "http://localhost:4000",
"ANTHROPIC_MODEL": "claude-opus-4.5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
合并安全行为:
env 条目尽可能使用两个终端:
claude请求一个小的提示,例如一个简短的脚本或代码审查请求,然后验证:
github_copilot/<model>健康路径是:
Claude Code -> LiteLLM -> GitHub Copilot -> LiteLLM -> Claude Code
如果 Claude Code 报告模型未找到、类似 404 的失败,或者 LiteLLM 说模型不存在:
ANTHROPIC_MODEL 和 model_name如果 LiteLLM 从未收到请求:
ANTHROPIC_BASE_URL 指向 http://localhost:4000claude 的同一个 shell 会话中设置的如果 LiteLLM 到达 GitHub Copilot 但收到 401 或 403 响应:
文章使用了明确的 Copilot 风格标头。当前的 LiteLLM 文档将 GitHub Copilot 公开为一个提供者,并且也记录了标头覆盖支持。
仅在以下情况下才考虑使用显式的 extra_headers:
备用示例:
model_list:
- model_name: claude-opus-4.5
litellm_params:
model: github_copilot/claude-opus-4.5
drop_params: true
extra_headers:
editor-version: "vscode/1.85.1"
editor-plugin-version: "copilot/1.155.0"
Copilot-Integration-Id: "vscode-chat"
user-agent: "GithubCopilot/1.155.0"
将此作为高级备用方案呈现,而非通用默认方案。
当使用此技能回答真实用户请求时,请包含:
config.yaml 或需要应用的增量内容ANTHROPIC_AUTH_TOKEN 是真实的 Copilot 凭证。~/.claude/settings.json。github_copilot/<model> 模式,并注意 Copilot 公开的模型可用性可能会发生变化。每周安装次数
3.9K
仓库
GitHub 星标数
1
首次出现
今天
安全审计
安装于
opencode3.9K
gemini-cli3.9K
deepagents3.9K
antigravity3.9K
github-copilot3.9K
codex3.9K
Use this skill for the specific workaround where Claude Code keeps its Anthropic-shaped client behavior, but the actual backend traffic is sent to a local LiteLLM proxy and then forwarded to GitHub Copilot.
Treat this as an advanced workaround, not an officially guaranteed GitHub workflow. Help the user succeed technically, but do not promise GitHub support, policy approval, or long-term compatibility.
This skill is guidance-first but execution-aware:
~/.claude/settings.json or shell profile files.Read references/doc-verified-notes.md before answering if you need to justify which parts come from the article and which parts were tightened against current LiteLLM docs.
Use this skill when the user wants any of the following:
config.yaml for LiteLLM's GitHub Copilot providerANTHROPIC_BASE_URL, ANTHROPIC_MODEL, or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC setupDo not use this skill for:
config.yaml unless the user explicitly wants a persistent setup.ANTHROPIC_MODEL and LiteLLM model_name identical. Exact string match matters more than clever explanation.ANTHROPIC_AUTH_TOKEN as a local placeholder. Claude Code expects a non-empty value locally, but it is not the GitHub Copilot credential and should not be presented as a reusable secret.~/.claude/settings.json wholesale. Merge only the needed env keys and preserve unrelated settings.Check these first when the user wants real setup work:
claude --help succeedsuv --version or pip --version succeeds4000If the user only wants instructions, state the prerequisites instead of running them.
Use this rule:
For persistent setup, confirm the target file and then merge keys into ~/.claude/settings.json. Do not replace the file contents.
config.yamlStart from the article's flow, but keep the provider naming aligned with LiteLLM docs:
model_list:
- model_name: claude-opus-4.5
litellm_params:
model: github_copilot/claude-opus-4.5
drop_params: true
Explain the fields:
model_name: the logical name Claude Code will requestmodel: the LiteLLM provider route, using github_copilot/<model>drop_params: true: strips unsupported Anthropic-specific fields before forwarding to CopilotIf the user wants a different Copilot-backed model, keep the same pattern:
model_list:
- model_name: <logical-name>
litellm_params:
model: github_copilot/<copilot-model>
drop_params: true
Do not hardcode extra headers into the default path unless the user already hit a rejection that suggests header overrides are needed.
Preferred install:
uv tool install "litellm[proxy]"
Fallback:
pip install "litellm[proxy]"
Start the proxy from the directory containing config.yaml:
litellm --config config.yaml --port 4000
Tell the user to keep that terminal open because the logs are the fastest truth source during verification.
On the first successful request to the GitHub Copilot provider, LiteLLM may open a device authorization flow:
Optional token-location overrides exist:
GITHUB_COPILOT_TOKEN_DIRGITHUB_COPILOT_ACCESS_TOKEN_FILEOnly mention these when the user needs custom token storage, shared environments, or troubleshooting around expired or misplaced credentials.
For a temporary PowerShell session:
$env:ANTHROPIC_AUTH_TOKEN = "sk-any-string"
$env:ANTHROPIC_BASE_URL = "http://localhost:4000"
$env:ANTHROPIC_MODEL = "claude-opus-4.5"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claude
For a temporary Bash or Zsh session:
export ANTHROPIC_AUTH_TOKEN="sk-any-string"
export ANTHROPIC_BASE_URL="http://localhost:4000"
export ANTHROPIC_MODEL="claude-opus-4.5"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claude
For persistent configuration, merge these keys into ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-any-string",
"ANTHROPIC_BASE_URL": "http://localhost:4000",
"ANTHROPIC_MODEL": "claude-opus-4.5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Merge-safe behavior:
env entries that are unrelated to this workflowUse two terminals when possible:
claudeAsk for one small prompt such as a short script or code review request, then verify:
github_copilot/<model>The healthy path is:
Claude Code -> LiteLLM -> GitHub Copilot -> LiteLLM -> Claude Code
If Claude Code reports model-not-found, 404-like failures, or LiteLLM says the model does not exist:
ANTHROPIC_MODEL to model_name exactlyIf LiteLLM never receives a request:
ANTHROPIC_BASE_URL points to http://localhost:4000claudeIf LiteLLM reaches GitHub Copilot but gets 401 or 403 responses:
The article uses explicit Copilot-style headers. Current LiteLLM docs expose GitHub Copilot as a provider and also document header override support.
Only reach for explicit extra_headers when:
Example fallback:
model_list:
- model_name: claude-opus-4.5
litellm_params:
model: github_copilot/claude-opus-4.5
drop_params: true
extra_headers:
editor-version: "vscode/1.85.1"
editor-plugin-version: "copilot/1.155.0"
Copilot-Integration-Id: "vscode-chat"
user-agent: "GithubCopilot/1.155.0"
Present this as an advanced fallback, not the universal default.
When answering a real user request with this skill, include:
config.yaml or the delta to applyANTHROPIC_AUTH_TOKEN is a real Copilot credential.~/.claude/settings.json wholesale.github_copilot/<model> pattern and note that Copilot-exposed model availability may change.Weekly Installs
3.9K
Repository
GitHub Stars
1
First Seen
Today
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode3.9K
gemini-cli3.9K
deepagents3.9K
antigravity3.9K
github-copilot3.9K
codex3.9K
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装