Connect Agent Tools

VS Code

Connect VS Code to AutoRouter via GitHub Copilot Chat BYOK (Bring Your Own Key)

VS Code

Visual Studio Code is Microsoft's open-source code editor. Starting with VS Code 1.122, GitHub Copilot Chat supports BYOK (Bring Your Own Key) mode. Through the Custom Endpoint provider, you can connect any OpenAI-compatible, Responses API, or Anthropic Messages API endpoint โ€” including AutoRouter โ€” and use models distributed through your AutoRouter gateway directly in VS Code.

Requires the GitHub Copilot Chat extension and VS Code 1.122 or later. Copilot Business / Enterprise users must have their organization administrator enable the "Bring Your Own Language Model Key in VS Code" policy in GitHub Copilot settings.

๐Ÿ“ฆ Prerequisites

What you'll need

  • VS Code 1.122 or later installed
  • The GitHub Copilot Chat extension installed and enabled
  • An AutoRouter endpoint
  • An AutoRouter API key (generated in the console)
  • A model ID exactly matching one exposed by your AutoRouter console (e.g. claude-sonnet-4-6, gpt-5.4)

๐Ÿš€ Step 1: Add a Custom Endpoint Provider

  1. Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P).
  2. Run Chat: Manage Language Models.
  3. Select Add โ†’ Custom Endpoint.
  4. Fill in the prompts:
    • Group name: e.g. AutoRouter
    • API Key: your AutoRouter API key (VS Code stores it securely and generates an ${input:chat.lm.secret...} reference in the config file)
    • API type: choose based on the models you want to connect (see table below)
  5. VS Code opens the chatLanguageModels.json configuration file.

Choosing an API type

API TypeBest forAutoRouter endpoint
chat-completionsGPT, DeepSeek, Gemini, and other OpenAI-compatible modelshttps://autorouter.top/v1/chat/completions
responsesModels supporting the OpenAI Responses APIhttps://autorouter.top/v1/responses
messagesClaude and other Anthropic-protocol models (recommended)https://autorouter.top/v1/messages

For Claude and other reasoning models, prefer the messages type to avoid 400 errors caused by reasoning_content round-tripping under the Chat Completions protocol.

๐Ÿ”ง Step 2: Configure Models

Fill in model details in chatLanguageModels.json. The example below connects multiple protocol types in one provider group:

[
  {
    "name": "AutoRouter",
    "vendor": "customendpoint",
    "apiKey": "${input:chat.lm.secret.example}",
    "apiType": "messages",
    "models": [
      {
        "id": "claude-sonnet-4-6",
        "name": "Claude Sonnet 4.6 (AutoRouter)",
        "url": "https://autorouter.top/v1/messages",
        "apiType": "messages",
        "toolCalling": true,
        "vision": true,
        "maxInputTokens": 200000,
        "maxOutputTokens": 8192
      },
      {
        "id": "gpt-5.4",
        "name": "GPT 5.4 (AutoRouter)",
        "url": "https://autorouter.top/v1/chat/completions",
        "apiType": "chat-completions",
        "toolCalling": true,
        "vision": true,
        "maxInputTokens": 128000,
        "maxOutputTokens": 16384
      }
    ]
  }
]

Key fields

  • Use the ${input:chat.lm.secret...} reference that VS Code generates when you add the provider โ€” do not paste a raw API key into the JSON file.
  • id must exactly match the model ID exposed in your AutoRouter console.
  • url must be the full endpoint URL (including /v1/chat/completions, /v1/messages, or /v1/responses).
  • Set toolCalling / vision to true if the model supports those capabilities; otherwise Agent mode may not use them.

After saving, the models appear in the Copilot Chat model picker.

โœ… Step 3: Verify the Connection

  1. Open the Copilot Chat panel in VS Code.
  2. Select your AutoRouter model from the model picker (e.g. Claude Sonnet 4.6 (AutoRouter)).
  3. Send a test message, for example:
Write a Python function that reads a JSON file

If the model responds normally, the connection is working.

๐Ÿ”„ Switching Models

Switch models directly from the Copilot Chat model picker. To add more models, append entries to the models array in chatLanguageModels.json and save.

โ“ Common Issues

Custom Endpoint option not visible

  • Confirm VS Code is version 1.122 or later (Help โ†’ About).
  • Confirm the GitHub Copilot Chat extension is installed.
  • Copilot Business / Enterprise users must have BYOK enabled by their administrator.

401 Unauthorized or connection errors

  • Verify the API key is correct; regenerate it in the AutoRouter console if needed.
  • Confirm url is a full endpoint URL and id matches the model ID in your AutoRouter console.

Claude models return 400 Bad Request

Change the model's apiType to messages and set url to https://autorouter.top/v1/messages.

Utility features unavailable without a GitHub login

When not signed into GitHub, built-in utility models (e.g. title generation) are unavailable. Set chat.utilityModel and chat.utilitySmallModel to your configured BYOK models in settings.

Agent mode cannot call tools

Confirm toolCalling is set to true in the model config, and that the selected model supports Tool Calling in AutoRouter.

On this page