Auth
Berget AI auth plugin for OpenCode - authenticate with your Berget account
1
711
84 in 7 days
40.0
Multi-signal model
1 day ago
2026-10-03
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@bergetai/opencode-auth@1.2.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@bergetai/opencode-auth@1.2.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D @bergetai/opencode-authOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
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
Similar plugins
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