Skip to Content

OpenCode

OpenAI Compatible
接口POST /v1/chat/completions

1. 安装并设置密钥

curl -fsSL https://opencode.ai/install | bash export BOTAPI_API_KEY="<YOUR_API_KEY>"

2. 配置项目

在项目根目录创建或修改 opencode.json:

{ "$schema": "https://opencode.ai/config.json", "model": "botapi/deepseek-v4.1-flash", "provider": { "botapi": { "npm": "@ai-sdk/openai-compatible", "name": "BotAPI", "options": { "baseURL": "https://api.example.com/v1", "apiKey": "{env:BOTAPI_API_KEY}" }, "models": { "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash" } } } } }

3. 验证

opencode

进入 OpenCode 后运行 /models,应能看到 botapi 下的 deepseek-v4.1-flash。若模型不可见,检查供应商 ID 是否始终为 botapi,并确认启动进程可以读取 BOTAPI_API_KEY。

@ai-sdk/openai-compatible 对应 /v1/chat/completions。不要改成面向 Responses API 的 @ai-sdk/openai。

官方参考:OpenCode 自定义供应商

Last updated on