Skip to content

opencode

Getting started

Install opencode and omniroute, configure providers and connect them through a local API.

References



  1. Install opencode

    Install opencode using the official installer.

    Terminal window
    curl -fsSL https://opencode.ai/install | bash
  2. Install omniroute

    Install the latest omniroute release globally, then start the local server.

    Terminal window
    pnpm add -g omniroute@latest --allow-build=better-sqlite3 --allow-build=@swc/core && omniroute
  3. Configure omniroute

    Open the omniroute web UI and complete the initial setup.

    Terminal window
    open http://localhost:20128/login

  4. Configure opencode

    Create the opencode configuration directory and file.

    Terminal window
    mkdir -p ~/.config/opencode
    Terminal window
    nano ~/.config/opencode/opencode.json

    Add the following configuration and replace YOUR_OMNIROUTE_API_KEY with your omniroute API key.

    opencode.json
    {
    "$schema": "https://opencode.ai/config.json",
    "provider": {
    "omniroute": {
    "npm": "@ai-sdk/openai-compatible",
    "name": "omniroute",
    "options": {
    "baseURL": "http://localhost:20128/v1",
    "apiKey": "YOUR_OMNIROUTE_API_KEY"
    },
    "models": {
    "auto": {
    "name": "Auto / Best Available"
    }
    }
    }
    }
    }
  5. Start opencode

    Start opencode from your terminal.

    Terminal window
    opencode

    Verify that omniroute is available as a provider. If needed, use /connect and select omniroute.