logo
icon

OpenAB OpenCode

Open Agent Broker — a lightweight Rust harness that bridges Discord to any ACP-compatible coding CLI over stdio JSON-RPC. This template uses OpenCode as the agent backend, supporting 75+ LLM providers (Ollama Cloud, OpenAI, Anthropic, Google, and more). Source: https://github.com/openabdev/openab

template cover
Deployed2 times
PublisherzeaburZeabur
Created2026-04-19
Minimum2 Cores4 GB
Recommended4 Cores8 GB
Tags
AIDeveloper ToolsDiscord

OpenAB OpenCode

OpenAB is a lightweight, open-source Rust harness that bridges Discord to any Agent Client Protocol-compatible coding CLI over stdio JSON-RPC.

This template uses OpenCode as the agent backend, supporting 75+ LLM providers (Ollama Cloud, OpenAI, Anthropic, Google, and more).

Important Notes

  • Image tag: This template uses a pinned version (0.8.1-beta.5). To upgrade, change the image tag in Zeabur Dashboard -> Service -> Settings. Available tags: GitHub Packages.
  • Persistent storage: /home/node is mounted as a persistent volume. Settings, config, credentials, and opencode.json survive restarts.
  • Config ownership: The container starts as root and switches to node user before running openab. If you encounter permission issues, restart the service -- ownership is fixed automatically on boot.

Setup

1. Get a Discord Bot Token

  1. Go to https://discord.com/developers/applications and click New Application
  2. Navigate to Bot tab -> click Reset Token -> copy the token
  3. On the same page, scroll down and enable Message Content Intent under Privileged Gateway Intents
  4. Go to OAuth2 -> URL Generator -> check scope bot -> check permissions: Send Messages, Send Messages in Threads, Create Public Threads, Read Message History, Add Reactions, Manage Messages
  5. Copy the generated URL and open it in your browser to invite the bot to your server

2. Configure an LLM Provider (after deployment)

OpenCode needs access to an LLM provider. The simplest approach is to set an environment variable in Zeabur Dashboard -> Service -> Variables:

VariableProvider
OPENCODE_API_KEYOpenCode (native, get key at opencode.ai)
ANTHROPIC_API_KEYAnthropic Claude
OPENAI_API_KEYOpenAI GPT
GOOGLE_GENERATIVE_AI_API_KEYGoogle Gemini
GROQ_API_KEYGroq
MISTRAL_API_KEYMistral
DEEPSEEK_API_KEYDeepSeek
OPENROUTER_API_KEYOpenRouter (proxies 100+ models)

Set at least one variable and restart the service. OpenCode picks it up automatically.

Alternative: Interactive login

For providers that use browser OAuth (e.g. AWS Bedrock, Azure OpenAI), open the service terminal in Zeabur Dashboard and run:

runuser -u node -- opencode auth login

Warning: Must run as node. Running as root writes credentials to /root/ which is not persisted; they will be lost on restart.

3. Model Selection (optional)

To configure a specific model, create or edit /home/node/opencode.json:

{
  "provider": "anthropic",
  "model": "claude-sonnet-4-20250514"
}

See OpenCode documentation for all available providers and models.

4. Get Discord Channel IDs

  1. Open Discord -> go to User Settings (gear icon) -> Advanced -> enable Developer Mode
  2. Right-click the channel where you want the bot to respond -> Copy Channel ID
  3. For multiple channels, separate IDs with commas: 123456789012345678,234567890123456789

5. Deploy

Fill in the Discord Bot Token and click deploy. The service connects to Discord automatically. Then authenticate OpenCode using the method above.

Usage

  • @mention the bot in an allowed channel to start a conversation
  • OpenAB creates a thread for multi-turn conversations -- no @mention needed for follow-ups
  • Each thread maps to a persistent OpenCode session (24h TTL)

Customization

FileDescription
/home/node/.config/openab/config.tomlOpenAB config (sessions, reactions, STT, etc.)
/home/node/opencode.jsonOpenCode model/provider config
/home/node/.opencode/OpenCode credentials and state

config.toml is created from a built-in template on first boot. After that, edit the file directly -- environment variables are only used for initial setup. To reset to defaults, delete the file and restart: rm /home/node/.config/openab/config.toml

For config options, see the OpenAB documentation.

Webhook / Bot Integration

By default, openab ignores messages from other bots and webhooks. To allow webhook-triggered messages (e.g. automated testing or CI pipelines), add the following to your config.toml:

[discord]
allow_bot_messages = "mentions"

With this setting, openab responds to any bot or webhook message that @mentions it. To restrict to a specific webhook, also add:

trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]

The webhook user ID is the numeric ID in the webhook URL: https://discord.com/api/webhooks/<ID>/...

Disabling

Leave Discord Bot Token empty. The service sleeps instead of crashing.