Setup guide

Connect VS Code

Visual Studio Code has AI chat built in (GitHub Copilot Chat), and it accepts your own models through a custom endpoint. This guide connects that chat to CheapTokens.

Before you start

The snippets below use claude-sonnet-5-5. Pick another model to update them.

Steps

  1. Install VS Code if you don't have it. These steps use the chat that is built in.
  2. Open the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on macOS) and run Chat: Manage Language Models.
  3. Click Add Models → Custom Endpoint. Name the group CheapTokens, paste your API key when asked, and choose Chat Completions as the API type.
  4. VS Code opens the file chatLanguageModels.json. Make the CheapTokens entry look like this and save. Keep the apiKey line that VS Code wrote for you.
    chatLanguageModels.json
    [
      {
        "name": "CheapTokens",
        "vendor": "customendpoint",
        "apiKey": "${input:cheaptokensApiKey}",
        "apiType": "chat-completions",
        "models": [
          {
            "id": "claude-sonnet-5-5",
            "name": "claude-sonnet-5-5",
            "url": "https://cheaptokens.pw/v1/chat/completions",
            "toolCalling": true,
            "vision": true,
            "maxInputTokens": 200000,
            "maxOutputTokens": 8192
          }
        ]
      }
    ]
  5. Open the Chat view, pick claude-sonnet-5-5 in the model picker and send a message. Restart VS Code if the model isn't listed.

Check that it works

Send a short message in VS Code, then open Dashboard → Usage. The request appears there within a few seconds, with its model, tokens and cost.

Good to know

If something goes wrong

What you seeWhat to do
401 or invalid_api_keyThe key is wrong, disabled or has extra spaces. Create a new key and paste it again.
402 or insufficient_quotaYour balance is empty. Top up under Billing.
404 or model_not_foundThe model ID has a typo. Copy it from the models page.
404 on every requestThe base URL is wrong. Check whether this tool needs the /v1 ending (see the steps above).
429Too many requests per minute. Wait a few seconds and retry.

Prefer a guided version? Open the setup wizard →