BroadRouter
Get started

Add BroadNet Inference to opencode as a custom provider

Updated

In opencode.jsonc, add a broadnet entry under providers with package @opencode/ai/providers/openai-compatible, settings.baseURL set to https://inference.broadnet.ai/v1 and env set to BROADNET_API_KEY. Map short model keys to BroadNet IDs with modelID, such as broadnet/glm-5.3, then pick the model with /models. Older V1 configs using npm @ai-sdk/openai-compatible and options.baseURL still work.

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

  1. Export your key in the shell that starts opencode:
export BROADNET_API_KEY='your-broadnet-key'
  1. Create the config. Put it in your project as opencode.jsonc, or in ~/.config/opencode/opencode.jsonc to 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 }
        }
      }
    }
  }
}
  1. Start opencode and pick the model with /models. The reference is broadnet/<map key>, for example broadnet/glm-5.3. opencode sends the modelID value 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_KEY is 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 that modelID matches BroadNet’s ID exactly. References are case-sensitive. Paid models need a top-up; the $5 credit covers only broadnet/gemma-4-26b-a4b and 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.

Questions

Why can't opencode find my BroadNet model?

opencode resolves the reference as provider/map key, and IDs are case-sensitive. With the config below, select broadnet/glm-5.3, where glm-5.3 is the map key. The modelID value is only what gets sent to BroadNet.

My config uses provider and npm with @ai-sdk/openai-compatible. Is that wrong?

No. That is the V1 format, and opencode's migration guide says it remains supported. The native V2 form renames provider to providers, npm to package (aisdk:@ai-sdk/openai-compatible) and options.baseURL to settings.baseURL.

Why are opencode replies empty?

The model spent its output budget on reasoning. Raise limit.output for the model. Reasoning counts toward max_tokens on BroadNet.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity