June 18, 2026
How to Run GLM-5.2 in VS Code with the opencode Extension (via Sota)
opencode is a terminal coding agent, but it also ships a VS Code extension that brings the same agent into your editor. It opens in a split terminal pane, watches what file and selection you have open, and lets you drop file references into a prompt with a keystroke. The model doesn't change between the terminal and the editor, and neither does the setup: the extension reads the exact same opencode.json and stored credentials as the CLI. This guide installs the extension and points it at GLM-5.2 through Sota, so inference runs on Cloudflare's network rather than Z.ai's China endpoint, at a flat monthly rate instead of per token.
One thing to know up front: there's no separate provider screen in the extension. You authenticate once through opencode's CLI prompt, add a few lines to opencode.json, and the editor picks it up. If you'd rather avoid the config file entirely, the opencode desktop app does provider setup through a form; the CLI guide covers the pure-terminal path. This is the VS Code path.
What you need
- VS Code (or a fork like Cursor, Windsurf, or VSCodium)
- opencode installed (
curl -fsSL https://opencode.ai/install | bash, or via Homebrew or npm; check opencode's install docs for your platform) - A Sota account (free to create, no card required)
- A Sota API key, which you'll generate in a moment
Step 1: Install the extension
The simplest way is to let opencode install it for you. Open VS Code, open the integrated terminal (Ctrl+ `), and run:
opencode
The extension detects your editor and installs itself automatically. If that doesn't happen, open the Extensions Marketplace, search OpenCode, and click Install. Auto-install relies on your editor's CLI command being on your PATH (code for VS Code, cursor, windsurf, or codium for the forks), so if it's missing, run "Shell Command: Install 'code' command in PATH" from the command palette and try again.
Step 2: Get a Sota API key
Sign in to Sota, open the dashboard, and go to API Keys. Create a key, name it something like opencode-vscode so you can find it later, and copy it. Keys start with sk-sota- and are shown once, so paste it somewhere before you close the dialog.
Step 3: Store the key in opencode
In the same integrated terminal, run:
opencode auth login
Work through the prompts:
- Select provider: scroll to the bottom of the list and choose Other.
- Enter provider id: type
sota. This is opencode's internal name for the provider, and the next step has to match it. - Enter your API key: paste your
sk-sota-…key.
opencode saves the credential and reminds you to finish the provider setup in config, which is the next step. You can reach this same flow from inside opencode with the /connect command.
Step 4: Point opencode at Sota
The prompt stored your key but never asked for an endpoint, so opencode still doesn't know Sota's URL or which models to offer. That goes in opencode.json. The global file is at ~/.config/opencode/opencode.json, or you can drop a project-level opencode.json in your repo root, which takes precedence. Open it (create it if it's missing) and add:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"sota": {
"npm": "@ai-sdk/openai-compatible",
"name": "Sota",
"options": {
"baseURL": "https://trysota.xyspace.dev/v1"
},
"models": {
"glm-5.2": { "name": "GLM-5.2" }
}
}
},
"model": "sota/glm-5.2"
}
What each part does:
- The provider key,
sota, has to match the provider id you entered in Step 3. That's how opencode pairs this config with the key it stored. npmpicks the adapter.@ai-sdk/openai-compatibleis the right one, since Sota speaks the OpenAI format.baseURLis Sota's endpoint. opencode appends/chat/completionsto it, so keep the/v1. There's noapiKeyline because opencode already has your key from Step 3.modelslists what shows up in the picker, andmodelsets the default so you don't pass it every time. The format isprovider/model.
Because the extension shares this file with the CLI, you only write it once and both surfaces use it.
Step 5: Drive it from the editor
Open a project folder, then bring up opencode with Cmd+Esc (Mac) or Ctrl+Esc (Windows/Linux). It opens in a split terminal pane alongside your code. Type /models to confirm GLM-5.2 appears under the Sota provider and is selected.
Two things make the extension worth using over a bare terminal:
- Context awareness. opencode automatically sees your active selection and the file you have open, so "explain what this function does" or "refactor this" works on whatever's in front of you without you pasting anything.
- File references. Press
Cmd+Option+K(Mac) orAlt+Ctrl+K(Windows/Linux) to insert a reference to a file into your prompt, so you can point the agent at code in other tabs by name.
Need a clean slate? Cmd+Shift+Esc / Ctrl+Shift+Esc starts a new session. To sanity-check the connection, select a function in your code, open opencode, and ask "what does this do?" — if the answer reflects your actual file rather than a generic guess, GLM-5.2 is answering through Sota.
GLM-5.2 vs Kimi K2.7 Code on Sota
Sota serves two open coding models, and both handle long context and long agent runs well, so the choice between them is about capability versus speed rather than memory.
GLM-5.2 is the more capable of the two. On coding leaderboards like Design Arena it ranks above Kimi, and it's the one to reach for when you want the strongest output: tricky refactors, dense logic, the tasks where a weaker model returns something that almost works. It costs more to run, which is the trade for that capability.
Kimi K2.7 Code is the faster alternative. It's a strong long-context coder in its own right, and it gives up a little of GLM-5.2's top-end quality for quicker responses, which is often the better deal when you're iterating fast. To offer both, add Kimi to the models block:
"models": {
"glm-5.2": { "name": "GLM-5.2" },
"kimi-k2.7-code": { "name": "Kimi K2.7 Code" }
}
Then switch with /models inside the opencode pane. No new key, no second account. We compare the two in more depth in GLM-5.2 vs Kimi K2.7 Code.
The extension vs the CLI and desktop app
The model and the routing are identical across all three: same GLM-5.2, same Sota endpoint, same Cloudflare inference. What changes is where the agent lives. The VS Code extension keeps it next to your code, with the editor's current selection and open file fed in automatically and file references a keystroke away. The desktop app gives you a standalone window with a diff viewer. The CLI is the leanest, best for scripting and a pure-terminal workflow. Since they all read the same opencode.json, you can move between them without reconfiguring.
If something's off
The extension didn't install. Auto-install needs your editor's CLI command on PATH. Install it from the command palette ("Shell Command: Install 'code' command in PATH"), or just install OpenCode from the Extensions Marketplace by hand.
opencode can't find the model. The provider key in opencode.json (sota) has to match both the provider id you set in Step 3 and the prefix in your model line (sota/glm-5.2). A mismatch anywhere breaks the lookup.
Authentication fails. Re-run opencode auth login in the integrated terminal and confirm you pasted the full sk-sota-… key under provider id sota. You can list stored credentials with opencode auth list.
Requests aren't reaching Sota. Check the baseURL is exactly https://trysota.xyspace.dev/v1, with no trailing slash. opencode builds the request path from that string.
Config isn't being read. opencode merges global and project config, with project winning. If a repo-level opencode.json also sets model, it overrides the global default. Make the two agree, or delete the one you don't need.
Why route through Sota
GLM-5.2's native API runs inference in China. Sota serves the same model from Cloudflare's network across the US, UK, Germany, Japan, and Australia, so the code the extension sends never lands on infrastructure your security team hasn't signed off on. And opencode's agent loops can burn a lot of tokens; per-token pricing turns that into a number you can't predict ahead of time, while Sota charges a flat monthly rate ($25 Starter, $125 Pro) with per-user spend ceilings, so a runaway loop costs you time, not money.
Get started with Sota and have GLM-5.2 answering inside VS Code in about five minutes.