Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VS Code Copilot Chat BYOK — Definitive Guide

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 found bug in the prompt-tsx renderer.

VS Code Platform


Table of Contents


What is this?

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 found bug in the prompt-tsx renderer
  • Solves the Missing Authentication header bug with custom endpoints
  • Preserves native OpenRouter and Gemini providers

Features

  • 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

Project Stats

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

Quick Start

# 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 instructions

Important: 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 -SetupMode script flag shows detailed instructions.


Repository Structure

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

Prerequisites

Software

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

Accounts and API Keys

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

Installation

Step 1: Clone the repository

git clone https://github.com/your-username/vscode-byok-copilot.git
cd vscode-byok-copilot

Step 2: Configure your API keys

Edit 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"
}

Step 3: Add providers via UI (CRITICAL)

This is essential for API keys to be stored in Windows Credential Manager.

  1. Open VS Code
  2. Ctrl+Shift+PChat: Manage Language Models
  3. Click + Add Models
  4. Add the 5 providers following the script instructions:
powershell -ExecutionPolicy Bypass -File .\scripts\byok-master.ps1 -SetupMode
  1. Close VS Code completely

Step 4: Run the master script

powershell -ExecutionPolicy Bypass -File .\scripts\byok-master.ps1

The script:

  1. Closes VS Code
  2. Backs up current configuration
  3. Cleans corrupt chats and caches
  4. Writes chatLanguageModels.json with configured models
  5. Writes settings.json with critical settings
  6. Modifies state.vscdb to pin models
  7. Verifies API keys work
  8. Opens VS Code

Step 5: Enable models in the picker

  1. Ctrl+Shift+PDeveloper: Reload Window
  2. Ctrl+Shift+PChat: Manage Language Models
  3. Click the > arrow next to each group to expand
  4. Hover over each model → click the eye icon to show it
  5. To pin: hover → click the pin icon

Step 6: Test

  1. Open a new chat (Ctrl+Alt+I)
  2. Select Llama 4 Scout - Main Agent
  3. Agent mode
  4. Prompt: "Create a file factorial.py with a recursive factorial function"

Usage

Agent Mode (with tool calling)

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 Google Heavy reasoning
Gemini 3.5 Flash Google Quick tasks with tools

Ask Mode (without tool calling)

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)

How to switch modes

In the VS Code chat, above the input, there's a dropdown that says Agent or Ask. Click to switch.


Troubleshooting

No lowest priority node found

Cause: The prompt-tsx renderer corrupts when processing tool calls from custom endpoints when maxInputTokens is less than the tools payload (~25k tokens).

Solutions:

  1. New chat: Don't reuse chats that errored
  2. Use Llama 4 Scout (TPM=30,000) for Agent mode
  3. Switch to Ask mode for other models
  4. Run quick cleanup:
    powershell -ExecutionPolicy Bypass -File .\scripts\clean-chats.ps1

Invalid API Key / Missing Authentication header

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}.

413 Request too large

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)

context_length_exceeded in Cerebras

Cause: Cerebras has a context window of 8,192 tokens (not 30k).

Solution: Reduce maxInputTokens to 7000. Don't attach large files.

Models don't appear in picker

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.


Free Tier Limits

Groq Free Tier (March 2026)

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

Cerebras Free Trial

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

OpenRouter Free Tier

  • 23 :free models available (June 2026)
  • Up to 1M tokens of context in some models
  • They change constantly

Gemini Free Tier

  • 20 requests/day per model
  • 39 models available

Documentation


Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

Areas needing help

  • Adapt scripts for Linux/macOS (bash/zsh)
  • Support for more providers (Mistral, DeepSeek, Together AI)
  • Uninstall script
  • Automated tests
  • CI/CD with GitHub Actions

Acknowledgments


Disclaimer

  • 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 found bug is a VS Code bug, not a bug in this project

Found this useful? Star the repo and share it with the community.

About

Complete BYOK setup for VS Code Copilot Chat with Groq, Cerebras, OpenRouter and Gemini. Includes PowerShell scripts, debug tools, and workaround for the "No lowest priority node found" bug. Agent mode + Ask mode functional.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages