VS Code with your own API key
VS Code Chat can talk to any OpenAI-compatible endpoint. Point it at GuRouter and you get every model in the catalog — a Claude model, a DeepSeek model, whatever the task needs — behind one key, and you can switch between them without leaving VS Code.
Watch on YouTube
What you need
Section titled “What you need”- A GuRouter API key. If you do not have one yet, ask your account owner for it.
- VS Code with the Chat view. BYOK support ships in VS Code 1.101 and later on the OpenAI-compatible provider path.
The configuration
Section titled “The configuration”VS Code takes a JSON array of custom endpoints, not a form. A working entry, with your key and base URL filled in:
[ { "name": "GU Router", "vendor": "customendpoint", "apiKey": "${input:chat.lm.secret.YOUR_SECRET_ID}", "apiType": "chat-completions", "models": [ { "id": "stealth/space-bunny-alpha", "name": "stealth/space-bunny-alpha", "url": "https://gurouter.com/v1/chat/completions", "apiType": "chat-completions", "toolCalling": true, "vision": true, "maxInputTokens": 128000, "maxOutputTokens": 16000 } ] }]Paste that into chatModels in settings.json, then replace YOUR_SECRET_ID with the
id of your own VS Code secret.
The fields that matter
Section titled “The fields that matter”- vendor
customendpoint- apiType
chat-completions- apiKey
${input:chat.lm.secret.…}- url
https://gurouter.com/v1/chat/completions
urlis the full endpoint, ending in/chat/completions. Unlike some clients, VS Code does not append the path for you. Leaving off/chat/completionsgives a 404.apiKeyis a secret reference, not a literal key.${input:chat.lm.secret.…}points at a secret stored in VS Code, so the key never lands in a file you might commit. See Secrets below.maxInputTokensmust be the real context size. Set it too high and VS Code will send a prompt the model cannot accept, which surfaces as a 400 rather than a useful message.toolCallingandvisionshould match what the model actually does. Claiming a capability the model lacks produces a request that fails at the tool-call step.
Storing your key
Section titled “Storing your key”Do not put a literal key in settings.json. VS Code keeps secrets separately and
${input:chat.lm.secret.…} reads from there.
The simplest path is Preferences: Configure Chat Customizations, which prompts for the
key and writes the secret reference for you. To manage secrets directly, use
Chat: Store Chat Location Secret and pass the id it reports.
Keys belong in settings.local.json, which is git-ignored, and never in a committed
settings.json.
Set it up
Section titled “Set it up”-
Store the key as a secret. Run
Chat: Store Chat Location Secretfrom the command palette and give it your GuRouter key. Note the id it returns. -
Open the BYOK settings. Run
Preferences: Configure Chat Customizations, or openchatModelsinsettings.jsondirectly. -
Paste the configuration from The configuration above, with your secret id in place of
YOUR_SECRET_ID. -
Restart the chat window. Run
Developer: Reload Windowso the new endpoints are picked up. -
Send a message. Pick the model from the Chat model picker and send anything. If the reply comes back, the wiring is correct.
Adding more models
Section titled “Adding more models”One provider entry can hold as many models as you like. Add another object to the models
array rather than another provider — they share the key and the URL.
"models": [ { "id": "stealth/space-bunny-alpha", "name": "Space Bunny", "url": "…", "apiType": "chat-completions", "maxInputTokens": 128000, "maxOutputTokens": 16000 }, { "id": "deepseek/deepseek-v4-flash", "name": "DeepSeek V4 Flash", "url": "…", "apiType": "chat-completions", "maxInputTokens": 1000000, "maxOutputTokens": 16000 }]name is what appears in the model picker, so it can be shorter than the id. The id must
stay exact. Copy ids from models & pricing.
Verify it outside VS Code
Section titled “Verify it outside VS Code”Worth doing once before debugging VS Code. If the same key and base URL work here, the problem is in VS Code’s configuration rather than in the gateway.
curl https://gurouter.com/v1/chat/completions \ -H "Authorization: Bearer <API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek/deepseek-v4-flash", "messages": [{ "role": "user", "content": "Say hello in one sentence." }] }'The list of model ids your key can actually reach comes from the gateway:
curl https://gurouter.com/v1/models \ -H "Authorization: Bearer <API_KEY>"When it does not work
Section titled “When it does not work”| Symptom | Cause | Fix |
|---|---|---|
404 on every request |
url is missing /chat/completions |
Use the full path: https://gurouter.com/v1/chat/completions |
401 Unauthorized |
Wrong key, or the secret id in apiKey does not exist |
Re-store the secret and match the id exactly |
400 mentioning the model |
Model id misspelled, vendor prefix dropped, or not enabled for your plan | Copy the id from /models/ verbatim |
| Model missing from the picker | The entry failed to parse, so VS Code skipped it | Check settings.json for a JSON syntax error |
| Works on short prompts, fails on long ones | maxInputTokens is higher than the model’s real context |
Set it to the real size from the models page |
| Tool calls fail or arrive malformed | toolCalling is set for a model that does not support it |
Set it to the model’s actual capability |
| Chat window does not see the new entry | Settings not reloaded | Developer: Reload Window |
Related
Section titled “Related”- Models & pricing — every model, its price, and which plan unlocks it
- Agent setup — the same gateway from curl, Python, and Node
- CLI tools with CC Switch — the same idea for Claude Code, Codex, and Gemini CLI
