安装
配置
编辑全局配置文件~/.config/opencode/opencode.json,文件不存在时新建:
opencode.json
然后在终端设置环境变量:
OpenCode 内置的 Anthropic 服务商使用 Vercel AI SDK,请求地址需要带
/v1。这与 Claude Code 的写法不同。验证
/models,选择吉吉API 下的模型,发送消息能正常回复即配置完成。Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
在开源终端编程助手 OpenCode 中配置吉吉API。
curl -fsSL https://opencode.ai/install | bash
npm i -g opencode-ai --registry=https://registry.npmmirror.com
brew install sst/tap/opencode
~/.config/opencode/opencode.json,文件不存在时新建:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"jiji": {
"npm": "@ai-sdk/openai-compatible",
"name": "吉吉API",
"options": {
"baseURL": "https://www.jiji.cc/v1",
"apiKey": "{env:JIJI_API_KEY}"
},
"models": {
"gpt-6.1-sol": { "name": "GPT 6.1 Sol" }
}
},
"anthropic": {
"options": {
"baseURL": "https://www.jiji.cc/v1",
"apiKey": "{env:JIJI_API_KEY}"
}
}
}
}
| 配置项 | 说明 |
|---|---|
jiji | 自定义服务商,用 OpenAI 兼容格式调用 GPT 等模型。models 中列出要使用的模型 ID |
anthropic | 覆盖内置 Anthropic 服务商的请求地址,用于调用 Claude 模型 |
{env:JIJI_API_KEY} | 从环境变量读取 Key |
echo 'export JIJI_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrc
setx JIJI_API_KEY "your-api-key-here"
/v1。这与 Claude Code 的写法不同。opencode
/models,选择吉吉API 下的模型,发送消息能正常回复即配置完成。