From 52f41536916055c897d92864daa8414076cf8a79 Mon Sep 17 00:00:00 2001 From: mqyang56 Date: Wed, 25 Feb 2026 10:40:47 +0800 Subject: [PATCH] feat: add OpenCode Zen provider (opencode/ prefix) Add support for OpenCode Zen as a new LLM provider gateway. - Protocol prefix: opencode/ - Default API base: https://opencode.ai/zen/v1 - Supports 30+ models (GPT-5, Claude, Gemini, etc.) via OpenAI-compatible API - Update all README variants and config.example.json with usage examples --- README.fr.md | 1 + README.ja.md | 1 + README.md | 13 +++++++++++++ README.pt-br.md | 1 + README.vi.md | 1 + README.zh.md | 13 +++++++++++++ config/config.example.json | 5 +++++ pkg/providers/factory_provider.go | 6 ++++-- pkg/providers/factory_provider_test.go | 1 + 9 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.fr.md b/README.fr.md index f59807739..1bde79f11 100644 --- a/README.fr.md +++ b/README.fr.md @@ -917,6 +917,7 @@ Cette conception permet également le **support multi-agent** avec une sélectio | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [Obtenir Clé](https://cerebras.ai) | | **Volcengine** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [Obtenir Clé](https://console.volcengine.com) | | **ShengsuanYun** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [Obtenir Clé](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | Custom | OAuth uniquement | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | diff --git a/README.ja.md b/README.ja.md index 5a7bb8542..40ce524a2 100644 --- a/README.ja.md +++ b/README.ja.md @@ -856,6 +856,7 @@ HEARTBEAT_OK 応答 ユーザーが直接結果を受け取る | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [キーを取得](https://cerebras.ai) | | **Volcengine** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [キーを取得](https://console.volcengine.com) | | **ShengsuanYun** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [キーを取得](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | カスタム | OAuthのみ | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | diff --git a/README.md b/README.md index 2b770f215..75fdd140e 100644 --- a/README.md +++ b/README.md @@ -823,6 +823,7 @@ This design also enables **multi-agent support** with flexible provider selectio | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [Get Key](https://cerebras.ai) | | **火山引擎** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [Get Key](https://console.volcengine.com) | | **神算云** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [Get Key](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | Custom | OAuth only | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | @@ -887,6 +888,18 @@ This design also enables **multi-agent support** with flexible provider selectio } ``` +**OpenCode Zen** + +```json +{ + "model_name": "opencode-zen", + "model": "opencode/claude-sonnet-4-5", + "api_key": "your-opencode-zen-api-key" +} +``` + +> Get your API key at [opencode.ai/zen](https://opencode.ai/zen). Supports 30+ models including GPT-5, Claude, and Gemini. + **Anthropic (with API key)** ```json diff --git a/README.pt-br.md b/README.pt-br.md index 0115b7f89..73e224adb 100644 --- a/README.pt-br.md +++ b/README.pt-br.md @@ -911,6 +911,7 @@ Este design também possibilita o **suporte multi-agent** com seleção flexíve | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [Obter Chave](https://cerebras.ai) | | **Volcengine** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [Obter Chave](https://console.volcengine.com) | | **ShengsuanYun** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [Obter Chave](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | Custom | Apenas OAuth | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | diff --git a/README.vi.md b/README.vi.md index 015bc264e..9cb62ca9c 100644 --- a/README.vi.md +++ b/README.vi.md @@ -882,6 +882,7 @@ Thiết kế này cũng cho phép **hỗ trợ đa tác nhân** với lựa ch | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [Lấy Khóa](https://cerebras.ai) | | **Volcengine** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [Lấy Khóa](https://console.volcengine.com) | | **ShengsuanYun** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [Lấy Khóa](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | Tùy chỉnh | Chỉ OAuth | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | diff --git a/README.zh.md b/README.zh.md index 4f4bde46a..f48ab1e31 100644 --- a/README.zh.md +++ b/README.zh.md @@ -458,6 +458,7 @@ Agent 读取 HEARTBEAT.md | **Cerebras** | `cerebras/` | `https://api.cerebras.ai/v1` | OpenAI | [获取密钥](https://cerebras.ai) | | **火山引擎** | `volcengine/` | `https://ark.cn-beijing.volces.com/api/v3` | OpenAI | [获取密钥](https://console.volcengine.com) | | **神算云** | `shengsuanyun/` | `https://router.shengsuanyun.com/api/v1` | OpenAI | - | +| **OpenCode Zen** | `opencode/` | `https://opencode.ai/zen/v1` | OpenAI | [获取密钥](https://opencode.ai/zen) | | **Antigravity** | `antigravity/` | Google Cloud | 自定义 | 仅 OAuth | | **GitHub Copilot** | `github-copilot/` | `localhost:4321` | gRPC | - | @@ -522,6 +523,18 @@ Agent 读取 HEARTBEAT.md } ``` +**OpenCode Zen** + +```json +{ + "model_name": "opencode-zen", + "model": "opencode/claude-sonnet-4-5", + "api_key": "your-opencode-zen-api-key" +} +``` + +> 在 [opencode.ai/zen](https://opencode.ai/zen) 获取 API Key,支持 GPT-5、Claude、Gemini 等 30+ 模型。 + **Anthropic (使用 OAuth)** ```json diff --git a/config/config.example.json b/config/config.example.json index 9575039f8..e7a89783f 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -32,6 +32,11 @@ "model": "deepseek/deepseek-chat", "api_key": "sk-your-deepseek-key" }, + { + "model_name": "opencode-zen", + "model": "opencode/claude-sonnet-4-5", + "api_key": "your-opencode-zen-api-key" + }, { "model_name": "loadbalanced-gpt4", "model": "openai/gpt-5.2", diff --git a/pkg/providers/factory_provider.go b/pkg/providers/factory_provider.go index 7d5566eef..6f6fa3bf7 100644 --- a/pkg/providers/factory_provider.go +++ b/pkg/providers/factory_provider.go @@ -53,7 +53,7 @@ func ExtractProtocol(model string) (protocol, modelID string) { // CreateProviderFromConfig creates a provider based on the ModelConfig. // It uses the protocol prefix in the Model field to determine which provider to create. -// Supported protocols: openai, anthropic, antigravity, claude-cli, codex-cli, github-copilot +// Supported protocols: openai, anthropic, opencode, antigravity, claude-cli, codex-cli, github-copilot // Returns the provider, the model ID (without protocol prefix), and any error. func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, error) { if cfg == nil { @@ -88,7 +88,7 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err case "openrouter", "groq", "zhipu", "gemini", "nvidia", "ollama", "moonshot", "shengsuanyun", "deepseek", "cerebras", - "volcengine", "vllm", "qwen", "mistral": + "volcengine", "vllm", "qwen", "mistral", "opencode": // All other OpenAI-compatible HTTP providers if cfg.APIKey == "" && cfg.APIBase == "" { return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol) @@ -188,6 +188,8 @@ func getDefaultAPIBase(protocol string) string { return "http://localhost:8000/v1" case "mistral": return "https://api.mistral.ai/v1" + case "opencode": + return "https://opencode.ai/zen/v1" default: return "" } diff --git a/pkg/providers/factory_provider_test.go b/pkg/providers/factory_provider_test.go index 6b133101a..159595c52 100644 --- a/pkg/providers/factory_provider_test.go +++ b/pkg/providers/factory_provider_test.go @@ -108,6 +108,7 @@ func TestCreateProviderFromConfig_DefaultAPIBase(t *testing.T) { {"vllm", "vllm"}, {"deepseek", "deepseek"}, {"ollama", "ollama"}, + {"opencode", "opencode"}, } for _, tt := range tests {