Skip to content

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

  • An Olares device with sufficient disk space and memory.

  • Admin privileges to install apps from Market.

  • Additional requirements depend on how you use OpenCode:

    UsageRequirements
    Browser with a local modelQwen3.6-27B (llama.cpp) installed from Market
    Browser with OpenAIA ChatGPT Plus/Pro account or an OpenAI API key
    OpenCode CLI on your computerOllama installed on Olares with at least one model downloaded, and LarePass VPN enabled on your computer.

Run OpenCode in the browser

This option installs OpenCode as an application on your Olares device. You access it through your browser.

Install OpenCode

  1. Open Market and search for "OpenCode". Install OpenCode

  2. 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

A standalone model on Olares runs as a separate service from the client app. To connect them, the client needs the exact Model name and a Base URL that matches the API format it expects.

You can get both values from the model's console. For more details, see Connect AI apps.

In this example, OpenCode connects to Qwen3.6-27B using the OpenAI-compatible API format:

  1. Open the model app from Launchpad. Its Model Console opens automatically.

  2. Wait until Model shows READY and Engine shows RUNNING.

    Qwen3.6-27B model console

  3. Under Model, copy the Model name exactly as shown.

  4. Under Engine:

    a. Connection source: Select Apps in Olares.

    b. API format: Select OpenAI-Compatible.

    c. Copy the provided Base URL exactly as shown.

Connect to a custom provider

Add Qwen3.6-27B as a custom provider in OpenCode.

  1. In OpenCode, click settings in the bottom-left corner. Open OpenCode settings

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

  3. Enter the following details:

    • Provider ID: Enter a unique identifier, such as qwen3.6-27b.
    • Display name: Enter the name shown in the provider list, such as Qwen3.6 27B.
    • Base URL: Paste the Base URL copied from Model Console. Use it exactly as displayed.
    • Models:
      • Model ID: Enter the exact Model name copied from Model Console. In this example, it is unsloth/Qwen3.6-27B-GGUF:Q4_K_M.
      • Display Name: Enter the name shown for this model, such as Qwen3.6 27B.
  4. Click Submit to save the configuration. Your newly added provider will appear in the provider list. 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.

Create a project

To work with multiple projects, create subfolders under Home/Code first:

  1. Open Files and navigate to Home/Code/.

  2. Create a subfolder for each project. Create subfolders in Files

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

Start coding

You can now interact with OpenCode through the chat interface.

  1. Select a project to open the coding agent interface.

  2. Below the chat box, select Big Pickle to open the model selector, and select Qwen3.6 27B from the list.

  3. Type a coding task in natural language. Code generation

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

  5. Use @ to mention a file in the chat window and ask OpenCode to edit it. Mention file in chat

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 the OpenCode CLI on your computer and connects it to Ollama on Olares through LarePass VPN.

Install OpenCode CLI

  1. Install the CLI using the official installer:

    bash
    curl -fsSL https://opencode.ai/install | bash
  2. (Optional) If you encounter the No config file found for zsh error, add the export line to your ~/.zshrc file by running:

    bash
    echo 'export PATH="$HOME/.opencode/bin:$PATH"' >> ~/.zshrc

    Error message example:

    text
    No config file found for zsh. You may need to manually add to PATH:
    export PATH=/Users/{username}/.opencode/bin:$PATH
  3. Reload your shell configuration:

    bash
    source ~/.zshrc
  4. Verify the installation:

    bash
    opencode --version

    The version is displayed, such as 1.15.6.

  5. Run the following command to initialize OpenCode and create the configuration file:

    bash
    opencode

    The config file is created at ~/.config/opencode/opencode.jsonc.

Get the Ollama service endpoint

OpenCode CLI connects to the Ollama app as a service provider.

How app endpoints work

When a client connects to another Olares app, it uses that app's endpoint as the network address. If the app exposes multiple endpoints, choose the one that matches the feature or protocol the client needs.

  1. Go to Olares Settings > Applications > Ollama > Entrances.
  2. Select Ollama API, then copy the Endpoint URL.

Configure the connection

  1. Enable LarePass VPN on your computer to connect to Olares. Enable LarePass VPN on desktop

    On the same local network?

    If your computer and Olares are on the same LAN, you can skip VPN and use the .local domain instead. For details, see Use .local domain.

  2. Open the OpenCode config file at ~/.config/opencode/opencode.jsonc in a text editor. Add a custom provider with your Ollama endpoint and model. The general format is:

    json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "<provider-id>": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "<display-name>",
          "options": {
            "baseURL": "<your-endpoint>/v1"
          },
          "models": {
            "<model-id>": {
              "name": "<model-display-name>"
            }
          }
        }
      }
    }

    For example, to connect to Ollama on Olares with the Qwen3.6 27B model:

    json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "olares-ollama": {
          "name": "olares-ollama",
          "npm": "@ai-sdk/openai-compatible",
         "models": {
            "qwen3.6:27b": {
              "name": "Qwen3.6 27B"
            }
          },
          "options": {
            "baseURL": "<Ollama-Endpoint>/v1"
          }
        }
      }
    }

    Windows WSL users

    If you installed OpenCode in WSL, the config file path is ~/.local/share/opencode/config.json.

  3. Save the file.

Launch OpenCode TUI

  1. In your terminal, run opencode to launch the TUI: Launch OpenCode TUI in terminal

  2. Use the /models command to switch to Qwen3.6 27B. Select model in terminal TUI

  3. Start chatting with your self-hosted models. Chat in terminal TUI

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.

OpenCode in VS Code

Edit the config file

OpenCode stores its configuration in a JSON file. You can edit this file directly to manage providers, models, and tools.

  1. Open Files and navigate to Application/Data/opencode/.config/opencode/.

  2. Right-click opencode.jsonc and select Rename. Rename config file

  3. Rename the file to config.json so you can edit it directly in Files. OpenCode recognizes both extensions.

  4. Open config.json and click edit_square to edit it. Edit config file

  5. Save the changes.

  6. Restart OpenCode from Settings > Applications to apply the changes.

Learn more