Configuring Custom AI Models in VS Code via BYOK
Visual Studio Codego watch the original →
the gist
Visual Studio Code now supports custom AI model endpoints, allowing developers to bypass default Copilot models by configuring third-party API keys or using local model extensions.
Configuring Custom Endpoints
Developers can integrate third-party AI providers into GitHub Copilot Chat by manually defining custom endpoints in the chat-language-models.json configuration file. This process requires an API key from a provider like OpenRouter and the specific model metadata, including the endpoint URL, model ID, and token limits.
To configure a custom model, follow these steps:
- Open the Copilot Chat window and click the gear icon to access the language model selector.
- Select "Add models" and choose "Add a custom endpoint."
- Input the provider name and API key to generate the
chat-language-models.jsonfile. - Populate the JSON schema with the model's
name,id,url(e.g.,https://openrouter.ai/api/v1),maxInputTokens, andmaxOutputTokens. - Enable features like
supportsToolCallingandsupportsVisionif the model supports them. - Save the file to make the model available in the Copilot Chat dropdown menu.
Using Model Extensions
Beyond manual configuration, developers can use extensions to manage model access. The Foundry Toolkit extension provides a managed interface for discovering and connecting to models hosted in Microsoft Azure or locally. This extension simplifies the process by providing a model catalog where users can filter by local hosting options, such as DeepSeek or Phi, and integrate them directly into the VS Code environment without manual JSON configuration.