Skip to main content
This guide provides instructions for integrating GitHub Copilot with the TrueFoundry AI Gateway.

Quick setup

With GitHub Copilot CLI installed, install the setup tool, then run:
Select GitHub Copilot CLI and any other agents you want to configure. To set up only GitHub Copilot CLI, run:
Sign in to your organization, choose models and any MCP servers or Skills you need, then review and approve the changes. Follow the completion summary for any remaining steps. See Set Up Your IDEs for the full walkthrough. This command configures the Copilot CLI. For VS Code’s built-in chat, see VS Code quick setup; for Copilot-specific VS Code and organization settings or manual CLI configuration, follow the instructions below.
Copilot routes through the AI Gateway only via BYOK — you point Copilot at TrueFoundry as an OpenAI-compatible endpoint. Only Chat, agent, and CLI traffic can be routed this way. Inline ghost-text completions always run on GitHub’s hosted models and cannot be routed through any gateway.

Prerequisites

Before integrating GitHub Copilot with TrueFoundry, ensure you have:
  1. TrueFoundry Account: Create a TrueFoundry account with at least one model provider configured and generate a Personal Access Token by following the instructions in Generating Tokens. For a quick setup guide, see our Gateway Quick Start
  2. GitHub Copilot Subscription: An active GitHub Copilot plan (Free, Pro, Business, or Enterprise)
  3. VS Code or Copilot CLI: Visual Studio Code (stable) with the GitHub Copilot extension, or the GitHub Copilot CLI
The credential Copilot asks for is always your TrueFoundry Personal Access Token (PAT) — not an OpenAI/Anthropic provider key. Provider credentials stay in the AI Gateway and are never seen by Copilot. The model must support tool calling and streaming (Copilot is agentic); ≥128k context is recommended.

Integration Guide (VS Code)

Copilot Chat in VS Code uses VS Code’s Custom Endpoint provider to add your own models. The setup, the chatLanguageModels.json format for the Chat Completions, Responses, and Messages APIs, request headers, and utility model settings are covered in the VS Code guide. It works whether or not you’re signed in to GitHub, unless your Copilot Business or Enterprise admin has turned off bring-your-own-key models.

Integration Guide (Copilot CLI)

The GitHub Copilot CLI supports BYOK through three environment variables. It uses the OpenAI JS SDK and calls {BASE_URL}/chat/completions.
  • No settings.json for BYOK. ~/.copilot/settings.json cannot set the provider base URL or API key. Persist the configuration via your shell profile, direnv, or MDM-pushed environment variables.
  • No custom headers. The CLI sends only a single Authorization: Bearer header — it has no equivalent of the VS Code requestHeaders field. If you need to attach headers (e.g., x-tfy-metadata), bake the values into the PAT / virtual account on the AI Gateway side, or run a local proxy that injects them.
In BYOK mode the CLI authenticates with only your COPILOT_PROVIDER_API_KEY (the TrueFoundry PAT). No GitHub OAuth token or Copilot session token is sent to the AI Gateway, and no gateway traffic is visible to GitHub.

Enterprise / Organization BYOK

For GitHub Copilot Business and Enterprise users, organization and enterprise admins can register TrueFoundry as a custom model provider at the org or enterprise level. This pushes TrueFoundry-routed models to every team member’s Copilot Chat model picker.
1

Navigate to Copilot Settings

Go to your GitHub organization or enterprise settings, then navigate to Copilot → AI controls → Configure allowed models → Custom models tab.
2

Add TrueFoundry API Key

Click Add API key and configure:
  • Provider: Select OpenAI-compatible providers
  • Name: Enter a descriptive name (e.g., “TrueFoundry AI Gateway”)
  • API Key: Enter your TrueFoundry Personal Access Token
  • Available models: Add your desired models using the fully qualified provider-name/model-name format
3

Configure Access

Choose which organizations can access the models and save the configuration. The models will appear in the Copilot Chat model picker for all enabled users, listed under your enterprise or organization name. When set at the enterprise level, the configuration is non-overridable by member organizations.
With Enterprise BYOK, usage is billed directly through your TrueFoundry account and does not count against GitHub Copilot’s built-in premium request quotas. This lets teams leverage existing contracts and credits.

Virtual Model Configuration (Optional)

If your models or Copilot setup requires standard model names (e.g., gpt-4o instead of openai-main/gpt-4o), create a Virtual Model in TrueFoundry to map standard names to fully qualified model names:
  1. Navigate to AI Gateway → Models → Virtual Model in the TrueFoundry dashboard.
TrueFoundry Virtual Models dashboardTrueFoundry Virtual Models dashboard
  1. Create a new Virtual Model Provider Group with a name (e.g., copilot-vm) and configure collaborators for access control.
  2. Add your target model (e.g., openai-main/gpt-4o) under the provider group. Set the Virtual Model name to the standard model name (e.g., gpt-4o), so requests for gpt-4o are automatically routed to openai-main/gpt-4o through the TrueFoundry AI Gateway.
For more details, see the Virtual Models documentation.

Fleet-wide enforcement

Gateway config: per user. GitHub states that local BYOK (COPILOT_PROVIDER_BASE_URL, COPILOT_PROVIDER_API_KEY, COPILOT_MODEL, and the VS Code custom endpoint) is not controlled by enterprise policies. Enterprise or organization BYOK puts gateway models in every member’s picker and can’t be overridden by member orgs, but it doesn’t stop a user choosing a GitHub-hosted model; inline completions always use GitHub’s models regardless. Push the CLI variables through MDM and use network policy for the rest. MCP servers: enforceable. Copilot in VS Code reads remote servers from .vscode/mcp.json (type: http or sse, url, headers); Copilot CLI from ~/.copilot/mcp-config.json or copilot mcp add --transport http. Point them at the MCP Gateway. Two admin layers restrict them: VS Code device policies (ChatAllowedMcpServers, ChatDeniedMcpServers, ChatAllowManagedMcpServersOnly, McpGalleryServiceUrl for a private registry), delivered by Group Policy, macOS profile, or /etc/vscode/policy.json; and Copilot’s managed-settings.json with allowedMcpServers / deniedMcpServers by URL or name, delivered by MDM, server-side, or at /Library/Application Support/GitHub Copilot/managed-settings.json, %ProgramFiles%\GitHub Copilot\managed-settings.json, or /etc/github-copilot/managed-settings.json. The organization-level “MCP servers in Copilot” policy is the master switch. See GitHub’s enterprise MCP allowlist and VS Code’s enterprise policies.