Coding agents

GitHub Copilot CLI

Connect GitHub Copilot CLI to RealRelay.ai with its bring-your-own-key environment variables: install it, set the provider, check the connection and choose models.

Protocol
OpenAI Chat Completions · Anthropic Messages
Base URL
https://www.realrelay.ai/v1
Official docs
docs.github.com
Checked against the tool’s docs
2026-10

Overview

GitHub Copilot CLI is GitHub's coding agent for the terminal. It reads your repository, edits files and runs commands after you approve them. With bring your own key (BYOK), it sends requests to a provider you choose. Its default provider type speaks OpenAI Chat Completions, so it connects to RealRelay.ai's /v1/chat/completions endpoint. For Claude models you can use the Anthropic type and /v1/messages instead.

  • An API key from the API keys page of the console.

  • For the openai type, the base URL with /v1. For the anthropic type, the site address without /v1.

  • A model ID exactly as GET /v1/models lists it, for example z-ai/glm-5.2.

Copilot CLI requires models that support tool calling and streaming, and GitHub recommends a context window of at least 128K tokens. GitHub's install guide also lists an active Copilot subscription as a prerequisite for the CLI.

Install

Use one of GitHub's install methods. The npm package needs Node.js 22 or later.

npm (Node.js 22+)
npm install -g @github/copilotcopilot --version
Homebrew (macOS · Linux)
brew install --cask copilot-clicopilot --version
Windows PowerShell
winget install GitHub.Copilotcopilot --version
macOS · Linux
curl -fsSL https://gh.io/copilot-install | bashcopilot --version

If copilot --version prints a version number, the install worked. On first launch Copilot CLI may ask you to run /login to sign in to GitHub.

Configure

Copilot CLI reads the provider only from environment variables, so set them in your shell profile. Replace sk-*** with your key.

~/.zshrc · ~/.bashrc
1export COPILOT_PROVIDER_TYPE="openai"2export COPILOT_PROVIDER_BASE_URL="https://www.realrelay.ai/v1"3export COPILOT_PROVIDER_API_KEY="sk-***"4export COPILOT_MODEL="z-ai/glm-5.2"5export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=1280006export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=32000

Run source ~/.zshrc, or open a new terminal, before starting Copilot CLI.

Windows PowerShell
1[Environment]::SetEnvironmentVariable("COPILOT_PROVIDER_TYPE", "openai", "User")2[Environment]::SetEnvironmentVariable("COPILOT_PROVIDER_BASE_URL", "https://www.realrelay.ai/v1", "User")3[Environment]::SetEnvironmentVariable("COPILOT_PROVIDER_API_KEY", "sk-***", "User")4[Environment]::SetEnvironmentVariable("COPILOT_MODEL", "z-ai/glm-5.2", "User")5[Environment]::SetEnvironmentVariable("COPILOT_PROVIDER_MAX_PROMPT_TOKENS", "128000", "User")6[Environment]::SetEnvironmentVariable("COPILOT_PROVIDER_MAX_OUTPUT_TOKENS", "32000", "User")

These are saved for your user account. Close and reopen the terminal before starting Copilot CLI.

~/.zshrc · ~/.bashrc
1export COPILOT_PROVIDER_TYPE="anthropic"2export COPILOT_PROVIDER_BASE_URL="https://www.realrelay.ai"3export COPILOT_PROVIDER_API_KEY="sk-***"4export COPILOT_MODEL="anthropic/claude-sonnet-4-6"5export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=1280006export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=32000

Use this instead of the first set for Claude models, which RealRelay.ai serves natively on /v1/messages.

  • COPILOT_PROVIDER_TYPE defaults to openai; it is spelled out so switching to anthropic is a one-line change.

  • COPILOT_MODEL is required unless you pass --model each time.

  • Copilot CLI looks up a model's limits by its well-known name, and RealRelay.ai IDs are not well-known names. COPILOT_PROVIDER_MAX_PROMPT_TOKENS and COPILOT_PROVIDER_MAX_OUTPUT_TOKENS tell it how much to send and ask for. The example values are safe for the models named here; raise them to the limits on the model's catalog page.

  • Do not commit a profile or .env file that contains the key.

Verify

  1. 1

    Call the endpoint directly

    Run this with your key. A JSON reply with a choices array means the address, key and model work.

    Terminal
    1curl -sS "https://www.realrelay.ai/v1/chat/completions" \2  -H "Authorization: Bearer sk-***" \3  -H "Content-Type: application/json" \4  -d '{"model": "z-ai/glm-5.2", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}'
  2. 2

    Run one prompt

    In the terminal where the variables are set, run a single prompt. Copilot CLI prints the answer and exits.

    Terminal
    copilot -p "Reply with OK"
  3. 3

    Start a session

    Start copilot in a project, send a short message, then run /usage. The token totals should list your RealRelay.ai model, and the requests appear in the console's usage logs.

    GitHub Copilot CLI
    cd /path/to/your/projectcopilot/usage

Models

The model comes from COPILOT_MODEL. To use another one for a single run, pass --model; to change it for good, edit the variable and open a new terminal.

Terminal
copilot --model z-ai/glm-5.2

Pick a model with tool calling and at least 128K tokens of context, and set the two token limits to match it. With the anthropic type, use an anthropic/* model. See Choosing a model.

Troubleshooting

  • An error that the model does not support tools or streaming. Copilot CLI cannot use that model. Choose one with tool calling.

  • 401 or "Invalid token". The key did not reach the CLI. Check that COPILOT_PROVIDER_API_KEY is set in the terminal you start copilot from.

  • 404. The base URL form does not match the provider type: openai needs /v1, anthropic must not have it.

  • Model not found. COPILOT_MODEL must match the RealRelay.ai ID exactly, including the prefix such as z-ai/.

  • Replies cut off, or context errors in long sessions. The token limits are missing or larger than the model allows. Set them from the model's catalog page.

  • A model that RealRelay.ai serves only on Responses, such as openai/gpt-5.3-codex, fails on Chat Completions. Switch the wire API for it:

    ~/.zshrc · ~/.bashrc
    export COPILOT_PROVIDER_WIRE_API="responses"export COPILOT_MODEL="openai/gpt-5.3-codex"
  • You want the CLI to talk only to RealRelay.ai. GitHub documents an offline mode that stops the CLI contacting GitHub's servers. Your prompts still go to RealRelay.ai.

    ~/.zshrc · ~/.bashrc
    export COPILOT_OFFLINE=true