OpenCode
在 OpenCode 中使用 APICAT 文本模型进行 AI 编程。
安装 OpenCode
- 使用
curl安装 OpenCode
curl -fsSL https://opencode.ai/install | bash
- 使用
npm安装 OpenCode
npm i -g opencode-ai
更多信息请参考 OpenCode 官网
使用内置的 example-coding-model 模型
配置 APICAT API
运行认证命令
opencode auth login
选择 Provider
当提示选择 provider 时,搜索并选择 "APICAT(payapionline.top)"。

输入 API Key
当提示输入 API 密钥时,输入您的 APICAT API Key。

开始使用
回到命令行界面,输入 opencode 开始使用已配置模型。

其他配置方式:
编辑配置文件
编辑 OpenCode 的配置文件,路径为 ~/.config/opencode/opencode.json,将以下配置添加到配置文件中:
WARNING
重要提示:使用前请先清除 Anthropic 环境变量
在配置前,请确保清除以下 Anthropic 相关的环境变量,以免影响 APICAT API 的正常使用:
ANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URL
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"APICAT": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "https://www.zeoapi.com/anthropic/v1",
"apiKey": "your-api-key (可选)"
},
"models": {
"example-coding-model": {
"name": "example-coding-model"
}
}
}
}
}
启动 OpenCode
进入项目目录,启动 opencode:
cd /path/to/your/project
opencode
选择模型
输入 /models,选择已配置模型并在 OpenCode 中开始使用。