June 18, 2026
How to Run Kimi K2.7 Code in opencode (CLI Setup via Sota)
Kimi K2.7 Code is Moonshot's coding model, a fast long-context model built for agents that run long. opencode is exactly that kind of agent: it reads files, writes code, runs tests, reads the errors, and keeps going. This guide connects the two through Sota, so inference runs on Cloudflare instead of Moonshot's China endpoint and you pay a flat rate instead of per token.
A note on the setup: opencode's terminal flow stores your API key interactively but doesn't ask for a custom endpoint URL. So this is two short steps. You paste your key through opencode's prompt, then add a few lines to opencode.json pointing at Sota. If you'd rather skip the config file, the desktop app does all of it through a form. This is the terminal path.
Before you start
- opencode installed (
curl -fsSL https://opencode.ai/install | bash, or Homebrew or npm) - A Sota account (free, no card)
- A Sota API key
Step 1: Create a Sota API key
In the Sota dashboard, open API Keys and create one. Name it opencode-kimi so you can tell it apart from other keys later. Copy it; keys start with sk-sota- and aren't shown again after you close the dialog.
Step 2: Store the key in opencode
Run:
opencode auth login
Work through the prompts:
- Select provider: choose Other at the bottom of the list.
- Enter provider id: type
sota. Step 3 has to use this same id. - Enter your API key: paste your
sk-sota-…key.
opencode saves the credential and tells you to finish setup in config, which is the next step. The same flow is available inside opencode as the /connect command.
Step 3: Point opencode at Sota
The prompt took your key but not an endpoint, so opencode still needs Sota's URL and the model list. Add them to opencode.json. The global file is at ~/.config/opencode/opencode.json, or use a project-level opencode.json that takes precedence. Create or open it 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": {
"kimi-k2.7-code": { "name": "Kimi K2.7 Code" }
}
}
},
"model": "sota/kimi-k2.7-code"
}
The short version of what matters:
- The provider key
sotamust match the id from Step 2. That's how opencode finds your stored key. @ai-sdk/openai-compatibleis the adapter for an OpenAI-shaped API like Sota's.baseURLkeeps the/v1, since opencode appends/chat/completions. NoapiKeyline is needed, because opencode has it from Step 2.modelmakessota/kimi-k2.7-codethe default.
Step 4: Launch and check
opencode
opencode comes up with Kimi K2.7 Code active. Type /models to confirm it's listed under Sota and selected, then give it something with a few moving parts: point it at a feature that spans several files and ask it to trace how a request flows through them. Kimi holds long context well, so a multi-file question tests it better than a one-liner. To pin the model at launch, use opencode -m sota/kimi-k2.7-code.
Kimi K2.7 Code vs GLM-5.2 on Sota
Both models on Sota are long-context coders, so they both hold up across opencode's longer runs. The difference is pace versus capability.
Kimi K2.7 Code is the faster of the two. Its quicker responses make the back-and-forth of interactive coding feel snappier, and for most day-to-day work that speed is worth more than the last increment of model quality. It's a strong default.
GLM-5.2 is the more capable model when you want to push harder. It ranks above Kimi on coding leaderboards like Design Arena and costs more to run, and it's the one to reach for on the tasks where you want the strongest possible output and can spare a little speed to get it. To offer both, add GLM-5.2 to the block:
"models": {
"kimi-k2.7-code": { "name": "Kimi K2.7 Code" },
"glm-5.2": { "name": "GLM-5.2" }
}
Then /models or opencode -m sota/glm-5.2 switches between them. The comparison post goes deeper on the trade-off.
Troubleshooting
Model not found. The provider key sota has to match both the id from Step 2 and the prefix in your model line (sota/kimi-k2.7-code). Check all three.
Auth errors. Re-run opencode auth login, confirm the full sk-sota-… key went in under provider id sota, and use opencode auth list to see what's stored.
404s or no response. Almost always the baseURL. It needs to be exactly https://trysota.xyspace.dev/v1, no trailing slash.
Long runs cut off. opencode and Kimi both handle large context, but check you're on a current opencode version. Sota normalizes Kimi's output to the standard response shape, and an old client can mishandle it.
Why Sota instead of Moonshot directly
Moonshot's native Kimi API runs inference in China. If your code can't leave Western infrastructure, that rules out the direct route no matter how good the model is. Sota serves Kimi K2.7 Code from Cloudflare's network (US, UK, Germany, Japan, Australia), so what opencode sends stays where your policy allows. And because opencode's agent loops are token-heavy, Sota's flat pricing ($25 Starter, $125 Pro, with per-user ceilings) keeps the cost predictable no matter how long the session runs.
Get started with Sota and put Kimi K2.7 Code to work in opencode in a few minutes.