VS Code — built-in Chat
Add RouterPlex models to VS Code's built-in Chat via a custom endpoint.
On this page
Set it up with your coding agent #
Paste your key into the prompt's key field, then copy the prompt into Claude Code, Codex, Cursor, or any coding agent. It configures the tool and keeps testing until a real request goes through RouterPlex, fixing environment problems along the way. Prefer to do it by hand? Follow the manual setup below; your key fills those commands too.
Optional. It stays in this browser tab and is never saved or sent. No key yet? Create one in guided setup.
Set up VS Code's built-in Chat on this machine to use RouterPlex, an OpenAI- and Anthropic-compatible AI gateway. Keep working until a real request from VS Code's built-in Chat succeeds through RouterPlex.My RouterPlex API key: YOUR_ROUTERPLEX_API_KEYKey handling:- If the key line above is a placeholder rather than a real key (real keys start with sk-), use my ROUTERPLEX_API_KEY environment variable. If that is empty too, ask me for the key once, then continue.- Store the key only in user-level config or my user environment. Never put it in a project file, never commit it, and do not repeat the full key in your replies (show at most its first 8 characters).Config handling:- Before changing an existing config file or shell startup file, copy it to a .bak file next to it and show me the diff. Merge into what is there; never replace my other settings, providers, or MCP servers.- If a step needs something only I can do, such as a click in a settings window, print the exact steps instead of guessing.Full guide: https://docs.routerplex.com/vscode-chatStep 1. Prove the key and the RouterPlex gateway work before changing anything else. Run:curl -sS https://api.routerplex.com/v1/chat/completions -H "Authorization: Bearer YOUR_ROUTERPLEX_API_KEY" -H "Content-Type: application/json" -d '{"model":"claude-sonnet-4-6","max_tokens":32,"messages":[{"role":"user","content":"Reply with exactly: RouterPlex connected."}]}'On Windows PowerShell, use curl.exe with the body in a file, or Invoke-RestMethod.- A reply containing "RouterPlex connected.": go on.- 401: the key is wrong or revoked. Stop and ask me for a correct key.- 402: my balance or trial credit is used up. 403: this key reached its own spending limit. Stop and tell me; retrying cannot fix these.- Network, DNS, TLS, or proxy errors: find and fix the cause (proxy variables, VPN, firewall, system clock, outdated CA certificates), then run it again.Step 2. Configure VS Code's built-in Chat:- Tell me to run Chat: Manage Language Models from the Command Palette, choose Add Models → Custom Endpoint, name the group RouterPlex, paste the key, and choose Chat Completions. VS Code stores the key itself.- Then edit the chatLanguageModels.json file VS Code opened (macOS: ~/Library/Application Support/Code/User/, Windows: %APPDATA%\Code\User\, Linux: ~/.config/Code/User/). In the RouterPlex group, keep the apiKey value VS Code generated and set apiType to chat-completions and models to:[{"id": "claude-sonnet-4-6", "name": "RouterPlex Sonnet", "url": "https://api.routerplex.com/v1/chat/completions", "toolCalling": true, "vision": true, "maxInputTokens": 995904, "maxOutputTokens": 4096}]- Do not touch other provider groups.Step 3. Test VS Code's built-in Chat itself from a new terminal or a restarted app, so you test the saved setup rather than the shell you changed:Ask me to reopen the model picker, select RouterPlex Sonnet, send this, and report the reply: Reply with exactly: RouterPlex connected.If the model does not appear, have me restart VS Code.Expected reply: "RouterPlex connected."Step 4. If step 1 works but step 3 fails, the problem is VS Code's built-in Chat's configuration or environment, not RouterPlex. Check these, fix what is wrong, and repeat step 3:- The key or base URL is set in one place but not where VS Code's built-in Chat starts: zsh vs bash startup files, login vs non-login shells, a desktop launcher, a background service, Windows vs WSL, or a remote SSH or container environment.- Another setting wins: OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_API_BASE, ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, or a project-level config that overrides the user-level one.- VS Code's built-in Chat is outdated, or still needs a full restart to read the new settings.- If an environment variable cannot be made to reach VS Code's built-in Chat reliably and VS Code's built-in Chat accepts a key in its user-level config, put the key there instead.Keep repeating steps 3 and 4 until the test reply comes back.Step 5. The test above sends no tools, but real sessions send every tool, MCP server, and plugin schema with each request, and that is where models differ. Ask me to send this in a new VS Code's built-in Chat chat and report the reply: List your available tools, then read ./README.md and reply with its first heading.Stop early only for a 401, 402, or 403, or for a step only I can do, such as a click in a settings window or a login. Then tell me exactly what to do, wait for me, and continue testing afterwards.When it works, tell me exactly which files you changed and which values you set (key shown by its first 8 characters only) so I can undo it, where the key is stored, and the final test output. Remind me that every request shows up in https://routerplex.com/dashboard/usage.
Manual setup #
Use Custom Endpoint in the current VS Code Chat experience on macOS, Linux, or Windows. This is separate from the Cline, Roo, and Continue extensions.
1. Add a custom endpoint #
- Update VS Code. Open the Command Palette (
Cmd+Shift+Pon macOS,Ctrl+Shift+Pon Windows/Linux) and run Chat: Manage Language Models. You can also use the model picker's Manage Models action. - Select Add Models → Custom Endpoint and name the group RouterPlex.
- Enter your RouterPlex API key and choose Chat Completions.
- Edit the opened
chatLanguageModels.jsonfile, preserving the key reference VS Code generated.
If Custom Endpoint is missing, update VS Code and check your organization's BYOK policy. For agent mode, the selected model must support tool calling.
2. Configure a model #
Use the full endpoint URL to avoid URL-resolution differences between releases. Keep your group's existing apiKey value; the placeholder below illustrates a reference, not a portable saved credential.
[{"name": "RouterPlex","vendor": "customendpoint","apiKey": "${input:routerplexApiKey}","apiType": "chat-completions","models": [{"id": "claude-sonnet-4-6","name": "RouterPlex Sonnet","url": "https://api.routerplex.com/v1/chat/completions","toolCalling": true,"vision": true,"maxInputTokens": 995904,"maxOutputTokens": 4096}]}]
If you added the group manually, choose Update API Key from the group's context menu. Do not copy someone else's generated secret ID or replace other provider groups.
The input and output limits must fit together in the context window. This starter example reserves 4,096 output tokens within Sonnet's listed 1,000,000-token budget.
Add more models #
The button below loads current chat models and capability metadata from RouterPlex's catalog. It copies only the models array: replace the array inside your RouterPlex group and keep your other settings and saved key reference.
Copy the current chat models, including their tool and image capabilities. Replace only the models array inside your RouterPlex group; keep its saved API key reference.
Uses the current catalog. Output is limited to 4,096 tokens per model for a conservative starting configuration.
Model availability and limits can change. Review the live catalog before changing models. Image-generation routes are not chat models and are excluded. Models without tool support can be used only in compatible chat modes.
File locations #
Use the file opened by VS Code, especially with profiles or portable/remote installs. Default desktop locations:
- macOS:
~/Library/Application Support/Code/User/chatLanguageModels.json - Windows:
%APPDATA%\Code\User\chatLanguageModels.json - Linux:
~/.config/Code/User/chatLanguageModels.json
Verify #
Save, reopen the model picker, select RouterPlex Sonnet, and send Reply with exactly: RouterPlex connected. Restart VS Code if the model does not appear. Confirm the request under your key in Usage.
Official reference: VS Code language models and Custom Endpoint.