Guidance for how to connect Github Copilot as model provider for Claude Code.
NOTICE: calling Github Copilot is not against its policy as this is officially supported per doc here. And actually, there are lots of AI tools (e.g. Aider and Cline VSCode extension) already support Github Copilot as one of the LLM providers.
npm install -g copilot-api @anthropic-ai/claude-code
$ copilot-api start
...
Please visit https://github.com/login/device and enter code XXXX-XXXX to authenticate
...
Once succeeds, you’d see the model list and API address:
...
- claude-3.5-sonnet
- claude-3.7-sonnet
- claude-3.7-sonnet-thought
- claude-sonnet-4
- claude-opus-4
- gemini-2.0-flash-001
- gemini-2.5-pro
- o3
...
➜ Listening on: http://localhost:4141/ (all interfaces)
~/.claude/settings.json
with following contents{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:4141",
"ANTHROPIC_AUTH_TOKEN": "dummy",
"ANTHROPIC_MODEL": "claude-sonnet-4",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-3.7-sonnet",
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Open another terminal and then run claude
at your will. DO read its best practices for fully leveraging its capabilities.
If the above configure file doesn’t work, use env variable directly:
export ANTHROPIC_BASE_URL="http://localhost:4141"
export ANTHROPIC_AUTH_TOKEN="dummy"
export ANTHROPIC_MODEL="claude-sonnet-4"
export ANTHROPIC_SMALL_FAST_MODEL="claude-3.7-sonnet"
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="1"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
claude