Copilot CLI
GitHub Copilot CLI is GitHub's official terminal AI coding assistant. With BYOK (Bring Your Own Key), you can point it at WRouter via environment variables.
- Official docs: https://docs.github.com/copilot/how-tos/copilot-cli/cli-getting-started
- npm: https://www.npmjs.com/package/@github/copilot
Prerequisites
| Item | Requirement |
|---|---|
| Node.js | ≥ 22 |
| Copilot CLI | latest |
| WRouter | A working sk- token |
Install
bash
npm install -g @github/copilot
copilot --versionConfigure (BYOK)
Copilot CLI reads provider settings from environment variables. Anthropic mode is recommended for the best compatibility:
macOS / Linux
bash
export COPILOT_PROVIDER_TYPE=anthropic
export COPILOT_PROVIDER_BASE_URL=https://wrouter.ai/v1
export COPILOT_PROVIDER_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export COPILOT_MODEL=claude-sonnet-4-6Windows (PowerShell)
powershell
$env:COPILOT_PROVIDER_TYPE="anthropic"
$env:COPILOT_PROVIDER_BASE_URL="https://wrouter.ai/v1"
$env:COPILOT_PROVIDER_API_KEY="sk-xxxx..."
$env:COPILOT_MODEL="claude-sonnet-4-6"Why Anthropic mode
Some reasoning models require reasoning_content to be echoed back in the next turn. Copilot CLI's OpenAI integration doesn't yet support that handshake, which can trigger 400 errors. The Anthropic Messages route avoids the issue.
If you only use non-reasoning models (e.g. gemini-2.5-flash), COPILOT_PROVIDER_TYPE=openai also works.
Optional: context and output caps
bash
export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=840000
export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=128000Verify
bash
copilotThe CLI should respond using the WRouter-routed model.
Recommended models
| Model | Notes |
|---|---|
claude-sonnet-4-6 | Daily driver in Anthropic mode |
claude-opus-4-8 | Heavier reasoning |
gemini-2.5-flash | Use with COPILOT_PROVIDER_TYPE=openai |
Known limitations
- Copilot CLI's tight coupling with GitHub features (issue context, repo metadata) goes through GitHub's APIs, not WRouter.
- Some MCP integrations require additional configuration; refer to GitHub's official docs.