TokenLab

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_completions and 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

  1. 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.
  2. Select Add Models → Custom Endpoint.
  3. VS Code asks for a Group Name. The field is prefilled with Custom Endpoint; replace it with TokenLab and press Enter.
  4. 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.
  5. If VS Code asks for an API type, select Chat Completions. This step may not appear; apiType in the file below sets it either way.
  6. VS Code opens chatLanguageModels.json. Keep the apiKey line the wizard generated (it points to the key in secret storage), make sure apiType is chat-completions, and edit the models list to match the entry below, then save.

Enter the key in the wizard. A key typed directly into chatLanguageModels.json is not sent, and requests fail with a missing Authorization header.

[
  {
    "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.
  • id is the TokenLab model ID sent in the request. Use any live model whose accepted_request_formats includes openai_chat_completions.
  • Token limits: VS Code treats maxInputTokens + maxOutputTokens as 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

  1. Select GPT-5.6 Luna (TokenLab) in the model picker (a low-cost model, good for a first test).
  2. Ask a read-only question first, for example: Summarize the top-level structure of this workspace. Do not modify files.
  3. 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 id must be an exact TokenLab model ID; check the model page.
  • Model missing in agent mode: set "toolCalling": true and 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.

On this page