feat: Add OpenCode CLI integration instructions to READMEs and provide an example configuration file.

This commit is contained in:
CJACK
2026-02-17 13:44:14 +08:00
parent 7dcddef91f
commit d0549c27c7
3 changed files with 54 additions and 0 deletions

View File

@@ -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` 示例

View File

@@ -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

22
opencode.json.example Normal file
View File

@@ -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"
}