GitHub Copilot CLI Integration with CodeGateway: Custom Model Provider

(Unofficial)

This guide is independently community-maintained. It is not affiliated with, endorsed by, or sponsored by the vendor of the third-party tool it covers. All third-party trademarks are the property of their respective owners.

Four environment variables point Copilot CLI at CodeGateway with DeepSeek/Kimi/GLM/Qwen models.

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

bash
curl -fsSL https://gh.io/copilot-install | bash

Alternatively brew install copilot-cli or npm install -g @github/copilot.

2. Configure a custom provider

Set four environment variables (shell profile or .env):

bash
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: always https://api.codegateway.dev/v1.

  • COPILOT_PROVIDER_TYPE: openai (OpenAI-compatible). Supported values are openai / 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

bash
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.

References

Turn this doc into a real API call

Lacking an official key or facing overseas card payment issues? Create an sk-cg- key after signing up, point your base URL at CodeGateway, and keep your existing SDK or CLI unchanged. Pay per token; binding a card adds free credit.

Sign up free
Author:CodeGateway Team