Set up OpenCode as your AI coding agent
OpenCode is an AI-powered coding agent that lets you write, test, and manage code through natural language. It supports multiple AI providers and can run shell commands, create files, and install development environments from a chat interface.
On Olares, you can use OpenCode in two ways:
- Browser: Install OpenCode as an app on Olares and access it through your browser.
- Local CLI: Install OpenCode on your computer and connect it to a model on Olares for a native terminal experience.
Learning objectives
By the end of this tutorial, you will learn how to:
- Install OpenCode on Olares and connect it to a local model or OpenAI.
- Create projects and run coding tasks through the chat interface or the terminal-based UI (TUI).
- Use OpenCode from your local computer over the LarePass VPN or from inside VS Code.
- Edit the OpenCode configuration file to manage providers, models, and tools.
Prerequisites
Before you begin, you need:
An Olares device running Olares 1.12.7 or later, with sufficient disk space and memory.
Access to Router for local model connections.
Admin privileges to install apps from Market.
Additional requirements depend on how you use OpenCode:
Usage Requirements Browser with a local model Qwen3.8-27B (llama.cpp) installed from Market Browser with OpenAI A ChatGPT Plus/Pro account or an OpenAI API key OpenCode CLI on your computer A default chat model configured in Router and a Router-issued API key.
Optional: Use a different model
Install another chat model from Market, or create a model instance with Engine Base apps. Then select it as the default chat model on Router's Default models page. Clients configured with default-chat use the new default without changing their model settings.
To keep a client on one specific model, use the full model name from Router's How to call this model window instead.
Run OpenCode in the browser
This option installs OpenCode as an application on your Olares device. You access it through your browser.
Install OpenCode
Open Market and search for "OpenCode".

Click Get, then Install, and wait for installation to complete.
After installation, you will see two icons on Launchpad:
- OpenCode: The main interface for OpenCode.
- OpenCode Terminal: A command-line terminal for OpenCode. Use this if you prefer working in the TUI.
Get model connection details
Planning to use oh-my-openagent?
For multi-local-model setups under oh-my-openagent, use single-model apps. Each model gets its own endpoint, which lets you register it as a separate provider and tune per-model settings like concurrency limits.
How model connections work
On Olares 1.12.7 and later, AI clients connect through Olares Router. Router provides the Base URL and routes default-chat to the model selected on its Default models page.
This guide uses Qwen3.8-27B (llama.cpp) as the default chat model. For connection formats and API key requirements, see Connect AI apps.
In this example, OpenCode connects to Qwen3.8-27B using the OpenAI-compatible API format:
Open Router from Launchpad. On Default models, set Qwen3.8-27B (llama.cpp) as the default chat model.
Go to LLM, find Qwen3.8-27B (llama.cpp), and click View connection example on its row.
In How to call this model, select Apps in Olares and copy the Base URL, including
/v1.For the model name, use
default-chat.Selecting a model in your app
default-chatis a routing name and does not appear in model lists loaded from Router. If the app you are connecting to Router loads a model list, adddefault-chatmanually. If the app only supports selecting a listed model, select the full model name shown in Router's How to call this model window.For the API key, leave the field empty. If the app you are connecting to Router requires a value, enter
olares.
Connect to a custom provider
Add Qwen3.8-27B as a custom provider in OpenCode.
In OpenCode, click settings in the bottom-left corner.

Select Providers, then scroll down and select Connect next to Custom Provider.

Enter the following details:
- Provider ID: Enter a unique identifier, such as
olares. - Display name: Enter the name shown in the provider list, such as
Router chat. - Base URL: Paste the Base URL copied from Router. Use it exactly as displayed.
- Models:
- Model ID: Enter
default-chat. - Display Name: Enter the name shown for this model, such as
Router chat.
- Model ID: Enter
- Provider ID: Enter a unique identifier, such as
Click Submit to save the configuration. Your newly added provider will appear in the provider list.
Connect to OpenAI
OpenCode supports two practical ways to connect OpenAI:
- Browser sign-in: Recommended for ChatGPT Plus or Pro accounts.
- API key: Simple and direct. Usage is billed separately by OpenAI based on token usage, even if you also have a ChatGPT subscription.
Do not use headless sign-in
The headless sign-in method is prone to known failures caused by OpenAI security checks. After a failed attempt, the sign-in flow might not recover for a short period of time. Use browser sign-in or an API key instead.
Create a project
The default workspace is Home/Code in Files. Click + in the left navigation bar to create a project.

To work with multiple projects, create subfolders under Home/Code first:
Open Files and navigate to
Home/Code/.Create a subfolder for each project.

Go back to OpenCode, click +, and open the project with the subfolder name.

Start coding
You can now interact with OpenCode through the chat interface.
Select a project to open the coding agent interface.
Below the chat box, select Big Pickle to open the model selector, and select Router chat from the list.
Type a coding task in natural language.

Click folder_open to open the file browser and review the generated code.

Use
@to mention a file in the chat window and ask OpenCode to edit it.
Use the TUI
OpenCode also offers a terminal-based UI (TUI). You can launch it in two ways:
- Inside the OpenCode UI: Open a terminal panel at the bottom of the OpenCode UI, similar to VS Code's integrated terminal. The agent chat stays visible above while the TUI runs in the panel.
- From OpenCode Terminal: Open OpenCode Terminal from Launchpad. It opens straight into a command line, without the chat UI.
Run OpenCode from your computer
This optional workflow installs OpenCode CLI on your computer and connects it to Olares Router using an API key.
Install OpenCode CLI
Install the CLI using the official installer:
bashcurl -fsSL https://opencode.ai/install | bash(Optional) If you encounter the
No config file found for zsherror, add the export line to your~/.zshrcfile by running:bashecho 'export PATH="$HOME/.opencode/bin:$PATH"' >> ~/.zshrcError message example:
textNo config file found for zsh. You may need to manually add to PATH: export PATH=/Users/{username}/.opencode/bin:$PATHReload your shell configuration:
bashsource ~/.zshrcVerify the installation:
bashopencode --versionThe version is displayed, such as
1.15.6.Run the following command to initialize OpenCode and create the configuration file:
bashopencodeThe config file is created at
~/.config/opencode/opencode.jsonc.
Get Router connection details
- Open Router and set Qwen3.8-27B (llama.cpp) as the default chat model on Default models. Then find the model on LLM and click View connection example.
- In How to call this model, select Devices in LAN or Remote and copy the Base URL.
- Create a key on API keys for OpenCode on your computer. A VPN connection does not replace this key.
Configure the connection
- In the terminal where you run OpenCode, set the
OLARES_ROUTER_API_KEYenvironment variable to your Router-issued key. - Open
~/.config/opencode/opencode.jsoncand add the following configuration. Replace<router-base-url>with the full URL copied from Router, including/v1.
{
"$schema": "https://opencode.ai/config.json",
"model": "olares/default-chat",
"provider": {
"olares": {
"name": "Olares Router",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "<router-base-url>",
"apiKey": "{env:OLARES_ROUTER_API_KEY}"
},
"models": {
"default-chat": { "name": "Router chat" }
}
}
}
}- Save the file and restart OpenCode.
Launch OpenCode TUI
In your terminal, run
opencodeto launch the TUI:
Use the
/modelscommand to switch to Router chat.Start chatting with your self-hosted models.

First connection
The first connection might take longer to establish.
Use OpenCode in VS Code
To work with your codebase directly, open a terminal in VS Code and run opencode from your project directory.

Edit the config file
OpenCode stores its configuration in a JSON file. You can edit this file directly to manage providers, models, and tools.
Open Files and navigate to
Application/Data/opencode/.config/opencode/.Right-click
opencode.jsoncand select Rename.
Rename the file to
config.jsonso you can edit it directly in Files. OpenCode recognizes both extensions.Open
config.jsonand click edit_square to edit it.
Save the changes.
Restart OpenCode from Settings > Applications to apply the changes.
Learn more
- Manage packages: Install system-level and language-specific packages.
- Skills and plugins: Add capabilities through skills and plugins.
- Manage Olares with Olares CLI: Authenticate the Olares CLI so the agent can manage files and apps on your device.
- Orchestrate multi-agent workflows with oh-my-openagent: Enable OMO to run multi-agent collaboration in OpenCode.
- Common issues: Solutions for known problems.
- Connect AI coding assistants to up-to-date docs with Context7: Register Context7 as a remote MCP server in OpenCode.
- OpenCode official documentation