Copilot CLI

Connect GitHub Copilot CLI to CoffeeRouter with its official BYOK provider environment variables.

Before You Begin

  • Install Node.js 22 or later.
  • Prepare a CoffeeRouter API key and the exact target model ID.
  • The model must support streaming and tool calling. GitHub recommends a context window of at least 128K.

Configuration Steps

1. Install Copilot CLI

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

If ~/.npmrc contains ignore-scripts=true, follow the official guidance and run:

npm_config_ignore_scripts=false npm install -g @github/copilot

On Windows, you can also run winget install GitHub.Copilot.

2. Configure the CoffeeRouter Provider

CoffeeRouter exposes an OpenAI Chat Completions-compatible API, so use the openai provider type by default.

Linux / macOS:

export COPILOT_PROVIDER_TYPE=openai
export COPILOT_PROVIDER_BASE_URL=https://www.coffeerouter.ai/v1
export COPILOT_PROVIDER_API_KEY=sk-your-api-key
export COPILOT_MODEL=your-model-id

Windows PowerShell:

$env:COPILOT_PROVIDER_TYPE="openai"
$env:COPILOT_PROVIDER_BASE_URL="https://www.coffeerouter.ai/v1"
$env:COPILOT_PROVIDER_API_KEY="sk-your-api-key"
$env:COPILOT_MODEL="your-model-id"

Replace your-model-id with a model ID permitted by your CoffeeRouter token.

3. Start Copilot CLI and Check the Provider

copilot

To inspect the provider options supported by your installed version, run:

copilot help providers

Verify the Integration

Ask Copilot CLI to analyze project files and perform a tool-assisted task. Streaming output and successful tool calls confirm that the integration works.

FAQ

Why does Copilot report that the model is unsupported?

Verify the model ID exactly and confirm that the model supports both streaming and tool calling. A chat-only model does not meet Copilot CLI agent requirements.

Why are the environment variables ignored?

Set the variables and launch copilot from the same terminal window. Exit the current Copilot session and restart it after changing a variable.

Why does a reasoning model return HTTP 400?

Reasoning state requirements differ between models. Do not use anthropic as a universal provider setting. Switch provider type only when CoffeeRouter explicitly exposes the corresponding Anthropic Messages endpoint and you have verified it. A non-reasoning model can help isolate the issue.

Why does the Base URL end in /v1?

Copilot CLI accepts an API base address and appends the Chat Completions path itself. Enter https://www.coffeerouter.ai/v1, not the complete /chat/completions endpoint.

Security

  • Provider environment variables contain the API key. Do not share shell profiles, terminal screenshots, or diagnostic logs.
  • Copilot CLI sends prompts, code context, and tool-call data to CoffeeRouter.
  • Use a dedicated token and restrict its models, quota, IP addresses, and expiration as needed.
  • For a remote CoffeeRouter service, confirm that the operator's data-handling policy meets your compliance requirements.

Official Resources