SSOTA
← Blog

June 16, 2026

How to Run GLM-5.2 in opencode (CLI Setup via Sota)

opencode is a coding agent that lives in your terminal. You run it, it reads your project, edits files, runs commands, and works through a task the way Claude Code or Cursor's agent does, except it never leaves your shell. Out of the box it talks to the usual hosted providers. This guide points it at GLM-5.2 through Sota instead, so inference runs on Cloudflare's network rather than Z.ai's China endpoint, and your bill is a flat monthly number rather than per-token.

One thing to know up front: opencode's terminal flow stores your API key interactively, but it never asks for a custom endpoint URL. So the setup is two short steps. You paste your key through opencode's prompt, then add a few lines to opencode.json telling it where Sota lives. If you'd rather avoid the config file entirely, the opencode desktop app does all of this through a form. This is the terminal path.

Before you start

  • 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: Get a Sota API key

Sign in to Sota, open the dashboard, and go to API Keys. Create a key, give it a name like opencode 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 2: Store the key in opencode

Run the auth command:

opencode auth login

opencode walks you through a short series of prompts. Answer them like this:

  • Select provider: scroll to the bottom of the list and choose Other.
  • Enter provider id: type sota. This is the name opencode uses for the provider internally, 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 by typing /connect.

Step 3: Tell opencode where Sota lives

The prompt stored your key but didn't ask 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 use 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"
}

This is the only file you'll touch, and here's what each part is for:

  • The provider key, sota, has to match the provider id you entered in Step 2. That's how opencode pairs this config with the key it stored.
  • npm picks the adapter. @ai-sdk/openai-compatible is the right one, since Sota speaks the OpenAI format.
  • baseURL is Sota's endpoint. opencode appends /chat/completions to it, so keep the /v1. There's no apiKey line because opencode already has your key from Step 2.
  • models lists what shows up in the picker, and model sets the default so you don't pass it every time. The format is provider/model.

Step 4: Run opencode

opencode

opencode launches with GLM-5.2 active, routed through Sota. Type /models to confirm GLM-5.2 appears under the Sota provider and is selected. Then ask it something about your actual code, like "what does the auth middleware in this repo do?", and check the answer reflects your files rather than a generic guess. You can also pin the model at launch with opencode -m sota/glm-5.2.

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 or opencode -m sota/kimi-k2.7-code. No new key, no second account. We compare the two in more depth in GLM-5.2 vs Kimi K2.7 Code.

If something's off

opencode can't find the model. The provider key in opencode.json (sota) has to match both the provider id you set in Step 2 and the prefix in your model line (sota/glm-5.2). A mismatch anywhere breaks the lookup.

Authentication fails. Re-run opencode auth login 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 opencode 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 opencode in about five minutes.