---
title: "Deploy OpenCode Web"
description: "OpenCode's web UI with a password, your projects and logins on a volume"
category: "AI/ML"
url: https://railway.com/deploy/opencode-web
---

# Deploy OpenCode Web

OpenCode's web UI with a password, your projects and logins on a volume

**[Deploy OpenCode Web on Railway](https://railway.com/template/opencode-web)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/opencode-web/manifest.json

- **Creator:** Dektion Studio
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### opencode https://raw.githubusercontent.com/anomalyco/opencode/34aa427434b054afcce7184764aa681159b5d769/packages/console/app/src/asset/brand/opencode-logo-dark-square.png

- **Source:** dektionstudio/railway-template-images
- **Public domain:** Yes

## Documentation

# Deploy and Host OpenCode Web on Railway

[OpenCode](https://github.com/anomalyco/opencode) is an open-source (MIT) AI coding agent that works with most model providers. This template runs its built-in web UI, `opencode web`, protected by OpenCode's own password setting. Everything OpenCode stores, including your projects and provider logins, lives in a home directory on a Railway volume.

I made it because the eight OpenCode templates on Railway all have health scores between 0 and 89 out of 100. This one uses OpenCode's own server and login instead of a custom wrapper, and pins the version so a deploy today and a deploy next month behave the same.

## About Hosting OpenCode Web

When the deploy finishes, open `OPENCODE_URL` from the Variables tab and log in as `opencode` with `OPENCODE_SERVER_PASSWORD`. Add a model provider either by setting `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` on the service, or by connecting one from the web UI. Clone your repositories into `~/projects`, which is where OpenCode starts.

Before publishing I tested it through the same HTTP API the web UI uses. Without the password both the UI and the API return 401. With an OpenRouter key set, a new session on `openai/gpt-4o-mini` answered with exactly the text I asked for in 2.9 seconds, using about 6,900 tokens for that one short message. After a restart the session was still there. Once started, the service settled at 245 MB of RAM, about $2.50 a month.

## Common Use Cases

- A coding agent you open from any browser, with sessions that keep running on the server
- One place for several model providers: switch between Claude and GPT models per session

## Dependencies for OpenCode Web Hosting

An API key for at least one model provider, set as a variable or connected in the UI after the deploy.

### Deployment Dependencies

- OpenCode: https://github.com/anomalyco/opencode
- OpenCode docs: https://opencode.ai/docs/web/
- The Dockerfile this template builds: https://github.com/dektionstudio/railway-template-images/tree/main/opencode

### Implementation Details

The version is `OPENCODE_VERSION` (1.18.32 when I published this). Railway passes service variables to the build, so changing it and redeploying builds that version.

Set `GIT_USER_NAME` and `GIT_USER_EMAIL` if you want the agent to commit. For private repositories, clone over HTTPS with a token, or add an SSH key to `~/.ssh` from the agent's shell.

OpenCode's agent runs shell commands in the container, and anyone who has the password can use it. Treat the password like an SSH key.

The health endpoint sits behind the password too, so the template has no Railway healthcheck. Railway restarts the service if the process exits.

## Why Deploy OpenCode Web on Railway?

The agent keeps working on the server when you close the laptop, and you reach the same sessions from any device. The home directory is on a volume, so redeploys and upgrades keep your projects and logins.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/opencode-web
