GitHub Copilot BYOK: Set Up an OpenAI-Compatible API in VS Code or CLI

Configure a supported BYOK model in VS Code or Copilot CLI. Check streaming, tool calling, API type and current settings before using a custom endpoint.

GitHub Copilot BYOK: Set Up an OpenAI-Compatible API in VS Code or CLI

Copilot BYOK connects a supported model provider to VS Code chat or Copilot CLI. An OpenAI-shaped text response alone does not establish compatibility: Copilot CLI requires both tool calling and streaming. VS Code and CLI have separate configuration paths.

Where you workConfigurationKey requirement
VS Code chatManage Language Models → Add Models → Custom EndpointMatch the API type and model capabilities; agents require tool calling
Copilot CLICOPILOT_PROVIDER_* environment variablesTool calling and streaming; GitHub recommends at least 128K context
Inline code completionsSeparate from these chat/BYOK settingsAdding a chat model does not replace inline completions

Updated from the official documentation on September 9, 2026. Replace the placeholders below with the settings for your provider and model.

Set up a custom endpoint in VS Code

The current VS Code model documentation supports BYOK chat without signing into GitHub or having a Copilot plan. Some features still require a GitHub account. Agent Host BYOK sessions are experimental and use a separate chat.agentHost.byokModels.enabled setting; do not assume every agent surface has identical support.

  1. Open Manage Language Models from the chat model picker or Command Palette.
  2. Choose Add Models, then Custom Endpoint.
  3. Select Chat Completions, Responses, or Messages to match your endpoint.
  4. Edit the chatLanguageModels.json file opened by VS Code. Copy the exact model ID, endpoint and limits from your provider.
  5. Select the saved model in chat. If it does not appear, restart VS Code.

This illustrative configuration uses a reserved example domain. Replace the URL, model ID and capability values before use:

[
  {
    "name": "My gateway",
    "vendor": "customendpoint",
    "apiKey": "${input:gatewayApiKey}",
    "apiType": "chat-completions",
    "models": [
      {
        "id": "your-model-id",
        "name": "My model",
        "url": "https://gateway.example/v1/chat/completions",
        "toolCalling": true,
        "vision": false,
        "maxInputTokens": 128000,
        "maxOutputTokens": 16000
      }
    ]
  }
]

The input variable keeps the secret out of the configuration text. toolCalling: true declares a capability; it cannot add tool support to a model. Set vision and token limits from the selected route’s documentation. The Custom Endpoint provider also supports automatic model discovery through its provider-level url, or an explicit models array as above.

Older articles may show github.copilot.chat.customOAIModels or describe chatLanguageModels.json as Insiders-only. Use the current model-management UI and reference for your installed VS Code version instead of copying the old settings shape.

Set up Copilot CLI

GitHub’s CLI BYOK guide documents three provider types: openai (the default), azure, and anthropic. For an OpenAI Chat Completions gateway:

export COPILOT_PROVIDER_TYPE=openai
export COPILOT_PROVIDER_BASE_URL=https://gateway.example/v1
export COPILOT_PROVIDER_API_KEY="$GATEWAY_API_KEY"
export COPILOT_MODEL=your-model-id
copilot

Replace the example URL and model ID, and load GATEWAY_API_KEY locally first. For Ofox, the Chat Completions base URL is https://api.ofox.io/v1; choose a model from the current catalog that supports streaming and tool calling on that route. An old list of model names is not proof of current availability.

For local Ollama, GitHub’s example uses http://localhost:11434 as the base URL. A provider key is optional when the local provider does not require authentication. Choose an installed model that meets the CLI requirements.

For native Anthropic, set COPILOT_PROVIDER_TYPE=anthropic and use the provider’s documented native base URL. Azure uses azure and a deployment-specific base URL and deployment name. Run copilot help providers for the examples corresponding to your CLI version.

Check compatibility before using an agent on your project

Check the provider’s model catalog and protocol documentation first. When you run your own integration test, verify a short streamed response, a tool-call response and the follow-up turn containing the tool result. A successful plain-text ping only checks basic authentication and text generation. Paid-model requests incur provider charges.

BYOK inference is billed by the selected provider. Do not assume that configuring a model changes every GitHub feature’s billing or network behavior. For isolated CLI use, GitHub documents COPILOT_OFFLINE=true; full network isolation additionally requires a local or isolated provider. A remote gateway still receives the requests.

Troubleshoot the failure you actually see

SymptomCheck
401 or 403Key ownership, environment loading, account access and organization policy
Model not foundExact model ID, selected provider and endpoint; see model-not-found checks
Model absent from VS Code pickerSaved configuration, UI version and restart; agents also require tool support
Model discovery failsProvider-level discovery URL and authentication; use explicit model entries when discovery is unsupported
CLI rejects the modelBoth streaming and tool calling are required
First turn works, tool turn failsTool schemas, streamed tool-call payloads and follow-up tool results; a capability flag is not a protocol adapter
Context errorProvider’s actual input/output limits, including tool definitions and chat history
Images failModel and selected route must support images; declare that capability accurately in VS Code

For other editors, see Cursor, Claude Code and Cline custom API setup. Their protocol and authentication settings are separate from Copilot’s.

Frequently Asked Questions

Can any OpenAI-compatible endpoint run Copilot CLI?
It must support both streaming and tool calling. Plain-text Chat Completions compatibility alone is insufficient.
Does VS Code BYOK require a Copilot subscription?
Current VS Code documentation says BYOK chat works without a GitHub sign-in or Copilot plan. Some other features still require a GitHub account.
Does adding a BYOK chat model replace inline completions?
No. Configuring a chat model does not replace the separate inline code completion feature.