OpenCode
OpenCode is an open source terminal agent. You declare Helmcode as one more provider and from then on you can switch models from inside the agent itself.
Configuration
Write this into ~/.config/opencode/opencode.json to have it in every project, or into an opencode.json at the root of the project if you only want it there:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"helmcode": {
"npm": "@ai-sdk/openai-compatible",
"name": "Helmcode",
"options": {
"baseURL": "https://api.helmcode.com/v1",
"apiKey": "sk-your-key-here"
},
"models": {
"deepseek-v4-flash": {
"name": "DeepSeek V4 Flash",
"limit": { "context": 1048576, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"glm5.3": {
"name": "GLM 5.3",
"limit": { "context": 1048576, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"glm5.3-flash": {
"name": "GLM 5.3 Flash",
"limit": { "context": 1048576, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"qwen3.6": {
"name": "Qwen 3.6",
"limit": { "context": 262144, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
},
"gemma4": {
"name": "Gemma 4",
"limit": { "context": 262144, "output": 32768 },
"modalities": { "input": ["text", "image"], "output": ["text"] }
}
}
}
},
"compaction": {
"auto": true,
"prune": true,
"reserved": 50000
}
}
Those are the language models worth declaring: deepseek-v4-flash, glm5.3, glm5.3-flash, qwen3.6 and gemma4. All five take images and all five do tool calling. The embedding, reranking and speech models are not used by the agent, so they do not go here.
@ai-sdk/openai-compatible is the generic adapter, the one that speaks to any API shaped like OpenAI’s. Do not use plain @ai-sdk/openai: that one expects the real OpenAI API.
Of everything inside each model, the only mandatory part is its key, which is the id. name, limit and modalities are optional: without them OpenCode works the same, you just see the bare id in the picker and automatic compaction runs on its own defaults.
Where to put the key
In the example above the key is written inside the file, which is the most direct thing but not the most comfortable if that file ends up in a repository.
The alternative is to leave apiKey out of the opencode.json and store it with OpenCode’s /connect command, which writes it into its own credential store:
/connect
It asks for a Provider id. Write exactly:
helmcode
Warning: the Provider id has to match the key in the JSON. OpenCode pairs the credential with the provider by that identifier. If your provider is called
helmcodeinopencode.jsonand you writeHelmcodeor anything else in/connect, OpenCode saves the credential but associates it with no provider, and the requests go out with no key. It is the most common failure when connecting OpenCode, and nothing in the error explains it.
Then paste your API key and press Enter.
The context limits
"limit": { "context": 1048576, "output": 32768 }
limit.context and limit.output are the fields OpenCode reads — not contextWindow, which is not part of OpenCode’s schema: an unknown key raises nothing anyone sees, OpenCode falls back to its own assumption about the window, and the symptom is a session that compacts far too early on the long-context models.
limit.context is the window published in Models: 1M for deepseek-v4-flash, glm5.3 and glm5.3-flash, 256K for qwen3.6 and gemma4. limit.output is a client-side budget rather than a server cap, so raise it if you need longer answers.
The compaction block
"compaction": { "auto": true, "prune": true, "reserved": 50000 }
OpenCode summarizes the conversation on its own when it gets close to the context limit, and reserved is the token margin it keeps to do that. With 1M token windows you are not going to touch the limit in a normal session, but leaving it on stops a very long session from being cut off abruptly.
Check that it works
opencode
Inside the agent, pick the model with /models and ask it for something short. If it answers, it is already going out through Helmcode.
Recommended model
glm5.3-flash for code and for anything agentic — a 1M window, in every plan’s quota. deepseek-v4-flash is the other model that size. qwen3.6 when the task is bounded and you want the answer now.
Known issues
- The key is written in the file. If you keep the
opencode.jsoninside the repository, the key goes with it. Keep it in the file in your home directory, use/connect, or add the file to.gitignore. - Do not raise the windows by hand. They are the ones the API accepts; above them, OpenCode fills the conversation up to a point where requests start being rejected.