VS Code extension
The Spanway extension registers the gateway as a language model provider in VS Code. The gateway's chat models appear in the chat model picker next to the built-in ones, each with its input and output price per million tokens and the context limits the gateway reports, so VS Code sizes prompts correctly. Requests go to POST /v1/chat/completions on the gateway as streaming chat completions with tools and images passed through, which means routing, fallbacks, guardrails and spend tracking all apply to editor traffic the same way they apply to any other client.
It ships as spanway-vscode.vsix on each release page and targets VS Code 1.115 or newer.
A real-world scenario
A company wants its engineers to use the approved models in the VS Code chat panel and to see that usage on the gateway's spend reports. Each engineer installs the extension, connects it with their own virtual key, and the chat model picker shows only the models that key may use, with their prices.
Before you start
- VS Code 1.115 or newer.
spanway-vscode.vsixfrom the release page of the gateway version you run.- The gateway's address, reachable from the engineer's machine, at least one chat model on it, and a virtual key made as in the next section.
Make a key for VS Code
A proxy admin gives each engineer their own key, so the picker shows only the models that engineer may use and their spend stays separate.
- In the Admin UI open Virtual Keys (
/ui/api-keys) and click + Create New Key. - Under Key Details, pick the engineer's team and set Key Name to who and which tool, for example
vscode-jane. Leave Key Type on AI APIs, so the key can call models but cannot change the gateway. - In Models, pick the chat models the engineer may use, for example
gpt-6.1-solandclaude-sonnet-5-5. The picker shows only these. The extension sends no background calls of its own, so there is no extra model to add. - Open Optional Settings. Set Max Budget (USD), for example
150, with Reset Budget on monthly, and Requests per minute Limit (RPM), for example60. - Click Create Key and copy the key. It is shown once.
The same key from the API, with the master key or a proxy admin's key:
curl -X POST https://gateway.example.com/key/generate \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"key_alias": "vscode-jane", "key_type": "llm_api", "team_id": "platform", "models": ["gpt-6.1-sol", "claude-sonnet-5-5"], "max_budget": 150, "budget_duration": "30d", "rpm_limit": 60}'
Steps
The setup itself is the numbered list in Set it up.
-
Get a key for the engineer, as in make a key for VS Code.
-
Check what the key will show in the picker.
curl http://localhost:4000/model_group/info -H "Authorization: Bearer $SPANWAY_API_KEY"
Expected result
The chat model picker lists the key's chat models under the connection name with their input and output prices, and each chat turn shows on the Logs page with the key alias.
What it does
The model list comes from the gateway's GET /model_group/info endpoint scoped to the virtual key you configure, so the picker shows exactly the chat models that key may use. The extension also describes a Reasoning Effort option for models whose gateway entry lists supported_reasoning_efforts and sends the chosen effort as reasoning_effort. That option relies on a proposed VS Code API that stable VS Code 1.115 does not expose, so stable VS Code shows no Reasoning Effort menu and requests go out without reasoning_effort. The key is stored in VS Code's secret storage, never in settings files.
Agents a key is explicitly allowed to use come back from /model_group/info as chat entries named a2a/<agent name>, so they show up in the picker next to the models. A chat turn on such an entry goes to that agent through the gateway.
A few things happen on the client side without any setting. When the gateway reports no context limits for a model, the extension assumes 128000 input and 4096 output tokens and says so in the model's details. A gateway URL that ends in /v1 is accepted, because the extension removes a trailing /v1 and slashes before it adds its own paths. Each request asks for streamed token usage, so the gateway's spend tracking sees the real counts, and when VS Code requires a tool call the request sets tool_choice to required. The model options VS Code passes, temperature, top_p, max_tokens, presence_penalty, frequency_penalty and seed, are forwarded unchanged when they are numbers.
The extension contributes one language model chat provider with vendor id spanway, configured by baseUrl (default http://localhost:4000) and apiKey, and one command, Spanway: Refresh Models, which re-reads the model list after the gateway's models change.
Install from a release
Every release attaches spanway-vscode.vsix to its release page, with an SPDX SBOM and a cosign signature. A stable release builds it at the gateway's version. A pre-release, such as 2.1.0-rc.1, builds it with the version of the last stable release, because VS Code only accepts major.minor.patch versions, so check the release page rather than the extension's version number to know which build you run. Download it and run:
code --install-extension spanway-vscode.vsix
The extension is not listed in the Visual Studio Marketplace or Open VSX yet, and store listings are planned. Until then, install it from the spanway-vscode.vsix file attached to the release page. Pre-release versions will never be listed in a store, because both stores only accept major.minor.patch versions.
Set it up
- Install the extension from a release.
- Run
Chat: Manage Language Modelsfrom the Command Palette and pickSpanway. - Enter a name for the connection, the gateway URL, for example
https://gateway.example.com, and a virtual key. - Open the chat model picker. The gateway's chat models are listed under the name you chose.
Add the provider again under another name to reach a second gateway or to use a second key with a different model set. To change a connection's key or remove it, use the gear on its row in the Language Models editor (Update API Key, Delete). To change its URL, open the entry with Open in Language Models (JSON) from the same menu. If the stored key is lost, the editor shows a missing its API key row until you update it.
The key needs access to at least one model group whose mode is chat or that has no mode set. spanwayctl model-groups list shows what a key can see.
Upgrading
Reload the VS Code window after installing, then follow the setup steps above. To upgrade, download the .vsix of the new release and install it over the old one. The extension's only runtime dependency is the openai package, which it uses to call the chat completions endpoint, and its SBOM on the release page lists the exact version.
Errors
| What you see | What it means | Fix |
|---|---|---|
| No models under the connection | The key has no model group whose mode is chat or unset. | Add chat models to the key, then run Spanway: Refresh Models. |
A missing its API key row | The stored key was lost from VS Code's secret storage. | Use Update API Key on the row. |
A chat turn fails with 401 | The key was deleted, blocked or expired. | Create a new key and update the connection. |
A chat turn fails with 429 | The key hit its rate limit. | Wait, or ask an admin to raise Requests per minute Limit (RPM). |
A chat turn fails with 422 and Budget has been exceeded! | The key's budget is spent. | Wait for the reset, or ask an admin to raise Max Budget (USD). |
Spanway gateway URL "<url>" is not an http or https URL. | The connection's URL has no http:// or https:// scheme, or is not a URL. | Fix the URL with Open in Language Models (JSON). |
Spanway provider is missing its Gateway URL | The connection was saved without a URL. | Add baseUrl with Open in Language Models (JSON). |
Spanway gateway at <url> answered 401 for /model_group/info: ... | The key was refused while the extension listed the models, before any chat turn. | Create a new key, or check that the key belongs to this gateway. |
Spanway gateway at <url> answered 429 for /model_group/info: ... | The key hit its rate limit while listing models. | Wait and run Spanway: Refresh Models. |
Spanway gateway at <url> returned an unexpected /model_group/info payload: ... | The address answers but is not a Spanway gateway, or is a version too old for the extension. | Point the connection at the gateway itself, not a proxy or load balancer page in front of it, and upgrade the gateway if needed. |
The model stopped at its output token limit before finishing the response | The answer was cut off at the model's output token limit. | Ask for a shorter answer, or ask an admin to raise max_output_tokens in the model's info on the gateway. |
Model returned invalid JSON arguments for tool <name>: ... | The model asked to call a tool with arguments that are not valid JSON. | Retry the turn. If it keeps happening, pick a model with better tool calling. |
| No Reasoning Effort menu | Stable VS Code does not expose that API yet. | Nothing to fix, requests go without reasoning_effort. |
Troubleshooting
- Run the
/model_group/infocurl from step 2 with the same key. An emptydatalist, or no group with modechat, explains an empty picker. - Run
Spanway: Refresh Modelsafter an admin changes the key's models, because the extension reads the list only when it starts or refreshes. - Open Logs (
/ui/logs) and filter by the key alias. A row means the turn reached the gateway, so read its status and message in the table above. No row means VS Code never reached the gateway, so check the URL inOpen in Language Models (JSON).
Logs
The extension writes no log file of its own. Its traffic shows up in two places.
- On the gateway, open Logs (
/ui/logs) and filter by the key alias, for examplevscode-jane. Every chat turn is a/v1/chat/completionsrow with its model, tokens and cost. The extension sendsUser-Agent: spanway-vscode/<version>on every call, so the request details also tell you which extension version made it. - In VS Code, a model listing problem shows on the connection's row in the Language Models editor, and a failed chat turn shows its message in the chat panel. The messages are the ones in the errors table.
Related
- Virtual keys for key limits and model access.
- VS Code with GitHub Copilot for gateway models through Copilot's Custom Endpoint and gateway tools through VS Code's MCP client, with a comparison to this extension.
- IDE assistants for Cline, Continue, Roo Code, Zed and JetBrains AI Assistant.
- Coding agent setup for other coding tools.
- Developer CLI for
spanwayctl model-groups list.