opencode
Getting started
Section titled “Getting started”Install opencode and omniroute, configure providers and connect them through a local API.
References
Section titled “References”-
Install opencode
Section titled “Install opencode”Install opencode using the official installer.
Terminal window curl -fsSL https://opencode.ai/install | bash -
Install omniroute
Section titled “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 -
Configure omniroute
Section titled “Configure omniroute”Open the omniroute web UI and complete the initial setup.
Terminal window open http://localhost:20128/login- Set an omniroute password.
- Get API keys for the providers you want to use:
- Add providers http://localhost:20128/dashboard/providers.
- Create omniroute API key http://localhost:20128/dashboard/api-manager.
-
Configure opencode
Section titled “Configure opencode”Create the opencode configuration directory and file.
Terminal window mkdir -p ~/.config/opencodeTerminal window nano ~/.config/opencode/opencode.jsonAdd the following configuration and replace
YOUR_OMNIROUTE_API_KEYwith 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"}}}}} -
Start opencode
Section titled “Start opencode”Start opencode from your terminal.
Terminal window opencodeVerify that omniroute is available as a provider. If needed, use
/connectand selectomniroute.