Skip to content

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

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

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.

vendor
customendpoint
apiType
chat-completions
apiKey
${input:chat.lm.secret.…}
url
https://gurouter.com/v1/chat/completions
  • url is the full endpoint, ending in /chat/completions. Unlike some clients, VS Code does not append the path for you. Leaving off /chat/completions gives a 404.
  • apiKey is 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.
  • maxInputTokens must 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.
  • toolCalling and vision should match what the model actually does. Claiming a capability the model lacks produces a request that fails at the tool-call step.

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.

  1. Store the key as a secret. Run Chat: Store Chat Location Secret from the command palette and give it your GuRouter key. Note the id it returns.

  2. Open the BYOK settings. Run Preferences: Configure Chat Customizations, or open chatModels in settings.json directly.

  3. Paste the configuration from The configuration above, with your secret id in place of YOUR_SECRET_ID.

  4. Restart the chat window. Run Developer: Reload Window so the new endpoints are picked up.

  5. Send a message. Pick the model from the Chat model picker and send anything. If the reply comes back, the wiring is correct.

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.

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.

Terminal window
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:

Terminal window
curl https://gurouter.com/v1/models \
-H "Authorization: Bearer <API_KEY>"
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