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

# Copilot CLI | AI Gateway

> Route the full Orq.ai model catalog through GitHub Copilot CLI using its bring-your-own-key provider config. A few environment variables connect Copilot CLI to the AI Gateway with unified tracing and cost tracking.

## Overview

[GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli) brings Copilot to the terminal. Its bring-your-own-key (BYOK) configuration points the CLI at any OpenAI-compatible, Azure OpenAI, or Anthropic endpoint, so every model in the **AI Gateway** catalog is reachable from a few environment variables, with unified tracing, cost tracking, and access controls through **Orq.ai**.

<Warning>
  Always use the `provider/model_id` format for the `COPILOT_MODEL` value (e.g. `anthropic/claude-sonnet-4-6`, not `claude-sonnet-4-6`). Bare IDs return a `400 invalid model format` error.
</Warning>

## Prerequisites

* [GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli) installed
* Active **Orq.ai** account
* [Orq.ai API key](/docs/ai-studio/organization/api-keys)

### Model requirements

The selected model must support **tool calling** (function calling) and **streaming**. Copilot CLI returns an error for models missing either capability. For best results, choose a model with a context window of at least 128k tokens.

## Setup

Configure the provider with environment variables before launching Copilot CLI. Export the API key first:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ORQ_API_KEY="<orq-api-key>"
```

Replace `<orq-api-key>` with the key from [Workspace Settings → API Keys](https://my.orq.ai/settings/api-keys).

<Tabs>
  <Tab title="OpenAI-compatible (recommended)" icon="https://mintcdn.com/orqai/d-t0Z04KwFlGVsS1/images/logos/openai.svg?fit=max&auto=format&n=d-t0Z04KwFlGVsS1&q=85&s=41cb629a8b2739dc90fac2ddea651c17" width="395" height="400" data-path="images/logos/openai.svg">
    The OpenAI-compatible router reaches the full **AI Gateway** catalog. This is the default provider type, so `COPILOT_PROVIDER_TYPE` can be omitted.

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export COPILOT_PROVIDER_BASE_URL=https://api.orq.ai/v3/router
    export COPILOT_PROVIDER_API_KEY=$ORQ_API_KEY
    export COPILOT_MODEL=openai/gpt-4o
    copilot
    ```

    Replace `openai/gpt-4o` with any identifier from the **AI Gateway** catalog (e.g. `anthropic/claude-sonnet-4-6`, `google/gemini-2.0-flash-001`).
  </Tab>

  <Tab title="Anthropic" icon="https://mintcdn.com/orqai/d-t0Z04KwFlGVsS1/images/logos/anthropic.svg?fit=max&auto=format&n=d-t0Z04KwFlGVsS1&q=85&s=b097662b141ad6f89f0c8d039ae241dc" width="61" height="43" data-path="images/logos/anthropic.svg">
    Route Claude models through the Anthropic-compatible endpoint.

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export COPILOT_PROVIDER_TYPE=anthropic
    export COPILOT_PROVIDER_BASE_URL=https://api.orq.ai/v3/anthropic
    export COPILOT_PROVIDER_API_KEY=$ORQ_API_KEY
    export COPILOT_MODEL=anthropic/claude-sonnet-4-6
    copilot
    ```

    Replace `anthropic/claude-sonnet-4-6` with any Claude identifier from the **AI Gateway** catalog.
  </Tab>
</Tabs>

## Configuration Reference

| Environment variable        | Required | Description                                                                                                                                            |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `COPILOT_PROVIDER_BASE_URL` | Yes      | Gateway endpoint. Use `https://api.orq.ai/v3/router` for the OpenAI-compatible router or `https://api.orq.ai/v3/anthropic` for the Anthropic endpoint. |
| `COPILOT_PROVIDER_TYPE`     | No       | Provider type: `openai` (default) or `anthropic`.                                                                                                      |
| `COPILOT_PROVIDER_API_KEY`  | Yes      | **Orq.ai** [API key](/docs/ai-studio/organization/api-keys).                                                                                           |
| `COPILOT_MODEL`             | Yes      | **AI Gateway** model identifier in `provider/model_id` format. Also settable with the `--model` flag.                                                  |

## Troubleshooting

<AccordionGroup>
  <Accordion title="Requests failing with 401 Unauthorized">
    Confirm `COPILOT_PROVIDER_API_KEY` is exported in the current shell and holds a valid **Orq.ai** [API key](/docs/ai-studio/organization/api-keys) (not a GitHub, OpenAI, or Anthropic key). Run `echo $ORQ_API_KEY` to verify.
  </Accordion>

  <Accordion title="400 invalid model format">
    Set `COPILOT_MODEL` to the `provider/model_id` format (e.g. `anthropic/claude-sonnet-4-6`). Bare model IDs are rejected by the router.
  </Accordion>

  <Accordion title="Model returns a capability error">
    The selected model must support tool calling and streaming. Choose a different model from [Workspace Settings → Models](https://my.orq.ai/settings/models).
  </Accordion>

  <Accordion title="No Traces appearing in Orq.ai">
    Confirm `COPILOT_PROVIDER_BASE_URL` points to `https://api.orq.ai/v3/router` or `https://api.orq.ai/v3/anthropic` and the API key is a valid **Orq.ai** key. Requests sent to the wrong endpoint will not appear in [**Orq.ai** Traces](/docs/ai-studio/observability/traces).
  </Accordion>
</AccordionGroup>

## Verification

Launch Copilot CLI with the provider variables set and send a prompt. The response appears in the session and the trace appears in [**Orq.ai** Traces](/docs/ai-studio/observability/traces) with the model identifier set in `COPILOT_MODEL`.
