---
title: "Deploy pi"
description: "Run the Pi AI coding agent on Railway — browser terminal or SSH"
category: "AI/ML"
url: https://railway.com/deploy/pi
---

# Deploy pi

Run the Pi AI coding agent on Railway — browser terminal or SSH

**[Deploy pi on Railway](https://railway.com/template/pi)**

- **Creator:** Mark Chen's Projects
- **Category:** AI/ML
- **Total deploys:** 11

## Template content

### pi

- **Source:** https://github.com/yuting1214/pi-railway
- **Public domain:** Yes

## Documentation

# Deploy and Host Pi on Railway

[Pi](https://pi.dev) is **an open-source AI coding agent** — a terminal-native assistant (think
Claude Code, but open and provider-agnostic) that reads your repo, writes and edits code, runs
commands, and opens pull requests. This template gives it a **persistent home in the cloud** you can
reach two ways: open the **Railway public URL** to use Pi in a browser terminal, or `railway ssh`
in and run `pi` from a shell. Your auth, sessions, settings, and cloned repos live on a Railway
volume, so they survive redeploys.

## About Hosting Pi

This template builds a small Node 24 image with the **Pi CLI** (`@earendil-works/pi-coding-agent`),
`ripgrep` (which Pi's search tools require), `git`, the **GitHub CLI**, and **ttyd** — a tiny server
that exposes the Pi TUI over HTTP. The container's main process is ttyd, listening on `$PORT`, so
opening the service's public URL drops you straight into Pi in your browser. Because that terminal
runs as root with your provider keys, it is always protected by HTTP basic auth (`WEB_USERNAME` /
`WEB_PASSWORD`) over Railway's HTTPS; you can also `railway ssh` in independently. A `/workspace`
volume holds your repositories and Pi's entire `~/.pi/agent` directory (auth, sessions, settings,
installed packages), and your provider API keys come from Railway variables. Railway handles the
build, restarts on failure, and persists the volume across deploys.

## Why Deploy Pi on Railway?

- **Use it from any browser** — no local CLI required; open the URL, log in, and Pi's TUI is right
  there. `railway ssh` is available too when you want a real shell.
- **Your laptop can sleep** — the agent and its session live in the cloud; reconnect anytime and
  pick up where you left off.
- **Persistent by default** — repos and Pi's auth/sessions sit on a Railway volume, so a redeploy
  never logs you out or loses your working tree.
- **Secured by default** — the web terminal is always behind basic auth over HTTPS; nothing is
  exposed without your password.
- **Provider-agnostic** — bring an Anthropic, OpenAI, Google, or OpenRouter key (or `/login` to a
  Claude/ChatGPT/Copilot subscription); switch models without rebuilding.
- **Real dev tooling included** — `git`, `ripgrep`, and the GitHub CLI ship in the image, so the
  agent can search, clone, commit, and open PRs from inside the box.

## Common Use Cases

- **A remote coding-agent workstation** you SSH into from any machine to run Pi interactively.
- **Long-running refactors or migrations** that should keep going regardless of your local machine.
- **A shared, reproducible agent environment** with pinned tooling for working across repositories.

## Dependencies for Pi Hosting

- A provider **API key** for at least one model backend — `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`,
  `GEMINI_API_KEY`, or `OPENROUTER_API_KEY` (or run `/login` after connecting).
- A **`WEB_PASSWORD`** for the browser terminal (`WEB_USERNAME` defaults to `pi`). If left unset, a
  random password is generated on boot and printed to the deploy logs.

### Deployment Dependencies

- [Pi](https://github.com/earendil-works/pi) — the open-source AI coding agent
  (`@earendil-works/pi-coding-agent` on npm).
- [ttyd](https://github.com/tsl0922/ttyd) — serves the Pi TUI in the browser over HTTP.
- [GitHub CLI](https://cli.github.com/) — bundled so the agent can manage issues and pull requests.

### Why This Template?

It packages Pi as a one-click, persistent **remote agent box** you can drive from a browser or over
SSH, with credentials and repos that outlive every redeploy. Source and docs:
[github.com/yuting1214/pi-railway](https://github.com/yuting1214/pi-railway).


## 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/pi
