Complete Bring Your Own Key (BYOK) configuration for VS Code Copilot Chat with Groq, Cerebras, OpenRouter, and Google Gemini, including a workaround for the
No lowest priority node foundbug in theprompt-tsxrenderer.
- What is this?
- Features
- Project Stats
- Quick Start
- Repository Structure
- Prerequisites
- Installation
- Usage
- Troubleshooting
- Free Tier Limits
- Documentation
- Contributing
- License
This repository contains all the configuration, scripts, and documentation needed to set up GitHub Copilot Chat in VS Code using your own API keys from 5 providers:
- Groq (Llama 3.3 70B, Llama 4 Scout, Qwen3, GPT-OSS 120B/20B)
- Cerebras (GPT-OSS 120B, Zai GLM 4.7, Gemma 4 31B — ultra-fast inference)
- OpenRouter (2 keys — 23 free models including Nemotron 550B, Qwen3 Coder, Hermes 405B)
- Google Gemini (Gemini 2.5 Flash/Pro, Gemini 3.5 Flash, etc.)
After 9 iterations (v1 to v9), a working configuration was achieved that:
- Enables Agent mode (file creation, code editing, tool calling) with Llama 4 Scout from Groq
- Enables Ask mode with all other models
- Solves the
No lowest priority node foundbug in theprompt-tsxrenderer - Solves the
Missing Authentication headerbug with custom endpoints - Preserves native OpenRouter and Gemini providers
- Automated setup with a single PowerShell script
- API keys stored in Windows Credential Manager (not in plaintext)
- Models grouped by use case (Agent, Ask, Cerebras Ultra Fast)
- Pinned models automatically in the picker
- Corrupt state cleanup integrated
- Live tool calling debug against each provider
- Complete documentation of every bug found and its root cause
- Automatic backup before every change
| Metric | Value |
|---|---|
| Script iterations | 9 (v1 → v9) |
| Bugs solved | 7 |
| Supported providers | 5 |
| Configured models | 31 (in full configuration) |
| GitHub issues analyzed | 12+ |
| Documentation lines | 1,500+ |
| PowerShell script lines | ~410 |
| Python script lines | ~50 |
# 1. Clone the repo
git clone https://github.com/your-username/vscode-byok-copilot.git
cd vscode-byok-copilot
# 2. Edit the API keys in the script
notepad scripts/byok-master.ps1
# Replace the $keys values with your real API keys
# 3. Run the script
powershell -ExecutionPolicy Bypass -File .\scripts\byok-master.ps1
# 4. Follow the on-screen instructionsImportant: Before running the script, you must add the 5 providers via VS Code UI (
Chat: Manage Language Models → Add Models) so the API keys are stored in Windows Credential Manager. The-SetupModescript flag shows detailed instructions.
vscode-byok-copilot/
├── README.md # This file
├── LICENSE # MIT License
├── .gitignore
├── CHANGELOG.md # Version history
├── docs/
│ ├── complete-report.md # Full technical report (1,500+ lines)
│ ├── bugs-found.md # Analysis of each bug and its solution
│ ├── architecture.md # Request flow diagram
│ └── images/ # Screenshots
├── scripts/
│ ├── byok-master.ps1 # Master script (full setup)
│ ├── debug-tools.ps1 # Live tool calling debug
│ ├── clean-chats.ps1 # Quick cleanup of corrupt chats
│ ├── test-keys.ps1 # API key verification
│ ├── show-models.ps1 # Discover available models
│ └── modify_state.py # Modify state.vscdb (Python)
├── config/
│ ├── chatLanguageModels.json # Final config (template)
│ ├── settings.json # VS Code settings (template)
│ └── examples/ # Example configurations
└── references/
└── links.md # Links to official docs and issues
| Component | Min Version | How to verify |
|---|---|---|
| VS Code | 1.122+ (1.127+ recommended) | Help → About |
| GitHub Copilot | latest | Extensions panel |
| GitHub Copilot Chat | latest | Extensions panel |
| PowerShell | 5.1+ | $PSVersionTable |
| Python | 3.8+ (with py launcher) |
py --version |
| Git | any version | git --version |
Create an account and generate an API key on each platform:
| Provider | URL to get key | Free tier |
|---|---|---|
| Groq | https://console.groq.com/keys | No credit card required |
| Cerebras | https://cloud.cerebras.ai/ | Free trial, 1M tokens/day |
| OpenRouter | https://openrouter.ai/keys | Up to 5 keys per account |
| Google Gemini | https://aistudio.google.com/apikey | 20 req/day per model |
git clone https://github.com/your-username/vscode-byok-copilot.git
cd vscode-byok-copilotEdit scripts/byok-master.ps1 and replace the $keys values:
$keys = @{
Groq = "gsk_YOUR_KEY_HERE"
Cerebras = "csk_YOUR_KEY_HERE"
OpenRouter1 = "sk-or-v1_YOUR_KEY_1_HERE"
OpenRouter2 = "sk-or-v1_YOUR_KEY_2_HERE"
Gemini = "AIza_YOUR_KEY_HERE"
}This is essential for API keys to be stored in Windows Credential Manager.
- Open VS Code
Ctrl+Shift+P→Chat: Manage Language Models- Click
+ Add Models - Add the 5 providers following the script instructions:
powershell -ExecutionPolicy Bypass -File .\scripts\byok-master.ps1 -SetupMode- Close VS Code completely
powershell -ExecutionPolicy Bypass -File .\scripts\byok-master.ps1The script:
- Closes VS Code
- Backs up current configuration
- Cleans corrupt chats and caches
- Writes
chatLanguageModels.jsonwith configured models - Writes
settings.jsonwith critical settings - Modifies
state.vscdbto pin models - Verifies API keys work
- Opens VS Code
Ctrl+Shift+P→Developer: Reload WindowCtrl+Shift+P→Chat: Manage Language Models- Click the
>arrow next to each group to expand - Hover over each model → click the eye icon to show it
- To pin: hover → click the pin icon
- Open a new chat (
Ctrl+Alt+I) - Select
Llama 4 Scout - Main Agent - Agent mode
- Prompt:
"Create a file factorial.py with a recursive factorial function"
For creating files, editing code, full projects.
| Model | Provider | Recommended for |
|---|---|---|
| Llama 4 Scout | Groq | Main agent, quick files |
| Nemotron 3 Ultra 550B | OpenRouter (free) | Full projects, 1M context |
| Qwen3 Coder | OpenRouter (free) | Code, 1M context |
| Gemini 2.5 Pro | Heavy reasoning | |
| Gemini 3.5 Flash | Quick tasks with tools |
For questions, generating snippets, explaining code.
| Model | Provider | Recommended for |
|---|---|---|
| Llama 3.3 70B | Groq | Generating standalone functions |
| GPT-OSS 120B | Groq | Reasoning without tools |
| GPT-OSS 120B | Cerebras | Ultra fast (3000 tok/s) |
| Zai GLM 4.7 | Cerebras | Max speed (1000 tok/s) |
In the VS Code chat, above the input, there's a dropdown that says Agent or Ask. Click to switch.
Cause: The prompt-tsx renderer corrupts when processing tool calls from custom endpoints when maxInputTokens is less than the tools payload (~25k tokens).
Solutions:
- New chat: Don't reuse chats that errored
- Use Llama 4 Scout (TPM=30,000) for Agent mode
- Switch to Ask mode for other models
- Run quick cleanup:
powershell -ExecutionPolicy Bypass -File .\scripts\clean-chats.ps1
Cause: Plaintext API key doesn't work with toolCalling: true.
Solution: Add the provider via UI so VS Code stores the key in Credential Manager with reference ${input:chat.lm.secret.xxx}.
Cause: VS Code's payload (25k-37k tokens with tools) exceeds the free tier TPM.
Solutions:
- Switch to Ask mode (no tools, ~1k token payload)
- Use Llama 4 Scout (TPM=30,000)
- Reduce
maxInputTokens(but > 21k to avoid pruning bug)
Cause: Cerebras has a context window of 8,192 tokens (not 30k).
Solution: Reduce maxInputTokens to 7000. Don't attach large files.
Cause 1: You're in Agent mode and the model has toolCalling: false.
Solution: Switch to Ask mode.
Cause 2: The model is hidden in state.vscdb.
Solution: Chat: Manage Language Models → click the model's eye icon.
See docs/bugs-found.md for the complete analysis of each error.
| Model | RPM | RPD | TPM | TPD |
|---|---|---|---|---|
llama-3.1-8b-instant |
30 | 14,400 | 6,000 | 500,000 |
llama-3.3-70b-versatile |
30 | 1,000 | 12,000 | 100,000 |
meta-llama/llama-4-scout-17b-16e-instruct |
30 | 1,000 | 30,000 | 500,000 |
qwen/qwen3-32b |
60 | 1,000 | 6,000 | 500,000 |
openai/gpt-oss-120b |
30 | 1,000 | 8,000 | 200,000 |
openai/gpt-oss-20b |
30 | 1,000 | 8,000 | 200,000 |
| Model | RPM | TPM | Context window |
|---|---|---|---|
gpt-oss-120b |
5 | 30,000 | 8,192 |
zai-glm-4.7 |
5 | 30,000 | 8,192 |
gemma-4-31b |
1 | 30,000 | 8,192 |
- 23
:freemodels available (June 2026) - Up to 1M tokens of context in some models
- They change constantly
- 20 requests/day per model
- 39 models available
- Complete Report — Exhaustive technical documentation (1,500+ lines)
- Bugs Found — Analysis of each bug and its root cause
- Architecture — Request flow diagram
- References — Links to official docs and GitHub issues
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
- Adapt scripts for Linux/macOS (bash/zsh)
- Support for more providers (Mistral, DeepSeek, Together AI)
- Uninstall script
- Automated tests
- CI/CD with GitHub Actions
- Microsoft VS Code team — for the official BYOK documentation
- Groq — for the generous free tier
- Cerebras — for ultra-fast inference
- OpenRouter — for the model aggregator
- Google AI Studio — for the Gemini free tier
- r/GithubCopilot community — for reporting bugs and sharing solutions
- This project is NOT affiliated with Microsoft, GitHub, Groq, Cerebras, OpenRouter, or Google
- API keys used in examples are for illustration and should be replaced with your own
- Each provider's free tier may change without notice
- The
No lowest priority node foundbug is a VS Code bug, not a bug in this project
Found this useful? Star the repo and share it with the community.