EasyRouterEasyRouter
Quick StartAPI DocsConnect Agent Tools

Copilot CLI

GitHub Copilot CLI tutorial โ€” Connect GitHub's official terminal AI coding assistant to EasyRouter via BYOK mode. Supports Agent mode, tool calling, and MCP.

Project Introduction

GitHub Copilot CLI is GitHub's official terminal AI coding assistant. It supports BYOK (Bring Your Own Key) mode for custom model endpoints, letting you point it at EasyRouter via a few environment variables. Agent mode, tool calling, and MCP are all supported.

This tutorial shows how to point Copilot CLI at EasyRouter using BYOK mode.

๐Ÿ“ฆ Prerequisites

What you'll need

  • Node.js 22 or later
  • An EasyRouter endpoint (must end with /v1)
  • An EasyRouter API key (generated in the console)
  • A model ID exactly matching one exposed by your EasyRouter console (e.g. claude-sonnet-4-6, gemini-2.5-flash)

๐Ÿš€ Step 1: Install Copilot CLI

npm install -g @github/copilot

Verify the install:

copilot --version

Full setup steps are in GitHub's getting started guide.

๐Ÿ”ง Step 2: Point it at EasyRouter

Copilot CLI reads provider config from environment variables. Use anthropic as the provider type for the best compatibility.

Linux / macOS

export COPILOT_PROVIDER_TYPE=anthropic
export COPILOT_PROVIDER_BASE_URL=https://easyrouter.io/v1
export COPILOT_PROVIDER_API_KEY=your-easyrouter-api-key
export COPILOT_MODEL=claude-sonnet-4-6

Windows (PowerShell)

$env:COPILOT_PROVIDER_TYPE="anthropic"
$env:COPILOT_PROVIDER_BASE_URL="https://easyrouter.io/v1"
$env:COPILOT_PROVIDER_API_KEY="your-easyrouter-api-key"
$env:COPILOT_MODEL="claude-sonnet-4-6"

Why anthropic type is recommended

Some models (especially reasoning models) require reasoning_content to be echoed back verbatim in the next turn. Copilot CLI's OpenAI integration doesn't support that mechanism, which can trigger 400 errors. Using the Anthropic Messages API compatible endpoint avoids this.

If you only use non-reasoning models (e.g. gemini-2.5-flash), you may set COPILOT_PROVIDER_TYPE=openai instead.

Optional: context / output token limits

export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=840000
export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=128000

โœ… Step 3: Launch & verify

copilot

Ask any coding question (e.g. "Write a Python function that reads a JSON file"). A normal response means you're set.

copilot help providers

lists every provider-related environment variable.

๐Ÿ”„ Switching models

Change COPILOT_MODEL and restart:

export COPILOT_MODEL=gemini-2.5-flash
copilot

The model name must exactly match the model ID exposed by your EasyRouter console.

โ“ Troubleshooting

IssueFix
400 Bad RequestSwitch COPILOT_PROVIDER_TYPE to anthropic
Model not foundConfirm COPILOT_MODEL exactly matches the EasyRouter model ID
Invalid API keyRegenerate a key in the EasyRouter console and update the env var
Variables don't take effectNew shell needed, or persist them in ~/.bashrc / ~/.zshrc / PowerShell profile
Output truncatedRaise COPILOT_PROVIDER_MAX_OUTPUT_TOKENS