Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: add OpenCode Zen and OpenCode Go to Connections (#16010)

Nilay1f3eb9df3ddf
diff --git a/studio/backend/core/inference/provider_model_capabilities.py b/studio/backend/core/inference/provider_model_capabilities.py
index 64925c287c8..33e5e24b4ec 100644
--- a/studio/backend/core/inference/provider_model_capabilities.py
+++ b/studio/backend/core/inference/provider_model_capabilities.py
@@ -91,6 +91,8 @@ MODELS_DEV_PROVIDER_MAP = {
"huggingface": "huggingface",
"alibaba": "qwen",
"zai": "zai",
+ "opencode": "opencode",
+ "opencode-go": "opencode_go",
"ollama-cloud": "ollama",
"lmstudio": "lmstudio",
}
diff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.py
index 34f66c4ca61..44dd4d37a9c 100644
--- a/studio/backend/core/inference/providers.py
+++ b/studio/backend/core/inference/providers.py
@@ -286,6 +286,48 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"notes": "Z.ai API key. China mainland: use base URL https://open.bigmodel.cn/api/paas/v4",
"body_omit": ("presence_penalty",),
},
+ # Zen is pay as you go, Go a subscription; both translate every text model to /chat/completions.
+ "opencode": {
+ "display_name": "OpenCode Zen",
+ "base_url": "https://opencode.ai/inference/v1",
+ "default_models": [
+ "kimi-k3",
+ "glm-5.3",
+ "minimax-m3",
+ "qwen3.8-max",
+ "deepseek-v4-pro",
+ "kimi-k2.7-code",
+ ],
+ "supports_streaming": True,
+ "supports_vision": True,
+ "supports_tool_calling": True,
+ "studio_tools": True,
+ "auth_header": "Authorization",
+ "auth_prefix": "Bearer ",
+ "extra_headers": {"User-Agent": "unsloth-studio"},
+ # Free tier ids only work from the OpenCode client; jev is a decision model.
+ "model_id_denylist": re.compile(r"-free$|^big-pickle$|^jev-"),
+ },
+ "opencode_go": {
+ "display_name": "OpenCode Go",
+ # _chat_headers adds the x-opencode-session header Go requires.
+ "base_url": "https://opencode.ai/inference/go/v1",
+ "default_models": [
+ "kimi-k3",
+ "glm-5.3",
+ "minimax-m3",
+ "qwen3.8-max",
+ "deepseek-v4-pro",
+ "kimi-k2.7-code",
+ ],
+ "supports_streaming": True,
+ "supports_vision": True,
+ "supports_tool_calling": True,
+ "studio_tools": True,
+ "auth_header": "Authorization",
+ "auth_prefix": "Bearer ",
+ "model_id_denylist": re.compile(r"-free$"),
+ },
"qwen": {
"display_name": "Qwen",
"base_url": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 4ae83c8cc0d..4c582635857 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -9396,11 +9396,18 @@ _TEXT_ONLY_PROVIDER_TYPES = frozenset({"cohere", "deepseek", "mistral"})
# because its allowlist permits only multimodal kimi-k3/k2.5/k2.6.
# Single-endpoint types (custom, vllm, ollama, llamacpp, lmstudio) retain the
# registry default: no model catalog exists to check the configured endpoint.
-_MIXED_CATALOG_PROVIDER_TYPES = frozenset({"huggingface", "openrouter", "qwen", "qwencloud", "zai"})
+_MIXED_CATALOG_PROVIDER_TYPES = frozenset(
+ {"huggingface", "openrouter", "qwen", "qwencloud", "zai", "opencode", "opencode_go"}
+)
# Mixed catalogs whose models.dev namespace answers vision per model.
# Mirrors CATALOG_VISION_PROVIDER_TYPES in external-providers.ts.
-_CATALOG_VISION_NAMESPACES = {"qwencloud": "qwen", "zai": "zai"}
+_CATALOG_VISION_NAMESPACES = {
+ "qwencloud": "qwen",
+ "zai": "zai",
+ "opencode": "opencode",
+ "opencode_go": "opencode_go",
+}
def _external_takes_mcp_images(
diff --git a/studio/backend/tests/test_opencode_providers.py b/studio/backend/tests/test_opencode_providers.py
new file mode 100644
index 00000000000..fcf35abc15a
--- /dev/null
+++ b/studio/backend/tests/test_opencode_providers.py
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import asyncio
+
+import httpx
+
+from core.inference import external_provider as ep
+from core.inference.providers import get_base_url, get_provider_info, list_available_providers
+
+
+def _capture(
+ monkeypatch,
+ provider_type,
+ model,
+ thread_id = None,
+) -> dict:
+ captured: dict = {}
+
+ def handler(request):
+ captured["url"] = str(request.url)
+ captured["headers"] = request.headers
+ return httpx.Response(
+ 200, headers = {"content-type": "text/event-stream"}, content = "data: [DONE]\n\n"
+ )
+
+ async def run():
+ async with httpx.AsyncClient(transport = httpx.MockTransport(handler)) as http:
+ monkeypatch.setattr(ep, "_client", lambda: http)
+ client = ep.ExternalProviderClient(
+ provider_type, get_base_url(provider_type), "sk-test"
+ )
+ async for _ in client.stream_chat_completion(
+ messages = [{"role": "user", "content": "hi"}], model = model, thread_id = thread_id
+ ):
+ pass
+
+ asyncio.run(run())
+ return captured
+
+
+def test_opencode_providers_listed():
+ types = {p["provider_type"] for p in list_available_providers()}
+ assert {"opencode", "opencode_go"} <= types
+
+
+def test_opencode_go_sends_session(monkeypatch):
+ cap = _capture(monkeypatch, "opencode_go", "kimi-k3", thread_id = "thread-abc")
+ assert cap["url"] == "https://opencode.ai/inference/go/v1/chat/completions"
+ assert cap["headers"]["x-opencode-session"]
+ assert cap["headers"]["user-agent"] == "unsloth-studio"
+ assert cap["headers"]["authorization"] == "Bearer sk-test"
+
+
+def test_opencode_zen_identifies_studio(monkeypatch):
+ cap = _capture(monkeypatch, "opencode", "glm-5.3")
+ assert cap["url"] == "https://opencode.ai/inference/v1/chat/completions"
+ assert cap["headers"]["user-agent"] == "unsloth-studio"
+ assert "x-opencode-session" not in cap["headers"]
+
+
+def test_opencode_hides_free_tier_models():
+ zen = get_provider_info("opencode")["model_id_denylist"]
+ go = get_provider_info("opencode_go")["model_id_denylist"]
+ zen_ids = ("big-pickle", "glm-5.3-flash-free", "jev-1.13", "glm-5.3")
+ assert [m for m in zen_ids if not zen.search(m)] == ["glm-5.3"]
+ go_ids = ("beam-free", "iceman-contributor-free", "kimi-k3")
+ assert [m for m in go_ids if not go.search(m)] == ["kimi-k3"]
+
+
+def test_opencode_mcp_images_follow_the_models_dev_catalog(monkeypatch):
+ from core.inference.provider_model_capabilities import trim_models_dev_catalog
+ from routes import providers as provider_routes
+ from routes.inference import _external_takes_mcp_images
+
+ models = {
+ "kimi-k3": {"modalities": {"input": ["text", "image"]}},
+ "glm-5.3": {"modalities": {"input": ["text"]}},
+ }
+ catalog = trim_models_dev_catalog(
+ {"opencode": {"models": models}, "opencode-go": {"models": models}}
+ )
+ monkeypatch.setattr(
+ provider_routes, "_model_catalog_cache", {"fetched_at": 0, "providers": catalog}
+ )
+ for provider_type in ("opencode", "opencode_go"):
+ info = get_provider_info(provider_type)
+ vision = info["supports_vision"]
+ assert _external_takes_mcp_images(provider_type, vision, "kimi-k3", info) is True
+ assert _external_takes_mcp_images(provider_type, vision, "glm-5.3", info) is False
+ assert _external_takes_mcp_images(provider_type, vision, "unknown-model", info) is False
diff --git a/studio/frontend/public/provider-logos/opencode.svg b/studio/frontend/public/provider-logos/opencode.svg
new file mode 100644
index 00000000000..f32aa3c5624
--- /dev/null
+++ b/studio/frontend/public/provider-logos/opencode.svg
@@ -0,0 +1,5 @@
+<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="512" height="512" fill="#131010"/>
+<path d="M320 224V352H192V224H320Z" fill="#5A5858"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M384 416H128V96H384V416ZM320 160H192V352H320V160Z" fill="white"/>
+</svg>
diff --git a/studio/frontend/scripts/refresh-model-catalog-snapshot.mjs b/studio/frontend/scripts/refresh-model-catalog-snapshot.mjs
index fbeee02ae62..6ca03261c20 100644
--- a/studio/frontend/scripts/refresh-model-catalog-snapshot.mjs
+++ b/studio/frontend/scripts/refresh-model-catalog-snapshot.mjs
@@ -25,6 +25,8 @@ const PROVIDER_MAP = {
huggingface: "huggingface",
alibaba: "qwen",
zai: "zai",
+ opencode: "opencode",
+ "opencode-go": "opencode_go",
"ollama-cloud": "ollama",
lmstudio: "lmstudio",
};
diff --git a/studio/frontend/src/features/chat/external-providers.ts b/studio/frontend/src/features/chat/external-providers.ts
index 109120866aa..bbc5282db77 100644
--- a/studio/frontend/src/features/chat/external-providers.ts
+++ b/studio/frontend/src/features/chat/external-providers.ts
@@ -250,9 +250,17 @@ export function providerModelSupportsVision(
// Mirrors _MIXED_CATALOG_PROVIDER_TYPES in studio/backend/routes/inference.py: vision for
// the family, unknown for a given model, so an MCP picture is not sent to one the
// registry says nothing about.
-const MIXED_CATALOG_PROVIDER_TYPES = new Set(["huggingface", "openrouter", "qwen", "qwencloud", "zai"]);
+const MIXED_CATALOG_PROVIDER_TYPES = new Set([
+ "huggingface",
+ "openrouter",
+ "qwen",
+ "qwencloud",
+ "zai",
+ "opencode",
+ "opencode_go",
+]);
// Mirrors _CATALOG_VISION_NAMESPACES: mixed catalogs whose model catalog answers vision per model.
-const CATALOG_VISION_PROVIDER_TYPES = new Set(["qwencloud", "zai"]);
+const CATALOG_VISION_PROVIDER_TYPES = new Set(["qwencloud", "zai", "opencode", "opencode_go"]);
/** Same rule as the backend's _external_takes_mcp_images, so stripped images are not resent. */
export function providerModelTakesMcpImages(
diff --git a/studio/frontend/src/features/chat/provider-logo-path.ts b/studio/frontend/src/features/chat/provider-logo-path.ts
index 64c8b19319f..c0b52222748 100644
--- a/studio/frontend/src/features/chat/provider-logo-path.ts
+++ b/studio/frontend/src/features/chat/provider-logo-path.ts
@@ -28,6 +28,8 @@ const CONNECTION_LOGO_PATHS = new Map([
["llama_cpp", "/provider-logos/llama_cpp.svg"],
["liquid", "/provider-logos/liquid.svg"],
["typesafe", "/provider-logos/typesafe.svg"],
+ ["opencode", "/provider-logos/opencode.svg"],
+ ["opencode_go", "/provider-logos/opencode.svg"],
]);
export function providerLogoPath(
diff --git a/studio/frontend/tests/provider-logo-path.test.ts b/studio/frontend/tests/provider-logo-path.test.ts
index 8fe5dc11378..b1184e8f858 100644
--- a/studio/frontend/tests/provider-logo-path.test.ts
+++ b/studio/frontend/tests/provider-logo-path.test.ts
@@ -40,7 +40,7 @@ test("every supported connection resolves to an existing public asset", () => {
for (const type of [
"openai", "openai_codex", "deepseek", "mistral", "huggingface", "kimi",
"qwen", "qwencloud", "gemini", "anthropic", "openrouter", "vllm", "ollama", "llama_cpp",
- "liquid", "typesafe", "zai",
+ "liquid", "typesafe", "zai", "opencode", "opencode_go",
]) {
const path = providerLogoPath(type);
assert.ok(path?.startsWith("/"), type);