> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aisonar.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Copilot CLI

> Connect GitHub Copilot CLI to AI Sonar with BYOK

## Overview

<Note>
  **Type**: Coding agent CLI

  **Primary Path**: OpenAI-compatible Chat Completions

  **Support Confidence**: Official BYOK path
</Note>

[GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models) can connect to any OpenAI Chat Completions-compatible endpoint. AI Sonar works through Copilot CLI's BYOK environment variables.

## Install

With Node.js 22 or later, install through npm:

```bash theme={null}
npm install -g @github/copilot
```

On macOS or Linux, you can alternatively use Homebrew:

```bash theme={null}
brew install --cask copilot-cli
```

Verify the installation:

```bash theme={null}
copilot --version
```

<Note>
  GitHub currently requires an active Copilot plan. Organization-managed accounts also need the Copilot CLI policy enabled.
</Note>

## Configure AI Sonar

Set the provider variables before starting Copilot CLI:

```bash theme={null}
export COPILOT_PROVIDER_TYPE="openai"
export COPILOT_PROVIDER_BASE_URL="https://api.aisonar.dev/v1"
export COPILOT_PROVIDER_API_KEY="sk-your-api-key"
export COPILOT_MODEL="kimi-k3"

copilot
```

| Variable                    | AI Sonar value                         |
| --------------------------- | -------------------------------------- |
| `COPILOT_PROVIDER_TYPE`     | `openai`                               |
| `COPILOT_PROVIDER_BASE_URL` | `https://api.aisonar.dev/v1`           |
| `COPILOT_PROVIDER_API_KEY`  | Your AI Sonar 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:

```text theme={null}
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:

```bash theme={null}
copilot help providers
copilot --model kimi-k3
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication failed">
    Confirm `COPILOT_PROVIDER_API_KEY` contains an active AI Sonar key and restart `copilot` after changing environment variables.
  </Accordion>

  <Accordion title="Model not found">
    Use the exact ID from the [live AI Sonar model catalog](https://aisonar.dev/models). Do not add a provider prefix to `kimi-k3`.
  </Accordion>

  <Accordion title="Tool calling or streaming error">
    Copilot CLI rejects models without both capabilities. Choose a tool-capable chat model such as `kimi-k3`.
  </Accordion>
</AccordionGroup>

<Warning>
  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.
</Warning>
