From d0549c27c7e6e3b482e5fd12df9c564edccd0ec9 Mon Sep 17 00:00:00 2001 From: CJACK Date: Tue, 17 Feb 2026 13:44:14 +0800 Subject: [PATCH] feat: Add OpenCode CLI integration instructions to READMEs and provide an example configuration file. --- README.MD | 16 ++++++++++++++++ README.en.md | 16 ++++++++++++++++ opencode.json.example | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 opencode.json.example diff --git a/README.MD b/README.MD index 3182941..52779da 100644 --- a/README.MD +++ b/README.MD @@ -148,6 +148,22 @@ cp config.example.json config.json ./ds2api ``` +### 方式五:OpenCode CLI 接入 + +1. 复制示例配置: + +```bash +cp opencode.json.example opencode.json +``` + +2. 编辑 `opencode.json`: +- 将 `baseURL` 改为你的 DS2API 地址(例如 `https://your-domain.com/v1`) +- 将 `apiKey` 改为你的 DS2API key(对应 `config.keys`) + +3. 在项目目录启动 OpenCode CLI(按你的安装方式运行 `opencode`)。 + +> 建议优先使用 OpenAI 兼容路径(`/v1/*`),即示例里的 `@ai-sdk/openai-compatible` provider。 + ## 配置说明 ### `config.json` 示例 diff --git a/README.en.md b/README.en.md index 555859c..189d719 100644 --- a/README.en.md +++ b/README.en.md @@ -148,6 +148,22 @@ cp config.example.json config.json ./ds2api ``` +### Option 5: OpenCode CLI + +1. Copy the example config: + +```bash +cp opencode.json.example opencode.json +``` + +2. Edit `opencode.json`: +- Set `baseURL` to your DS2API endpoint (for example, `https://your-domain.com/v1`) +- Set `apiKey` to your DS2API key (from `config.keys`) + +3. Start OpenCode CLI in the project directory (run `opencode` using your installed method). + +> Recommended: use the OpenAI-compatible path (`/v1/*`) via `@ai-sdk/openai-compatible` as shown in the example. + ## Configuration ### `config.json` Example diff --git a/opencode.json.example b/opencode.json.example new file mode 100644 index 0000000..2933e9f --- /dev/null +++ b/opencode.json.example @@ -0,0 +1,22 @@ +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "ds2api": { + "npm": "@ai-sdk/openai-compatible", + "name": "DS2API", + "options": { + "baseURL": "http://localhost:5001/v1", + "apiKey": "your-api-key" + }, + "models": { + "deepseek-chat": { + "name": "DeepSeek Chat (DS2API)" + }, + "deepseek-reasoner": { + "name": "DeepSeek Reasoner (DS2API)" + } + } + } + }, + "model": "ds2api/deepseek-chat" +}