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.
- Website: https://code.visualstudio.com
- Documentation: VS Code language models
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
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P). - Run Chat: Manage Language Models.
- Select Add โ Custom Endpoint.
- 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)
- Group name: e.g.
- VS Code opens the
chatLanguageModels.jsonconfiguration file.
Choosing an API type
| API Type | Best for | AutoRouter endpoint |
|---|---|---|
chat-completions | GPT, DeepSeek, Gemini, and other OpenAI-compatible models | https://autorouter.top/v1/chat/completions |
responses | Models supporting the OpenAI Responses API | https://autorouter.top/v1/responses |
messages | Claude and other Anthropic-protocol models (recommended) | https://autorouter.top/v1/messages |
For Claude and other reasoning models, prefer the
messagestype to avoid400errors caused byreasoning_contentround-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. idmust exactly match the model ID exposed in your AutoRouter console.urlmust be the full endpoint URL (including/v1/chat/completions,/v1/messages, or/v1/responses).- Set
toolCalling/visiontotrueif 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
- Open the Copilot Chat panel in VS Code.
- Select your AutoRouter model from the model picker (e.g.
Claude Sonnet 4.6 (AutoRouter)). - Send a test message, for example:
Write a Python function that reads a JSON fileIf 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
urlis a full endpoint URL andidmatches 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.