> ## Documentation Index
> Fetch the complete documentation index at: https://nusabase-a8dcf793.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate GitHub Copilot CLI

> Use Copilot CLI BYOK environment variables with the Nusabase OpenAI-compatible endpoint.

GitHub Copilot CLI supports BYOK (Bring Your Own Key) for OpenAI Chat Completions-compatible endpoints. The Nusabase OpenAI-compatible Base URL is `https://api.nusabasedigital.com/v1`.

## When To Use This

* You want to use Copilot CLI in the terminal.
* You want Copilot CLI model calls to go through Nusabase.
* Your selected model supports tool calling and streaming.

> [!WARNING]
>
> Copilot CLI BYOK requires the model to support tool calling/function calling and streaming. If the selected model or channel does not support these capabilities, Copilot CLI will return an error. Confirm available models with `/v1/models`, then choose according to model capability.

## Prerequisites

* GitHub Copilot CLI is installed according to GitHub's official docs.
* You have a Nusabase API key: `sk-...`.
* Your machine can reach `https://api.nusabasedigital.com`.
* The example model `qwen3.5-flash` appears in the current pricing docs. Use `/v1/models` as the source of truth.

Check the CLI:

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

## Configure Environment Variables

Linux / macOS / WSL:

```bash theme={null}
export COPILOT_PROVIDER_TYPE=openai
export COPILOT_PROVIDER_BASE_URL=https://api.nusabasedigital.com/v1
export COPILOT_PROVIDER_API_KEY=sk-your_api_key
export COPILOT_MODEL=qwen3.5-flash
```

Windows PowerShell:

```powershell theme={null}
$env:COPILOT_PROVIDER_TYPE="openai"
$env:COPILOT_PROVIDER_BASE_URL="https://api.nusabasedigital.com/v1"
$env:COPILOT_PROVIDER_API_KEY="sk-your_api_key"
$env:COPILOT_MODEL="qwen3.5-flash"
```

| Environment Variable | Description |
| - | - |
| `COPILOT_PROVIDER_TYPE` | Use `openai` for OpenAI Chat Completions-compatible calls. |
| `COPILOT_PROVIDER_BASE_URL` | Use `https://api.nusabasedigital.com/v1`. |
| `COPILOT_PROVIDER_API_KEY` | Nusabase API key. |
| `COPILOT_MODEL` | Default model name; must be enabled for your account. |

If the model is not in Copilot CLI's built-in catalog, set token limits explicitly:

```bash theme={null}
export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=128000
export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=8192
```

## Verify API First

```bash theme={null}
curl https://api.nusabasedigital.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-flash",
    "messages": [{"role": "user", "content": "hello"}],
    "stream": true
  }'
```

## Start Copilot CLI

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

Then send:

```text theme={null}
Introduce this project in one sentence.
```

## Troubleshooting

| Problem | Likely Cause | Fix |
| - | - | - |
| `401` | API key is wrong or not visible in the current shell | Set `COPILOT_PROVIDER_API_KEY` again in the same terminal. |
| `404` or model unavailable | `COPILOT_MODEL` is not enabled for your account | Call `/v1/models` and copy a real model ID. |
| `400` | Provider type or Base URL does not match the CLI request format | Use `openai` and `https://api.nusabasedigital.com/v1`. |
| Tool calls fail | The selected model or channel does not support tool calling/streaming | Switch to a model that supports tool calling and streaming. |
| CLI still calls GitHub-hosted models | Environment variables were not inherited | Set them in the same terminal that starts `copilot`. |

For VS Code workflows, see [GitHub Copilot](https://nusabase-a8dcf793.mintlify.site/en/guides/agent-integrations-github-copilot.md).

## References

* [GitHub Copilot CLI BYOK](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models)
* [GitHub Copilot CLI product page](https://github.com/features/copilot/cli)
* [First Request Example](https://nusabase-a8dcf793.mintlify.site/en/getting-started/first-request.md)
* [Models and Pricing](https://nusabase-a8dcf793.mintlify.site/en/getting-started/pricing.md)
* [Error Codes](https://nusabase-a8dcf793.mintlify.site/en/getting-started/error-codes.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.