-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add blog post: Use your own language model key in VS Code #9908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cinnamon-msft
wants to merge
8
commits into
main
Choose a base branch
from
blog/byok-vscode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
08905b2
Add blog post: Use your own language model key in VS Code
cinnamon-msft c1af626
Apply suggestions from code review
cinnamon-msft 71b83a7
Fix more stuff
cinnamon-msft 94ed9d4
Address remaining comments
cinnamon-msft 8bfcf43
Add in keynote bits
cinnamon-msft 0ce99a1
nits
cinnamon-msft e90390f
Small tweaks
cinnamon-msft cb517ac
Swap Azure example for Mistral
cinnamon-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| --- | ||
| Order: 131 | ||
| TOCTitle: Bring Your Own Key | ||
| PageTitle: "Use your own language model key or local model in VS Code" | ||
| MetaDescription: Learn how to use bring your own key (BYOK) in VS Code to add models from providers like Azure, Anthropic, Gemini, OpenAI, Huggingface, OpenRouter, or use a local model with Ollama, Foundry Local, and more. | ||
| MetaSocialImage: language-models-editor.png | ||
| Date: 2026-06-09 | ||
| Author: Kayla Cinnamon | ||
| --- | ||
|
|
||
| # Use your own language model key in VS Code | ||
|
|
||
| June 9, 2026 by [Kayla Cinnamon](https://github.com/cinnamon-msft) | ||
|
|
||
| At Microsoft Build this year, I had the opportunity to present in the opening keynote. One thing I showed was using local models inside VS Code on the new Surface RTX Spark Dev Box. My model was periodically analyzing my log files and giving me summaries, so I could easily diagnose issues without having to look through the logs myself. Check out the [recording at 12:18](https://build.microsoft.com/sessions/KEY01). | ||
|
|
||
| Using local models gives you even greater flexibility when working with agents. Sometimes you want the built-in models available through GitHub Copilot. Sometimes you want to try a new model from a provider your team already uses. Sometimes you want to experiment locally. VS Code allows you to do all of these workflows with bring your own language model key (BYOK) and bring your own local model. | ||
|
|
||
| With BYOK in VS Code, you can add models from providers like Azure, Anthropic, Huggingface, Gemini, OpenAI, OpenRouter, or you can run a model locally with Ollama, Foundry Local, and more, then use them directly from the Chat model picker. | ||
|
|
||
|  | ||
|
|
||
| ## What is BYOK? | ||
|
|
||
| BYOK lets you use a language model from a supported provider by adding your own API key or endpoint configuration in VS Code. Once configured, those models appear in the same Chat model picker you already use for Copilot. Support is built in for several providers and VS Code is extensible, so any model provider can enable support through an extension. | ||
|
|
||
| This gives you more choice for chat and agent workflows. For example, you can: | ||
|
|
||
| - Try models that are not built into VS Code. | ||
| - Use a provider your organization already has billing or governance set up for. | ||
| - Connect to local models through providers such as Ollama or Foundry Local. | ||
| - Pick different models for different tasks, such as quick Q&A, planning, or multi-step agent work. | ||
|
|
||
| The goal is to allow you to choose the right model and keep working. | ||
|
|
||
| ## What BYOK works with | ||
|
|
||
| BYOK models are available for VS Code chat experiences, including agent workflows when the selected model supports the required capabilities. | ||
|
|
||
| There are a few important details to keep in mind: | ||
|
|
||
| - BYOK models work **without** signing into a GitHub account and **without** a Copilot plan. You can add and use models entirely with your own API keys, including fully **offline scenarios with local models**. | ||
| - BYOK applies to chat and utility tasks, not standard code completions. | ||
| - Some AI features, such as semantic search, inline suggestions, and features that rely on embeddings, still require a GitHub account or Copilot support. | ||
| - Usage for provider-backed BYOK models is billed directly by that provider and does not count against GitHub Copilot request quotas. | ||
| - For Copilot Business and Enterprise, organization administrators can control BYOK availability through Copilot policy settings. | ||
|
|
||
| In other words, BYOK expands model choice in VS Code Chat, but it does not replace every Copilot-powered feature in the editor. | ||
|
|
||
| ## Getting started with BYOK | ||
|
|
||
| The easiest way to get started is through the **Language Models** editor. | ||
|
|
||
| You can open it from the Chat model picker by selecting the **Manage Language Models** gear icon, or you can run **Chat: Manage Language Models** from the Command Palette. | ||
|
|
||
|  | ||
|
|
||
| The Language Models editor shows the models available to you, grouped by provider. It also shows useful details like model capabilities, context size, billing information, and whether a model is visible in the picker. | ||
|
|
||
| This is also where you can keep the model picker focused. If you are testing several providers, you can hide models you do not use often and keep your day-to-day models easy to find. | ||
|
|
||
| ## Adding models from a built-in provider | ||
|
|
||
| If the provider you want is built into VS Code, setup is a few clicks. | ||
|
|
||
| 1. Open **Chat: Manage Language Models**. | ||
| 2. Select **Add Models**. | ||
| 3. Choose a provider. | ||
| 4. Enter a group name for the models. This is the label shown in the model picker and Language Models editor. | ||
| 5. Enter the provider details, such as an API key, endpoint, deployment name, or other required configuration. | ||
| 6. Select the model from the Chat model picker. | ||
|
|
||
|  | ||
|
|
||
| Depending on the provider, VS Code might open a `chatLanguageModels.json` file so you can finish configuring model details. | ||
|
|
||
| For example, a Mistral configuration specifies the endpoint URL, API type, and model capabilities: | ||
|
|
||
| ```json | ||
| [ | ||
| { | ||
| "name": "Mistral", | ||
| "vendor": "customendpoint", | ||
| "apiKey": "<your-mistral-api-key>", | ||
| "apiType": "chat-completions", | ||
| "models": [ | ||
| { | ||
| "id": "mistral-medium-latest", | ||
| "name": "mistral medium", | ||
| "url": "https://api.mistral.ai/v1/chat/completions", | ||
| "toolCalling": true, | ||
| "vision": true, | ||
| "maxInputTokens": 256000, | ||
| "maxOutputTokens": 16000 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| The exact fields depend on the provider and model. The important part is that after the provider is configured, the model becomes available from the same picker you use for the rest of Chat. For more information, check out the [docs](https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-model-from-a-built-in-provider). | ||
|
|
||
| ## Adding models from extensions | ||
|
|
||
| VS Code also supports language model provider extensions. These extensions can contribute models directly into the Language Models editor and Chat model picker. | ||
|
|
||
| To find provider extensions: | ||
|
|
||
| 1. Open the Extensions view. | ||
| 2. Search for `@tag:language-models`. | ||
| 3. Install the provider extension you want to use. | ||
| 4. Follow the extension's setup instructions. | ||
| 5. Select the model from the Chat model picker. | ||
|
|
||
|  | ||
|
|
||
| This extensibility is a big part of the BYOK story. Instead of every provider needing to be hard-coded into VS Code, extensions can bring new model providers into the editor as the ecosystem evolves. | ||
|
|
||
| ## Leveraging utility models | ||
|
|
||
| VS Code also uses lightweight models in the background for small tasks like generating chat titles, commit messages, and rename suggestions. These default to built-in Copilot models and most users won't need to touch them. But if you're using BYOK without signing into a GitHub account, those defaults aren't available. VS Code will show a notification in the Chat view prompting you to configure them. Set `setting(chat.utilityModel)` and `setting(chat.utilitySmallModel)` to one of your BYOK models to keep those features working. A fast, inexpensive model works well here. | ||
|
|
||
|  | ||
|
|
||
| ## Choosing the right model | ||
|
|
||
| One of the best parts of BYOK is that you do not have to use one model for everything. | ||
|
|
||
| For everyday work, you might choose: | ||
|
|
||
| - A fast model for quick questions, summaries, and small edits. | ||
| - A reasoning model for planning, debugging, or complex refactors. | ||
| - A local model when you want to experiment offline. | ||
| - A provider-specific model when your team already has workflows around that provider. | ||
|
|
||
| Simply choose which model you want to use in the model picker below the Chat box. | ||
|  | ||
|
|
||
| ## Try it out | ||
|
|
||
| BYOK gives you more flexibility in VS Code without adding more tools to your workflow. You can keep using the built-in Copilot models, add models from providers you already use, experiment with local models, and choose the right model for each task from one place. | ||
|
|
||
| To learn more, check out the VS Code docs on [AI language models](https://code.visualstudio.com/docs/agent-customization/language-models), the VS Code blog post on [Expanding Model Choice in VS Code with Bring Your Own Key](https://code.visualstudio.com/blogs/2025/10/22/bring-your-own-key), and the GitHub changelog entry for [BYOK availability in VS Code](https://github.blog/changelog/2026-04-22-bring-your-own-language-model-key-in-vs-code-now-available/). | ||
|
|
||
| We are continuing to improve model choice in VS Code, and your feedback helps shape what comes next. Try BYOK with your workflow and let us know what you think in the [VS Code repository](https://github.com/microsoft/vscode). | ||
|
|
||
| Happy coding! 💙 | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.