opencode is an open-source coding agent for the terminal. Providers that aren’t in its built-in catalog are added as custom providers in opencode.jsonc. BroadNet Inference speaks the OpenAI chat-completions format, so it uses opencode’s OpenAI-compatible runtime package. This guide follows the current (V2) opencode docs.
Setup
- Export your key in the shell that starts opencode:
export BROADNET_API_KEY='your-broadnet-key'
- Create the config. Put it in your project as
opencode.jsonc, or in~/.config/opencode/opencode.jsoncto use it everywhere.
{
"$schema": "https://opencode.ai/config.json",
"model": "broadnet/glm-5.3",
"providers": {
"broadnet": {
"name": "BroadNet Inference",
"env": ["BROADNET_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://inference.broadnet.ai/v1"
},
"models": {
"glm-5.3": {
"modelID": "broadnet/glm-5.3",
"name": "GLM 5.3",
"capabilities": { "tools": true, "input": ["text"], "output": ["text"] },
"limit": { "context": 1048576, "output": 16000 }
},
"deepseek-v4.1-flash": {
"modelID": "broadnet/deepseek-v4.1-flash",
"name": "DeepSeek V4.1 Flash",
// BroadNet's docs don't list tool calling for this model: test it first
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 1048576, "output": 16000 }
},
"qwen3.8-27b": {
"modelID": "broadnet/qwen3.8-27b",
"name": "Qwen3.8 27B",
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 262144, "output": 16000 }
}
}
}
}
}
- Start opencode and pick the model with
/models. The reference isbroadnet/<map key>, for examplebroadnet/glm-5.3. opencode sends themodelIDvalue to BroadNet.
Config files merge. opencode applies the global file first, then project files found from the current directory upward (farthest first), then any .opencode/ config, so a project file can override the global provider. Managed system config, if your company uses it, overrides both. Keep the key in the environment, not in the file, so the config can go into version control.
Why the aliases
BroadNet IDs already contain a slash (broadnet/glm-5.3). The models map key is what opencode shows and selects, and modelID is what it sends. Short keys keep references readable.
Set capabilities and limit yourself. For a model outside its catalog, opencode assumes JSON tool support, text and image input, a 200,000-token context and 32,000 output tokens. Its docs call these fallback assumptions, not detected values. The output value of 16000 above is our suggestion, not a BroadNet limit; it leaves room for reasoning.
Older V1 configs
opencode V2 still reads the V1 format, so an existing block like this keeps working:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"broadnet": {
"npm": "@ai-sdk/openai-compatible",
"name": "BroadNet Inference",
"options": {
"baseURL": "https://inference.broadnet.ai/v1",
"apiKey": "{env:BROADNET_API_KEY}"
},
"models": {
"broadnet/glm-5.3": { "name": "GLM 5.3" }
}
}
}
}
In the native V2 form, provider becomes providers, npm becomes package (aisdk:@ai-sdk/openai-compatible if you want to keep the AI SDK package), and options.baseURL and options.apiKey move under settings. The opencode V1 migration guide maps each field.
Which model to pick
| Task | Model | Notes |
|---|---|---|
| Agent coding with tools | GLM 5.3 | Tools and structured output listed; 1M context |
| Screenshots, Arabic | Qwen3.8 27B | Tools and images; 262K context |
| All-day sessions, flat price | DeepSeek V4.1 Flash | Unlimited plans; tools not listed by BroadNet |
opencode relies on tool calls. BroadNet’s docs don’t list tool calling for DeepSeek V4.1 Flash, so the config marks it as an assumption to test. Run a real task on a Meteor hour ($1) before you buy a Full Moon month ($60).
Troubleshooting
- 401. The key in
BROADNET_API_KEYis wrong, expired, or out of pay-as-you-go allowance. Make sure the variable is set in the process that runs opencode. - Model not found or rejected. Select the map key (
broadnet/glm-5.3), and check thatmodelIDmatches BroadNet’s ID exactly. References are case-sensitive. Paid models need a top-up; the $5 credit covers onlybroadnet/gemma-4-26b-a4band the two Transcribe models. - Empty answers. Raise
limit.output. Why answers come back empty. - 429. Pay-as-you-go keys allow 30 requests a minute and 4 in flight. Retries count too. See errors and retries.
- Subagents on a plan. Each plan session handles one request at a time, so parallel subagents queue unless each has its own session.
