Skip to main content

Opencode Configuration

Official guide: https://opencode.ai/v2/docs

CLI Version

Linux & macOS

  • Download cli version:
curl -fsSL https://opencode.ai/v2/install | bash
  • open the application on the terminal with the command:
opencode
  • Then exit from the application with the command \quit or by pressing Ctrl+C
  • Open the configuration file .config/opencode/opencode.jsonc in your file explorer and replace its contents with the new settings below.
  • In the "apiKey" line insert your API key
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "elettragateway": {
      "name": "ElettraGateway",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://llm-api-gw.elettra.eu/v1",
        "apiKey": "sk_ePkBU....." //insert your apiKey
      },
      "models": {
        "balanced": {
          "name": "balanced",
          "limit": {
            "context": 262144,
            "input": 262144,
            "output": 100000
          },
          "modalities": {
            "input": ["text", "image"]
          }
        },
        "top": {
          "name": "top",
          "limit": {
            "context": 1000000,
            "input": 1000000,
            "output": 100000
          },
          "modalities": {
            "input": ["text", "image"]
          }
        },
        "fast": {
          "name": "fast",
          "limit": {
            "context": 131000,
            "input": 131000,
            "output": 100000
          }
        }
      }
    }
  }
}
  • In a terminal, navigate to the directory of the project you want to work on.
  • Launch Opencode in that directory and type /models, then choose top, balanced, or fast based on your needs.
    You’ll now have access to everything you need within the project.

Windows

We suggest you use the Windows Subsystem for Linux (WSL)
After activating it, use the same procedure as described in Linux & macOS to install and use it!

DESKTOP Version

  • Download the correct installer for your operating system from
    https://opencode.ai/v2/docs#desktop and complete the installation.

  • Edit the configuration file

    • On Linux/macOS: ~/.config/opencode/opencode.jsonc
    • On Windows: C:\Users\<YourUser>\.config\opencode\opencode.jsonc

    Replace its contents with the settings you need (ensure the file is valid JSONC).

  • Launch Opencode from a terminal or by double‑clicking the application icon.

  • In Opencode, go to File → Settings → Models.

    • Enable the top, balanced, fast model.
    • Disable any other models that are listed.
  • In the prompt bar, select the model you prefer (the one you just enabled).
    You’re now ready to use it.