multi-router.aidocs

Agents & Editors

GitHub Copilot

Connecting GitHub Copilot chat in VS Code to an Adaptive Router through a Custom Endpoint model.

GitHub Copilot in VS Code can use models from a Custom Endpoint alongside GitHub's own. A Custom Endpoint with the Chat Completions API type sends Copilot chat and agent requests to an Adaptive Router, with the router header added to each model's request headers.

Creating the router

GitHub Copilot connects through an Adaptive Router, which accepts OpenAI Chat Completions requests and serves each one with the model it names, using the organization's provider key for that model's provider. GitHub Copilot holds only the Multi-Router API key. See Adaptive Router. To set it up:

  1. In Model Groups, create or choose a model group with the models GitHub Copilot should use. See Model Group.
  2. In Routers, choose New router, then Adaptive Router. Name it, choose the model group, and switch on the models to serve.
  3. Choose the organization's provider key for each provider in the group, and create the router. Its id, such as rt_XXXXXXXX, is on the router's page.
  4. In API Keys, create a key with the inference scope. It can be limited to this router. See API Key.

Every request carries the router id in the X-MR-Router header and the API key as a Bearer token, both set in GitHub Copilot's settings below.

Settings

  1. In VS Code, open the chat model picker and choose Manage Language Models, or run Chat: Manage Language Models.
  2. Choose Add Models, then Custom Endpoint. Enter a group name, a display name and the Multi-Router API key.
  3. Choose the Chat Completions API type. VS Code opens chatLanguageModels.json to describe the models.
  4. Add each model with the full Chat Completions URL and the router header, and save.
chatLanguageModels.json, one modeljson
{
  "id": "anthropic/claude-sonnet-4.6",
  "name": "Claude Sonnet 4.6 (Multi-Router)",
  "url": "https://api.multi-router.ai/v1/chat/completions",
  "toolCalling": true,
  "maxInputTokens": 200000,
  "maxOutputTokens": 64000,
  "requestHeaders": {
    "Authorization": "Bearer ${apiKey}",
    "X-MR-Router": "rt_XXXXXXXX"
  }
}

${apiKey} is replaced with the stored API key when the request is sent. Only models with toolCalling: true are offered to Copilot's agent. On Copilot Business and Enterprise, an admin first enables the Bring Your Own Language Model Key in VS Code policy on GitHub.com.

Models

An Adaptive Router names models by their Multi-Router catalog id, provider/model, such as anthropic/claude-sonnet-4.6, openai/gpt-5 or google/gemini-2.5-flash. The model must be switched on in the router's model group; a request for any other model is refused with a message listing the models the router serves. The settings on this page list each model id explicitly.

The model's id is the catalog id sent to Multi-Router; name is the label in the model picker. Inline suggestions, semantic search and embeddings still use GitHub's models.

Checking the setup

Choose the model in the chat model picker and say hello.

The request then appears in Traffic with the Adaptive Router in the Router column and the model, tokens and cost in the request detail. A reply with the requested model or router was not found means the router id is wrong, or the API key is not allowed to use that router. See Traffic and Troubleshooting.

AiderZed
Was this helpful?