Skip to content

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.

Prerequisites

ItemRequirement
Node.js≥ 22
Copilot CLIlatest
WRouterA working sk- token

Install

bash
npm install -g @github/copilot
copilot --version

Configure (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-6

Windows (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=128000

Verify

bash
copilot

The CLI should respond using the WRouter-routed model.

ModelNotes
claude-sonnet-4-6Daily driver in Anthropic mode
claude-opus-4-8Heavier reasoning
gemini-2.5-flashUse 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.