TL;DR: GitHub Copilot CLI officially supports custom model providers — four environment variables pointing at CodeGateway give you DeepSeek / Kimi / GLM / Qwen models in Copilot CLI, pay as you go.
Prerequisites
Register at codegateway.dev — trial credit included after you bind a card (current amount shown on the signup/pricing page) — and create an API key in the Dashboard (sk-cg- prefix).
This path needs no GitHub Copilot subscription (no GitHub login with a custom provider).
1. Install Copilot CLI
curl -fsSL https://gh.io/copilot-install | bashAlternatively brew install copilot-cli or npm install -g @github/copilot.
2. Configure a custom provider
Set four environment variables (shell profile or .env):
export COPILOT_PROVIDER_BASE_URL="https://api.codegateway.dev/v1"
export COPILOT_PROVIDER_TYPE="openai"
export COPILOT_PROVIDER_API_KEY="sk-cg-your-key"
export COPILOT_MODEL="deepseek-v4-pro"Field notes:
COPILOT_PROVIDER_BASE_URL: alwayshttps://api.codegateway.dev/v1.COPILOT_PROVIDER_TYPE:openai(OpenAI-compatible). Supported values areopenai/azure/anthropic.COPILOT_PROVIDER_API_KEY: your CodeGateway key.COPILOT_MODEL: model id matching the model list; can also be overridden with--model.
3. Model requirements
Custom-provider models must support tool (function) calling and streaming; a context window of at least 128k is recommended. CodeGateway picks:
deepseek-v4-pro: first choice — tool calling + streaming both supported.kimi-k2.7-code: long coding tasks.glm-5.3: balanced.
Note: GPT-series models are region-restricted upstream; Claude / Gemini series are not OpenAI-compatible — do not configure them here.
4. Verify
copilot "Reply with only: hello"A reply means it works. copilot help providers shows provider details.
FAQ
*Q: What happens without COPILOT_PROVIDER_?** The default path: GitHub login (subscription or a PAT with Copilot Requests rights via GH_TOKEN) and GitHub-hosted models.
Q: What if a model lacks tool calling? Copilot CLI needs the agent to edit files and run commands; without function calling the task fails or degrades. Stick to the recommended models.
Q: Can I set only some variables? Set BASE_URL / API_KEY / MODEL together — partial configuration is undefined behavior (docs recommend all four).
Q: Works in WSL / containers? Yes — env-var based, platform-independent.
Q: How is billing calculated? Same as the rest of the gateway: per token with tiered markup — see Tier pricing explained.