Coding Tools
Visual Studio Code
Use TokenLab models in VS Code chat with the Custom Endpoint provider
Overview
VS Code chat can use your own model provider through Custom Endpoint (bring your own key). This page connects TokenLab over the Chat Completions API.
- Chat does not need a Copilot plan. VS Code's BYOK models work without signing in to GitHub.
- Some features still need GitHub: inline suggestions (code completions), semantic search, and other embedding-based features are not served by BYOK models. A TokenLab key does not replace them.
- Copilot Business or Enterprise users: your administrator must allow the Bring Your Own Language Model Key in VS Code policy.
Requirements
- A current stable VS Code with the Chat view.
- A TokenLab API key (get one).
- A model that accepts
openai_chat_completionsand supports tool calling (agent mode only lists tool-calling models). A model's page shows both: Chat Completions API under API format and Tool use under Capabilities, for example GPT-5.6 Luna.
Add TokenLab
- Open the model picker in the Chat view and select Manage Language Models (gear icon), or run Chat: Manage Language Models from the Command Palette.
- Select Add Models → Custom Endpoint.
- VS Code asks for a Group Name. The field is prefilled with
Custom Endpoint; replace it withTokenLaband press Enter. - A prompt titled TokenLab: API Key opens right away. Paste your TokenLab API key and press Enter. VS Code keeps the key in its secret storage.
- If VS Code asks for an API type, select Chat Completions. This step may not appear;
apiTypein the file below sets it either way. - VS Code opens
chatLanguageModels.json. Keep theapiKeyline the wizard generated (it points to the key in secret storage), make sureapiTypeischat-completions, and edit themodelslist to match the entry below, then save.
Enter the key in the wizard. A key typed directly into
chatLanguageModels.jsonis not sent, and requests fail with a missingAuthorizationheader.
[
{
"name": "TokenLab",
"vendor": "customendpoint",
"apiKey": "${input:tokenlabApiKey}",
"apiType": "chat-completions",
"models": [
{
"id": "gpt-5.6-luna",
"name": "GPT-5.6 Luna (TokenLab)",
"url": "https://api.tokenlab.sh/v1/chat/completions",
"toolCalling": true,
"vision": true,
"maxInputTokens": 200000,
"maxOutputTokens": 32000
},
{
"id": "claude-sonnet-5-5",
"name": "Claude Sonnet 5.5 (TokenLab)",
"url": "https://api.tokenlab.sh/v1/chat/completions",
"toolCalling": true,
"vision": true,
"maxInputTokens": 200000,
"maxOutputTokens": 32000
},
{
"id": "gpt-6.1-sol",
"name": "GPT-6.1 Sol (TokenLab)",
"url": "https://api.tokenlab.sh/v1/chat/completions",
"toolCalling": true,
"vision": false,
"maxInputTokens": 200000,
"maxOutputTokens": 32000
}
]
}
]Notes:
- Write the full URL including
/chat/completions. VS Code uses a URL with an explicit API path as-is. - With the Chat Completions type, VS Code sends
Authorization: Bearer <key>, which is what TokenLab expects. Do not add a custom auth header. idis the TokenLab model ID sent in the request. Use any live model whoseaccepted_request_formatsincludesopenai_chat_completions.- Token limits: VS Code treats
maxInputTokens + maxOutputTokensas the context window. The values above are conservative; you can raise them up to the model's limits on its model page. Larger contexts cost more per request. - If the model does not appear in the picker, restart VS Code.
Without a GitHub sign-in
Title generation, commit messages and other background "utility" tasks use GitHub Copilot models by default. Without a Copilot sign-in, set chat.utilityModel and chat.utilitySmallModel to a TokenLab model (a fast, inexpensive one for the small model), or set chat.byokUtilityModelDefault to Main Agent Model. These background calls are billed to your TokenLab balance.
Verify
- Select GPT-5.6 Luna (TokenLab) in the model picker (a low-cost model, good for a first test).
- Ask a read-only question first, for example:
Summarize the top-level structure of this workspace. Do not modify files. - Check the reply and its matching request record before running agent tasks.
Saving the configuration or listing models does not prove that the key works. A prompt uses TokenLab balance.
Troubleshooting
- Missing Authorization header: the key is not in secret storage. Run Add Models → Custom Endpoint again and enter the key in the wizard instead of in the JSON file.
- 401 / authentication failed: re-enter the key from Manage Language Models → gear icon next to the TokenLab group.
- Model not found: the
idmust be an exact TokenLab model ID; check the model page. - Model missing in agent mode: set
"toolCalling": trueand use a model that supports tool use. - Messages or Responses API types: not covered on this page yet; use Chat Completions.
Do not commit API keys to chatLanguageModels.json or any file tracked by Git; keep ${input:...} in the file.