Self-hosted AI workspace.
Python
feat: add OpenCode Zen and Go as provider options (#26)
M5717b4f8a5b8e5
diff --git a/routes/model_routes.py b/routes/model_routes.pyindex 07d674e81..29188a72d 100644--- a/routes/model_routes.py+++ b/routes/model_routes.py@@ -285,6 +285,8 @@ _HOST_TO_CURATED = (("x.ai", "xai"),("openrouter.ai", "openrouter"),("ollama.com", "ollama"),+ ("opencode.ai/zen/go", "opencode-go"),+ ("opencode.ai/zen", "opencode-zen"),)diff --git a/routes/webhook_routes.py b/routes/webhook_routes.pyindex d1372bea8..5cf739fda 100644--- a/routes/webhook_routes.py+++ b/routes/webhook_routes.py@@ -194,6 +194,8 @@ def setup_webhook_routes("together": "https://api.together.xyz/v1","openrouter": "https://openrouter.ai/api/v1","ollama": "https://ollama.com/api",+ "opencode-zen": "https://opencode.ai/zen/v1",+ "opencode-go": "https://opencode.ai/zen/go/v1","fireworks": "https://api.fireworks.ai/inference/v1","venice": "https://api.venice.ai/api/v1",}diff --git a/src/llm_core.py b/src/llm_core.pyindex 9123a1b4a..691ed30c9 100644--- a/src/llm_core.py+++ b/src/llm_core.py@@ -414,6 +414,10 @@ def _detect_provider(url: str) -> str:return "ollama"if _host_match(url, "anthropic.com"):return "anthropic"+ if _host_match(url, "opencode.ai/zen/go"):+ return "opencode-go"+ if _host_match(url, "opencode.ai/zen"):+ return "opencode-zen"if _host_match(url, "openrouter.ai"):return "openrouter"if _host_match(url, "groq.com"):@@ -451,6 +455,8 @@ def _provider_label(url: str) -> str:if _host_match(url, "x.ai"): return "xAI"if _host_match(url, "openai.com"): return "OpenAI"if _host_match(url, "openrouter.ai"): return "OpenRouter"+ if _host_match(url, "opencode.ai/zen/go"): return "OpenCode Go"+ if _host_match(url, "opencode.ai/zen"): return "OpenCode Zen"if _host_match(url, "groq.com"): return "Groq"from src.copilot import is_copilot_baseif is_copilot_base(url): return "GitHub Copilot"diff --git a/static/index.html b/static/index.htmlindex 98a5784e1..9aa365eb4 100644--- a/static/index.html+++ b/static/index.html@@ -2117,6 +2117,8 @@<option value="https://generativelanguage.googleapis.com/v1beta/openai" data-logo="gemini">Google Gemini</option><option value="https://api.x.ai/v1" data-logo="grok">xAI Grok</option><option value="https://api.z.ai/api/paas/v4" data-logo="zhipu">Z.AI (Zhipu)</option>+ <option value="https://opencode.ai/zen/v1" data-logo="opencode">OpenCode Zen</option>+ <option value="https://opencode.ai/zen/go/v1" data-logo="opencode">OpenCode Go</option><option value="https://api.z.ai/api/coding/paas/v4" data-logo="zhipu">Z.AI Coding Plan</option></select><div class="admin-model-form-row">diff --git a/static/js/admin.js b/static/js/admin.jsindex b4a1c7399..06d322432 100644--- a/static/js/admin.js+++ b/static/js/admin.js@@ -773,7 +773,7 @@ function initEndpointForm() {}} catch(e) {}// Ensure /v1 suffix for bare host:port URLs (not cloud providers)- if (!u.includes('api.') && !u.includes('openrouter') && !u.includes('ollama.com') && !u.endsWith('/v1')) {+ if (!u.includes('api.') && !u.includes('openrouter') && !u.includes('opencode.ai') && !u.includes('ollama.com') && !u.endsWith('/v1')) {try {const parsed = new URL(u);if (!parsed.pathname || parsed.pathname === '/') {diff --git a/static/js/providers.js b/static/js/providers.jsindex ee619cab5..327e0bbff 100644--- a/static/js/providers.js+++ b/static/js/providers.js@@ -11,6 +11,10 @@ const _PROVIDERS = [[/openai|gpt-|^o[13]-|chatgpt|dall-e/i,'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 10.696.453a6.023 6.023 0 0 0-5.75 4.172 6.061 6.061 0 0 0-3.946 2.945 6.024 6.024 0 0 0 .742 7.099 5.98 5.98 0 0 0 .516 4.911 6.046 6.046 0 0 0 6.51 2.9A5.996 5.996 0 0 0 13.26 23.547a6.023 6.023 0 0 0 5.75-4.172 6.061 6.061 0 0 0 3.946-2.945 6.024 6.024 0 0 0-.674-6.609zM13.26 21.047a4.508 4.508 0 0 1-2.886-1.041l.143-.082 4.793-2.769a.777.777 0 0 0 .391-.676V10.34l2.026 1.17a.072.072 0 0 1 .039.061v5.596a4.532 4.532 0 0 1-4.506 4.48zM3.968 17.64a4.473 4.473 0 0 1-.537-3.018l.143.086 4.793 2.769a.79.79 0 0 0 .782 0l5.852-3.379v2.34a.072.072 0 0 1-.029.062l-4.845 2.796a4.532 4.532 0 0 1-6.159-1.656zM2.804 7.922a4.49 4.49 0 0 1 2.348-1.973V11.6a.778.778 0 0 0 .391.676l5.852 3.378-2.026 1.17a.072.072 0 0 1-.068 0L4.456 14.03a4.532 4.532 0 0 1-1.652-6.108zm16.423 3.823L13.375 8.367l2.026-1.17a.072.072 0 0 1 .068 0l4.845 2.796a4.525 4.525 0 0 1-.7 8.08V12.42a.778.778 0 0 0-.387-.676zm2.015-3.025l-.143-.086-4.793-2.769a.79.79 0 0 0-.782 0L9.672 9.243V6.903a.072.072 0 0 1 .029-.062l4.845-2.796a4.525 4.525 0 0 1 6.696 4.675zM8.598 12.66L6.57 11.49a.072.072 0 0 1-.039-.061V5.833a4.525 4.525 0 0 1 7.413-3.48l-.143.082-4.793 2.769a.777.777 0 0 0-.391.676l-.019 6.78zm1.1-2.379l2.607-1.505 2.607 1.505v3.01l-2.607 1.505-2.607-1.505z"/></svg>'],+ // OpenCode (Zen / Go) — official brand mark+ [/opencode/i,+ '<svg viewBox="0 0 24 30" fill="currentColor"><path d="M18 6H6V24H18V6ZM24 30H0V0H24V30Z"/></svg>'],+// OpenRouter[/openrouter|open router/i,'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="5" cy="12" r="2.5"/><circle cx="19" cy="6" r="2.5"/><circle cx="19" cy="18" r="2.5"/><path d="M7.5 12h4.5c2 0 2.5-6 4.5-6"/><path d="M12 12c2 0 2.5 6 4.5 6"/></svg>'],diff --git a/static/js/slashCommands.js b/static/js/slashCommands.jsindex 1a11454bf..d1ed3e4ff 100644--- a/static/js/slashCommands.js+++ b/static/js/slashCommands.js@@ -54,8 +54,10 @@ const SETUP_PROVIDER_URLS = {groq: { name: 'Groq', url: 'https://api.groq.com/openai/v1' },gemini: { name: 'Gemini', url: 'https://generativelanguage.googleapis.com/v1beta/openai' },google: { name: 'Gemini', url: 'https://generativelanguage.googleapis.com/v1beta/openai' },+ 'opencode-zen': { name: 'OpenCode Zen', url: 'https://opencode.ai/zen/v1' },+ 'opencode-go': { name: 'OpenCode Go', url: 'https://opencode.ai/zen/go/v1' },};-const SETUP_PROVIDER_NAMES = ['deepseek', 'openai', 'openrouter', 'ollama', 'xai', 'anthropic', 'groq', 'gemini'];+const SETUP_PROVIDER_NAMES = ['deepseek', 'openai', 'openrouter', 'ollama', 'xai', 'anthropic', 'groq', 'gemini', 'opencode-zen', 'opencode-go'];const SETUP_PROVIDER_HINT = SETUP_PROVIDER_NAMES.slice(0, -1).join(', ') + ', or ' + SETUP_PROVIDER_NAMES[SETUP_PROVIDER_NAMES.length - 1];const SETUP_LOCAL_ICON = '<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-1px;margin-right:5px;"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/></svg>';const SETUP_API_ICON = '<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-1px;margin-right:5px;"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>';