Coding Tools
GitHub Copilot CLI
Connect GitHub Copilot CLI to TokenLab with BYOK
Overview
GitHub Copilot CLI can connect to any OpenAI Chat Completions-compatible endpoint. TokenLab works through Copilot CLI's BYOK environment variables.
Install
With Node.js 22 or later, install through npm:
npm install -g @github/copilot@1.0.85On macOS or Linux, you can alternatively use Homebrew:
brew install --cask copilot-cliVerify the installation:
copilot --versionConfigure TokenLab
Set the provider variables before starting Copilot CLI:
Use the Quickstart terminal instructions for macOS, Linux, WSL, or Windows PowerShell to set TOKENLAB_API_KEY without putting the key in command history. Launch Copilot CLI from that terminal. For persistent use, use your local secret manager; do not append a plaintext key to your shell profile.
These variables apply only to this launch; your saved account, default model and permission settings stay in place. Launch normally without the variables to use your previous setup. Do not persist them in your shell profile.
COPILOT_PROVIDER_TYPE=openai COPILOT_PROVIDER_BASE_URL=https://api.tokenlab.sh/v1 COPILOT_PROVIDER_API_KEY="${TOKENLAB_API_KEY:?Set TOKENLAB_API_KEY first}" copilot --model kimi-k3| Variable | TokenLab value |
|---|---|
COPILOT_PROVIDER_TYPE | openai |
COPILOT_PROVIDER_BASE_URL | https://api.tokenlab.sh/v1 |
COPILOT_PROVIDER_API_KEY | Your TokenLab API key |
COPILOT_MODEL | A live model ID, for example kimi-k3 |
GitHub requires the selected model to support both streaming and tool calling. kimi-k3 exposes tool use and a context window larger than GitHub's recommended 128K minimum.
Verify
Inside Copilot CLI, ask for a read-only action first, such as:
Inspect this repository and summarize its top-level structure. Do not modify files.You can also inspect provider help or switch the model for the current session:
copilot help providersTroubleshooting
Do not commit API keys to shell scripts or dotfiles tracked by Git. Rotate any key that was exposed in terminal history, screenshots, or logs.
Saving settings or listing models does not verify a key or a completed request. A prompt uses TokenLab balance. Check the reply and its matching request record before trying tools; auxiliary requests may also be billed.