GitHub Copilot BYOK: use your own API key in Copilot

Updated · 7 min read

GitHub Copilot supports bring your own key (BYOK) in two ways. You can add your own model provider in a Copilot client, such as the VS Code model picker, Copilot CLI or the GitHub Copilot app, and the client then sends those requests straight to the provider. This needs no Copilot subscription, and GitHub's docs say these requests carry no Copilot usage charges. On Copilot Business or Enterprise, an organization or enterprise owner can also add provider keys in GitHub's settings for all members (public preview). Either way, your models show up in the model picker next to the models GitHub provides.

Where you can use your own key

Client Where to add the key Providers Copilot plan needed
VS Code Model picker → Manage Language Models → Add Models Built-in providers (Anthropic, Azure, Gemini, OpenAI and others), provider extensions such as Ollama, or a Custom Endpoint No, in Local harness sessions; see the notes below
Copilot CLI ~/.copilot/providers.json or COPILOT_PROVIDER_* variables OpenAI and OpenAI-compatible APIs (Ollama, vLLM, Foundry Local), Azure OpenAI, Anthropic No, and no GitHub sign-in
GitHub Copilot app (preview) Settings → Model providers → Add provider OpenAI, Azure OpenAI, Microsoft Foundry, Anthropic, Ollama, Foundry Local, LM Studio, any OpenAI-compatible endpoint No, but you sign in with a GitHub account
JetBrains IDEs, Xcode (preview) Copilot Chat model picker → Manage Models Anthropic, Azure, Google Gemini, Groq, OpenAI, OpenRouter; JetBrains also takes OpenAI-compatible endpoints The 2025 announcement asked for a Copilot license
Eclipse (preview) Copilot Chat Not listed in the announcement Individual users, or Business and Enterprise users when the organization turns it on
Organization or enterprise keys (preview) GitHub settings: AI controls → Copilot → Configure custom models Anthropic, AWS Bedrock, Google AI Studio, Microsoft Foundry, OpenAI, OpenAI-compatible providers, xAI Copilot Business or Enterprise, and each user needs a Copilot license

GitHub's feature matrix also lists BYOK in Visual Studio, and the Copilot SDK has its own BYOK option. Neovim doesn't support it.

Set up BYOK in VS Code

  1. Open the model picker in the chat input and select Manage Language Models (the gear icon), or run Chat: Manage Language Models from the Command Palette.
  2. Select Add Models and pick a provider.
  3. Enter a group name. It labels these models in the picker.
  4. Enter the provider's details, usually the API key and sometimes an endpoint URL. For some providers VS Code opens chatLanguageModels.json so you can describe the models.
  5. Pick the new model in the chat model picker.

For a provider that isn't in the list, choose Custom Endpoint. It speaks the Chat Completions, Responses or Anthropic Messages API, which you choose per provider or per model. Store the key with an input variable such as "apiKey": "${input:myApiKey}" instead of typing the raw key into a file you might commit. Custom Endpoint replaces the old OpenAI Compatible provider and the github.copilot.chat.customOAIModels setting, both deprecated. The built-in Ollama provider is deprecated too; install the Ollama extension from the Marketplace instead.

In VS Code, BYOK covers:

  • chat and agents (a model must support tool calling to appear for agents);
  • utility tasks such as chat titles and intent detection, once you point chat.utilityModel at your model.

It doesn't cover inline suggestions (code completions), semantic search or anything that uses embeddings. Those still need a GitHub account.

VS Code now runs chat in "harnesses". In Local harness sessions, BYOK models work without a GitHub sign-in or a Copilot plan, including offline with local models. The Local harness is deprecated and will be removed in February 2027. To use BYOK models in Copilot harness sessions in the Chat view or the Agents window, turn on chat.agentHost.byokModels.enabled, which is experimental. The desktop Agents window then runs BYOK models without a GitHub sign-in; the browser-based Agents window always needs one.

On Copilot Business and Enterprise, the Bring Your Own Language Model Key in VS Code policy controls BYOK. GitHub's April 2026 changelog says the policy is on by default and an admin can turn it off.

Set up BYOK in Copilot CLI

Copilot CLI reads your providers from providers.json in its config folder, usually ~/.copilot. Set COPILOT_PROVIDERS_CONFIG to use another file.

  1. Add a provider and at least one model:

    {
      "providers": [
        {
          "name": "my-provider",
          "type": "openai",
          "baseUrl": "https://api.openai.com/v1",
          "apiKey": "YOUR-API-KEY"
        }
      ],
      "models": [
        { "id": "YOUR-MODEL-NAME", "provider": "my-provider" }
      ]
    }
    
  2. Set type to azure for Azure OpenAI or anthropic for Anthropic. Add "wireApi": "responses" for OpenAI or Azure models that use the Responses API (the default is completions). For any other OpenAI-compatible service, keep openai and change baseUrl.

  3. Restart the CLI and start a session with copilot --model my-provider/YOUR-MODEL-NAME, or switch with /model.

The file stores keys as plain text, and $MY_API_KEY in it is read as literal text, not as an environment variable. Keep it private and out of your repositories.

For a quick setup without the file, set COPILOT_PROVIDER_BASE_URL, COPILOT_PROVIDER_TYPE (openai, azure or anthropic), COPILOT_PROVIDER_API_KEY and COPILOT_MODEL. GitHub calls these variables legacy: once providers.json declares a provider or model, the file wins.

If Ollama runs on your machine, the CLI finds its models at http://127.0.0.1:11434 and lists them under Local and self-hosted in /model. Set OLLAMA_HOST if Ollama uses another address on your machine.

Models need tool calling and streaming, and GitHub suggests a context window of at least 128K tokens. Without a GitHub sign-in, /delegate, the GitHub MCP server and code search don't work, but you can sign in as well to get them back. The CLI still sends telemetry unless you set COPILOT_OFFLINE=true.

Set up BYOK in the GitHub Copilot app

  1. Open Settings (the gear icon) and select Model providers.
  2. Click Add provider and pick your provider.
  3. Enter its details, such as a display name, base URL and API key, then click Add provider.

If you have no Copilot plan, the app offers this step when you first open it. Keys go into your system's credential store. On Copilot Business or Enterprise, the app needs Copilot CLI to be enabled in your organization's policy settings.

Keys for a whole organization

Enterprise owners add keys under AI controls → Copilot → Configure custom models → Add API key: choose the provider, name the key (the name shows in the model picker) and paste it. For OpenAI, Anthropic and xAI keys, fetch the models tied to the key and select the ones you want; for Microsoft Foundry, enter the deployment URL and model IDs. Then decide which organizations can use each model. Organization owners can add their own keys once the enterprise turns on the Enable custom models policy.

These models work in Copilot Chat, Copilot CLI and IDEs, and appear at the bottom of the model picker under the enterprise's name. Unlike user BYOK, requests go through GitHub's Copilot API, so members never handle the key and usage shows up in Copilot's metrics. GitHub recommends this as the default for most organizations, with user BYOK for local models, air-gapped setups and trying new providers.

What still counts against Copilot

Copilot plans bill usage in GitHub AI Credits, where 1 credit is $0.01. On 2026-11-24, Pro costs $10 a month with 1,500 credits, Pro+ $39 with 7,000 and Max $100 with 20,000. Copilot Free and Student include an allowance of AI credits and auto model selection only.

  • GitHub's usage-metrics reference says BYOK requests have no Copilot usage charges; your provider bills the tokens. GitHub's announcements for VS Code (April 2026) and enterprise keys (November 2025) also say BYOK usage doesn't count against Copilot quotas.
  • Code completions and next edit suggestions still run on GitHub's models. They aren't billed in AI credits on paid plans, and Copilot Free includes 2,000 completions a month.
  • GitHub's BYOK docs don't list Copilot cloud agent or code review, which use AI credits.
  • To avoid charges beyond your plan, set a Bundled AI credits budget of $0 and turn on Stop usage when budget limit is reached.

Privacy

With user BYOK, the client sends your requests straight to your provider, not through GitHub's Copilot API, so your provider's data terms apply. Keys you add in the Copilot app stay in the system credential store; Copilot CLI keeps them in plain text in providers.json. Requests with organization keys go through GitHub instead, and members never handle the key. If you need full isolation, run a local model and set COPILOT_OFFLINE=true in the CLI.

Copilot and other coding tools that take your own key

  • GitHub Copilot

    Free + from $10/month · VS Code, JetBrains, CLI

    Visit

    GitHub's AI coding assistant; users can add their own model provider keys in Copilot CLI, the Copilot app and VS Code, and enterprises can add Anthropic, OpenAI, xAI, Gemini or Bedrock keys for their teams.

    Works with:AnthropicOpenAIxAIGoogle Gemini+1 more

  • Cline

    Free, open source · VS Code, JetBrains, CLI · Open source

    Visit

    Open-source AI coding agent for VS Code, JetBrains and the terminal. Bring your own key, endpoint or local model.

    Works with:AnthropicOpenAIGoogle GeminiOllama+1 more

  • Kilo Code

    Free to start, no markup on model usage · VS Code, JetBrains, CLI · Open source

    Visit

    Open-source AI coding agent for VS Code, JetBrains and the CLI. Use 500+ models at zero markup or bring your own keys.

    Works with:AnthropicOpenAIGoogle GeminiOpenRouter+8 more

  • Zed

    Free editor; paid plans for Zed-hosted AI · macOS, Windows, Linux · Open source

    Visit

    Fast open-source code editor with an AI agent that works with your own Anthropic, OpenAI, Gemini, OpenRouter or local model keys.

    Works with:AnthropicOpenAIGoogle GeminiMistral+5 more

  • OpenCode

    Free, open source · CLI, Web · Open source

    Visit

    Open-source AI coding agent for the terminal, desktop and web that works with any model provider or local models.

    Works with:OpenAIAnthropicxAI

  • Aider

    Free, open source · CLI · Open source

    Visit

    AI pair programming in your terminal. Works with your own Anthropic, OpenAI, DeepSeek and other model keys.

    Works with:AnthropicOpenAIDeepSeek

  • Cursor

    Free plan + paid plans · macOS, Windows, Linux

    Visit

    AI code editor built on VS Code. Add your own OpenAI, Anthropic, Google, Azure or Bedrock key for chat and agent models.

    Works with:OpenAIAnthropicGoogle GeminiAzure OpenAI+1 more

  • JetBrains AI Assistant

    Works with your own key; JetBrains AI plans optional · JetBrains

    Visit

    AI chat, code generation and completion inside JetBrains IDEs. Connect your own Anthropic, OpenAI or Gemini key, or local models.

    Works with:AnthropicOpenAIGoogle GeminiGoogle Vertex AI+2 more

Other coding tools

Copilot's BYOK covers chat and agents, but completions still come from GitHub. Open-source agents such as Cline, Kilo Code, Aider and OpenCode, and the Zed editor, send every AI request with your own key. Cursor takes your own key for chat models only. For more tools, see AI coding tools that support BYOK, and to reach many models with one key, see OpenRouter BYOK and the OpenRouter API key guide.

Questions

Does GitHub Copilot support bring your own key?

Yes. You can add your own model provider in VS Code, Copilot CLI, the GitHub Copilot app, JetBrains IDEs, Xcode and Eclipse, and on Copilot Business or Enterprise an admin can add provider keys for the whole organization. Your models appear in the model picker next to GitHub's.

Do I need a Copilot subscription to use my own key?

Not for user-configured BYOK. GitHub's docs say it works without a Copilot subscription: VS Code and Copilot CLI don't even need a GitHub sign-in, and the Copilot app needs a GitHub account but no plan. The 2025 announcement for JetBrains and Xcode asked for a Copilot license. Organization-wide keys need Copilot Business or Enterprise.

Do BYOK requests use my GitHub AI Credits?

No. GitHub's usage-metrics reference says BYOK requests have no Copilot usage charges; your provider bills you for the tokens. Features that still run on GitHub's models, such as code completions, keep using your plan.

How do I use my own key in Copilot CLI?

Add a provider and a model to ~/.copilot/providers.json, restart the CLI and run copilot --model PROVIDER-NAME/MODEL-NAME, or set COPILOT_PROVIDER_BASE_URL, COPILOT_PROVIDER_TYPE, COPILOT_PROVIDER_API_KEY and COPILOT_MODEL. Ollama models are found automatically under /model.

Can I use OpenRouter with GitHub Copilot?

Yes. GitHub's April 2026 changelog names OpenRouter among the VS Code providers. In Copilot CLI, add it as an openai-type provider with the base URL https://openrouter.ai/api/v1 and your OpenRouter key.

Does Copilot's code completion use my own key?

No. In VS Code, BYOK covers chat and utility tasks only. Inline suggestions, semantic search and features that use embeddings still need a GitHub account and use GitHub's models.

Sources

Checked against the providers' own documentation on 2026-11-24. Prices and limits change; the links below have the current figures.

Related guides