Skip to main content
Use the reference starter repo for complete source code: runloopai/opencode-starter.

What you need

  • A Runloop API key (RUNLOOP_API_KEY)
  • One of:
    • Python 3.11+ and uv
    • Node.js 18+ and npm
  • Optional model provider keys:
    • ANTHROPIC_API_KEY
    • OPENAI_API_KEY

Environment variables

Set your Runloop API key before running any command:
You can also set provider keys if your OpenCode workflow needs them:
Instead of exporting provider keys directly, you can store them as Runloop account secrets and map them into your devbox at runtime. See Account Secrets.
The starter image is used when you start a devbox without specifying an image, and as the default base when you build a blueprint without providing Dockerfile content. It includes:
  • Core tools: jq, sudo
  • Extras: dnsutils, iputils-ping, less, vim, rsync, gh
  • Python stack: Python 3.12, pip, uv
  • Node stack: Node 22.15.0, npm, Yarn 1.22.22 via corepack

Setup

Clone the reference implementation:

Create a blueprint with OpenCode

This creates a reusable opencode blueprint with OpenCode preinstalled.

Create a devbox with OpenCode

Each command creates a devbox, starts opencode web, enables a tunnel, and prints the OpenCode URL.

Optional: create devbox without blueprint (manual install)

Use this when you want zero upfront setup:
Manual mode is slower because OpenCode is installed in a fresh devbox each run.

How the integration works internally

Each run follows this flow:
  1. Create a devbox (from blueprint or fresh)
  2. Install OpenCode (manual mode only)
  3. Write OpenCode config in the devbox
  4. Start OpenCode on 0.0.0.0:3000
  5. Create a Runloop tunnel and print the URL
This makes local setup simple while keeping execution remote and sandboxed.

OpenCode Dockerfile

Use this Dockerfile when creating the blueprint:

OpenCode config

Use this OpenCode config payload:

Write config into the devbox filesystem

The starter writes config to /home/user/.config/opencode/opencode.json before starting OpenCode:

Snippets

Creating a blueprint with OpenCode

Creating a devbox with OpenCode

Common issues

  • Missing API key errors
    • Confirm RUNLOOP_API_KEY is set in your shell before running commands.
  • Provider/model errors
    • Set ANTHROPIC_API_KEY or OPENAI_API_KEY based on the model you are using.
  • Slow startup
    • Use blueprint mode (create-blueprint once, then run) instead of --manual.

Next steps