Auth
Berget AI auth plugin for OpenCode - authenticate with your Berget account
1
711
近 7 天 84
40.0
生态多维模型
1 天前
2026-10-03
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@bergetai/opencode-auth@1.2.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@bergetai/opencode-auth@1.2.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @bergetai/opencode-authOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Authenticate OpenCode with your Berget AI account.
Works with OpenCode V2 and V1 from one package (@bergetai/opencode-auth ≥ 1.2):
- V2 (
@opencode/cli≥ 2.0) — configure under"plugins" - V1 (
opencode-ai≥ 1.3.4) — configure under"plugin"
Quick Start
The recommended way to get started is with the Berget CLI:
npm install -g berget
berget code init
opencode
# Type /connect → choose your auth method
Manual setup
// OpenCode V2 — opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["@bergetai/opencode-auth@latest"],
}
// OpenCode V1 — opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@bergetai/opencode-auth@latest"],
}
Authentication Methods
Berget Code Seat — Magic link
For team members with a Berget Code seat, on machines with a browser:
- Run
/connectin OpenCode - Select "Berget Code Seat - Login using this device"
- The login page opens in your browser — token refresh is automatic
Berget Code Seat — Login using other device with QR
For headless environments (SSH, CI, containers) where the browser cannot open on the same machine:
- Run
/connectin OpenCode - Select "Berget Code Seat - Login using other device with QR"
- Scan the QR code with your phone, or open the link shown in the dialog — the sign-in code is already included in it
- Approve the sign-in on the other device; OpenCode continues automatically
The sign-in is valid for 10 minutes. If it times out, just run /connect again.
API Key
For API key users:
- Run
/connectin OpenCode - Select "Berget API Key - Enter API key manually"
- Paste your key — persisted across sessions
Version Compatibility
| OpenCode CLI | Plugin version | Config key |
|---|---|---|
@opencode/cli (V2) |
@bergetai/opencode-auth 1.2.x |
plugins |
opencode-ai ≥ 1.3.4 |
@bergetai/opencode-auth 1.2.x |
plugin |
opencode-ai < 1.3.4 |
pin @bergetai/opencode-auth@1.1.1 |
plugin |
OpenCode V1 CLIs older than 1.3.4 cannot load object-form default exports; on those
versions the plugin fails to load with a visible error. Pin the exact version
@bergetai/opencode-auth@1.1.1 to keep using it on older V1 releases — the @1
dist-tag now resolves to the 1.2.x line, which requires V1 ≥ 1.3.4.
Coming from OpenCode V1 on V2?
Your V1 login carries over: on startup the plugin imports the berget credential from
V1's auth.json into V2's credential store when OpenCode exposes the import surface
(V2 2.0.22 does not yet — see docs/auth.md; until then, log in once via
/connect). Once imported, token refresh is handled by the framework; refreshes made
while on V2 are not written back to V1's store, so a long V2 session may require one
re-login if you later downgrade to 1.1.x.
How It Works
- PKCE Authorization Flow for browser login (magic link)
- Device Authorization Grant (RFC 8628) for QR / device code login on headless machines
- Automatic token refresh — V1 uses a custom fetch; V2 delegates to the framework's credential store (see docs/auth.md)
- Models fetched dynamically from Berget API — no manual config needed
License
MIT
同类生态推荐
Qwen Auth
opencode-qwen-auth
Qwen OAuth authentication plugin for OpenCode with multi-account rotation and API translation
Qwen Auth
@speto/opencode-qwen-auth
Qwen OAuth authentication plugin for OpenCode with multi-account rotation and API translation
Qwencode Auth
opencode-qwencode-auth
Qwen OAuth authentication plugin for OpenCode - Access Qwen AI models (Coder, Vision) with your qwen.ai account