Skip to content

OpenCode Custom Providers: Connect DeepSeek, GLM, Kimi, Qwen

Configure OpenCode to use DeepSeek, GLM, Kimi, or Qwen through custom providers. opencode.json with the OpenAI-compatible SDK, model IDs, API keys, and fixes.

MGMCSA Guru Team June 12, 2026 4 min read
OpenCode config on Windows defining custom DeepSeek and Qwen providers

OpenCode is one of the most popular open-source coding agents — a terminal-first tool, provider-agnostic by design. Through the AI SDK and Models.dev it supports dozens of providers out of the box, and for anything it doesn’t list, you can wire up a custom provider in a few lines. That makes it a natural home for cheap models like DeepSeek, GLM, Kimi, and Qwen.

This covers the config that connects any OpenAI-compatible endpoint, where the files live, and the small things that go wrong. For why you’d run a cheaper backend at all, see use cheap AI models with Claude Code — the cost logic carries straight over.

Two ways to add a provider

OpenCode supports many providers natively. For an OpenAI-compatible one, you have two paths:

  • Quick: opencode auth login, scroll to Other, paste your key and base URL.
  • Explicit: define a custom provider in the config — clearer, reproducible, and version-controllable.

The config approach is worth knowing because it pins exact model IDs and base URLs.

Install OpenCode

npm install -g opencode-ai

On Windows it works directly, but WSL gives the cleaner shell — see install OpenCode on Windows with WSL and the WSL install guide.

Add a custom provider

OpenCode reads a global config (commonly ~/.config/opencode/opencode.json) and a project-level opencode.json. A custom DeepSeek provider using the OpenAI-compatible SDK looks like this:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "deepseek": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DeepSeek",
      "options": {
        "baseURL": "https://api.deepseek.com/v1",
        "apiKey": "{env:DEEPSEEK_API_KEY}"
      },
      "models": {
        "deepseek-chat": { "name": "DeepSeek Chat" },
        "deepseek-reasoner": { "name": "DeepSeek Reasoner" }
      }
    }
  }
}

The {env:DEEPSEEK_API_KEY} syntax pulls the key from your environment instead of hard-coding it. Export it first:

export DEEPSEEK_API_KEY="sk-your-key"

Other providers

Same structure, different endpoint. Qwen via Alibaba’s international OpenAI-compatible URL:

{
  "provider": {
    "dashscope": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Qwen",
      "options": {
        "baseURL": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
        "apiKey": "{env:DASHSCOPE_API_KEY}"
      },
      "models": { "qwen3-coder-plus": { "name": "Qwen3 Coder Plus" } }
    }
  }
}

Custom provider fields

npm @ai-sdk/openai-compatible for OpenAI-style APIs
name Display name
options.baseURL The provider's /v1 endpoint
options.apiKey {env:VAR} reads from your environment
models Map of model IDs OpenCode can use

For per-model specifics, see DeepSeek + OpenCode, GLM + OpenCode, Kimi K2.5 Turbo + OpenCode, and MiniMax M2 + OpenCode.

Pick the model and run

Set a default model in the config or choose it in the TUI:

{
  "model": "deepseek/deepseek-chat"
}

Then launch:

opencode

The model identifier is always provider/model, matching your config keys.

Troubleshooting

  • Provider not found — the provider key and the model prefix must match exactly (deepseekdeepseek/...).
  • Auth failures — the {env:...} variable isn’t set in the shell that launched OpenCode.
  • Wrong base URL — most providers expect the /v1 suffix; confirm on their docs.
  • Model ID rejected — pull the current model name from the provider; IDs change between releases.

OpenCode custom provider checklist

  • Install OpenCode (npm i -g opencode-ai)
  • Add a provider block with @ai-sdk/openai-compatible
  • Set baseURL and apiKey via {env:VAR}
  • List the model IDs you'll use
  • Set a default model and launch with opencode

Wrapping up

OpenCode runs on any cheap model through one config pattern: a custom provider using @ai-sdk/openai-compatible, with the base URL, an {env:...} API key, and your model list. Set a default provider/model and launch. The same block works for DeepSeek, Qwen, GLM, Kimi, and local servers — only the URL and IDs change.

For the bigger landscape, see best cheap Claude Code alternatives for Windows and the head-to-head in Claude Code vs Codex vs OpenCode vs Aider.

Frequently asked questions

What is OpenCode?

OpenCode is an open-source, terminal-based AI coding agent written in Go. It's provider-agnostic — through the AI SDK and Models.dev it supports 75+ providers and local models — so you can run it on cheap models like DeepSeek or Qwen instead of a single vendor's.

How do I add a provider that isn't built in?

Define it under the provider section of your OpenCode config using the @ai-sdk/openai-compatible npm package, with the provider's base URL, API key, and model list. Any OpenAI-compatible endpoint works this way.

Where is the OpenCode config file?

OpenCode reads a global config (commonly ~/.config/opencode/opencode.json) and a project-level opencode.json. You can also point it elsewhere with the OPENCODE_CONFIG environment variable, which takes precedence.

Can I just log in instead of editing config?

For OpenAI-compatible providers, run opencode auth login, scroll to Other, and add the key. For full control over model IDs and base URLs, the config file is clearer and reproducible.

Does OpenCode work on Windows?

Yes, and it runs cleanly in WSL too. On Windows many users prefer WSL for the standard shell environment, but the config format is identical either way.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.