Get started with OpenCode and Berget AI

Install OpenCode, connect it to Berget AI, and run your first AI-assisted coding session on European infrastructure

In this tutorial, you'll install OpenCode, configure it to use Berget AI as its AI provider, and run your first prompt from the terminal. By the end, you will have a working AI coding assistant running on Berget AI's European infrastructure.

Before you start

To complete this tutorial, you'll need:

Set up OpenCode

You'll configure OpenCode to send requests to Berget AI instead of its default provider.

Install OpenCode

Install the OpenCode CLI using your preferred method.

curl -fsSL https://opencode.ai/install | bash
brew install anomalyco/tap/opencode
npm install -g opencode-ai

Verify the installation by running:

opencode --version

Install the Berget AI plugin

Create a file called opencode.json in your project root (or in ~/.config/opencode/opencode.json to apply it globally).

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@bergetai/opencode-auth"]
}

Run OpenCode

In your project directory, start OpenCode:

opencode

Create a Berget AI API key

  1. Go to API Keys in the Berget AI Console.
  2. Click + Create New Key.
  3. Enter a name in the Key Name field (e.g. OpenCode).
  4. Click + Create Key.
  5. Store it somewhere safe — it won't be shown again.
berget api-keys create --name "OpenCode"

The key is printed once in full (sk_ber_... format). Store it somewhere safe — it won't be shown again.

Connect the Berget AI provider

In the text field, type /connect and select Berget AI from the list of providers. Then select Enter Berget API Key manually and submit your API key.

You can now select any of our models by pressing Ctrl+X and then M. We recommend GLM 4.7 for coding tasks.

What you built

You now have OpenCode running as an AI coding assistant in your terminal, backed by Berget AI. Every prompt you send — your code, your questions, the responses — stays within the EU and is processed on Berget AI's European infrastructure.

For more information how to use OpenCode, see the OpenCode docs.

Next steps

  • Models — browse available models
  • Quickstart — call Berget AI directly from your own code

On this page