{"meta":{"title":"Using your own LLM models in GitHub Copilot CLI","intro":"Use a model from an external provider of your choice in Copilot by supplying your own API key.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos","title":"How-tos"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-cli","title":"Copilot CLI"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-cli/customize-copilot","title":"Customize Copilot CLI"},{"href":"/en/enterprise-cloud@latest/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models","title":"Use your own model provider"}],"documentType":"article"},"body":"# Using your own LLM models in GitHub Copilot CLI\n\nUse a model from an external provider of your choice in Copilot by supplying your own API key.\n\nYou can configure Copilot CLI to use your own LLM provider, also called BYOK (Bring Your Own Key), instead of GitHub-hosted models. This lets you connect to OpenAI-compatible endpoints, Azure OpenAI, or Anthropic, including locally running models such as Ollama.\n\n> \\[!NOTE]\n> This article is for users who want to configure their own LLM provider API key on their local machine. To set up custom models for users in an enterprise, see [Enabling custom models for GitHub Copilot in your enterprise](/en/enterprise-cloud@latest/copilot/how-tos/administer-copilot/manage-for-enterprise/enable-custom-models).\n\n## Prerequisites\n\n* Copilot CLI is installed. See [Installing GitHub Copilot CLI](/en/enterprise-cloud@latest/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli).\n* You have an API key from a supported LLM provider, or you have a local model running (such as Ollama).\n\n## Supported providers\n\nCopilot CLI supports three provider types:\n\n| Provider type | Compatible services                                                                                                                    |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |\n| `openai`      | OpenAI, Ollama, vLLM, Foundry Local, and any other OpenAI Chat Completions API-compatible endpoint. This is the default provider type. |\n| `azure`       | Azure OpenAI Service.                                                                                                                  |\n| `anthropic`   | Anthropic (Claude models).                                                                                                             |\n\nFor additional examples, run `copilot help providers` in your terminal.\n\n## Model requirements\n\nModels must support **tool calling** (also called function calling) and **streaming**. If a model does not support either capability, Copilot CLI returns an error. For best results, use a model with a context window of at least 128k tokens.\n\n## Configuring your provider\n\nYou configure your model provider by setting environment variables before starting Copilot CLI.\n\n| Environment variable        | Required | Description                                                                                                                |\n| --------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |\n| `COPILOT_PROVIDER_BASE_URL` | Yes      | The base URL of your model provider's API endpoint.                                                                        |\n| `COPILOT_PROVIDER_TYPE`     | No       | The provider type: `openai` (default), `azure`, or `anthropic`.                                                            |\n| `COPILOT_PROVIDER_API_KEY`  | No       | Your API key for the provider. Not required for providers that do not use authentication, such as a local Ollama instance. |\n| `COPILOT_MODEL`             | Yes      | The model identifier to use. You can also set this with the `--model` command-line flag.                                   |\n\n## Connecting to an OpenAI-compatible endpoint\n\nUse the following steps if you are connecting to OpenAI, Ollama, vLLM, Foundry Local, or any other endpoint that is compatible with the OpenAI Chat Completions API.\n\n1. Set environment variables for your provider. For example, for a local Ollama instance:\n\n   ```shell\n   export COPILOT_PROVIDER_BASE_URL=http://localhost:11434\n   export COPILOT_MODEL=YOUR-MODEL-NAME\n   ```\n\n   Replace `YOUR-MODEL-NAME` with the name of the model you have pulled in Ollama (for example, `llama3.2`).\n\n2. For a remote OpenAI endpoint, also set your API key.\n\n   ```shell\n   export COPILOT_PROVIDER_BASE_URL=https://api.openai.com/v1\n   export COPILOT_PROVIDER_API_KEY=YOUR-OPENAI-API-KEY\n   export COPILOT_MODEL=YOUR-MODEL-NAME\n   ```\n\n   Replace `YOUR-OPENAI-API-KEY` with your OpenAI API key and `YOUR-MODEL-NAME` with the model you want to use (for example, `gpt-4o`).\n\n3. Start Copilot CLI.\n\n```bash\ncopilot\n```\n\n## Connecting to Azure OpenAI\n\n1. Set the environment variables for Azure OpenAI.\n\n   ```shell\n   export COPILOT_PROVIDER_BASE_URL=https://YOUR-RESOURCE-NAME.openai.azure.com/openai/deployments/YOUR-DEPLOYMENT-NAME\n   export COPILOT_PROVIDER_TYPE=azure\n   export COPILOT_PROVIDER_API_KEY=YOUR-AZURE-API-KEY\n   export COPILOT_MODEL=YOUR-DEPLOYMENT-NAME\n   ```\n\n   Replace the following placeholders:\n\n   * `YOUR-RESOURCE-NAME`: your Azure OpenAI resource name\n   * `YOUR-DEPLOYMENT-NAME`: the name of your model deployment\n   * `YOUR-AZURE-API-KEY`: your Azure OpenAI API key\n\n2. Start Copilot CLI.\n\n```bash\ncopilot\n```\n\n## Connecting to Anthropic\n\n1. Set the environment variables for Anthropic:\n\n   ```shell\n   export COPILOT_PROVIDER_TYPE=anthropic\n   export COPILOT_PROVIDER_BASE_URL=https://api.anthropic.com\n   export COPILOT_PROVIDER_API_KEY=YOUR-ANTHROPIC-API-KEY\n   export COPILOT_MODEL=YOUR-MODEL-NAME\n   ```\n\n   Replace `YOUR-ANTHROPIC-API-KEY` with your Anthropic API key and YOUR-MODEL-NAME with the Claude model you want to use (for example, `claude-opus-4-5`).\n\n2. Start Copilot CLI.\n\n```bash\ncopilot\n```\n\n## Running in offline mode\n\nYou can run Copilot CLI in offline mode to prevent it from contacting GitHub's servers. This is designed for isolated environments where the CLI should communicate only with your local or on-premises model provider.\n\n> \\[!IMPORTANT]\n> Offline mode only guarantees full network isolation if your provider is also local or within the same isolated environment. If `COPILOT_PROVIDER_BASE_URL` points to a remote endpoint, your prompts and code context are still sent over the network to that provider.\n\n1. Configure your provider environment variables as described in Configuring your provider.\n\n2. Set the offline mode environment variable:\n\n   ```shell\n   export COPILOT_OFFLINE=true\n   ```\n\n3. 1. Start Copilot CLI.\n\n```bash\ncopilot\n```"}