---
title: "Pi + Railway"
description: "Deploy with Pi on Railway. Minimal, extensible open-source coding agent in your terminal. Bring any of 15+ LLM providers."
url: https://railway.com/agents/pi
---

# Pi + Railway

Pi is Earendil's minimal coding agent harness — an open-source (MIT) CLI that reads files, writes and edits code, and runs shell commands directly in your project. It ships four core tools (read, write, edit, bash) and stays deliberately small: sub-agents, plan mode, and sandboxing are opt-in extensions rather than baked in. Pi authenticates against 15+ LLM providers (Anthropic, OpenAI, Google, and more) with mid-session model switching, and runs in interactive, print/JSON, RPC, or SDK modes. Paired with Railway, Pi deploys, sets variables, and reads logs from the terminal.

## Quick start

1. **Install Pi** — Install the Pi CLI and authenticate a provider with an API key or OAuth

   ```
   npm install -g @earendil-works/pi-coding-agent
   ```

2. **Install Railway CLI** — Install Railway CLI and authenticate

   ```
   npm install -g @railway/cli && railway login
   ```

3. **Open your project** — Run `pi` in your repo. Add an AGENTS.md so Pi picks up project-level instructions

4. **Deploy a Go API with Redis** — Pi runs the Railway CLI and deploys railway.com/template/gin with a Redis service attached

   ```
   Deploy this to Railway with a Redis cache for rate limiting
   ```

## Railway integrations

- CLI: https://docs.railway.com/reference/cli-api

## Example prompts

- "Deploy this Go API to Railway"
- "Add Redis for caching API responses"
- "Check the failing health check and fix it"
- "Set up environment variables from my .env.example file"
- "Configure the service to scale to zero when idle"
- "Add a cron service that sends daily email digests"
- "Deploy Plausible Analytics with Postgres and Clickhouse"
- "Set up a Langchain app with Postgres (pgvector) for RAG"
- "Deploy Grafana connected to my Railway metrics"
- "Create a complete auth system with Keycloak and Postgres"

## Common workflows

### Deploy from the terminal

- Ask Pi to deploy the current directory to Railway
- Pi runs `railway up` and streams the build
- Pi reports the deployment URL and status
- Iterate in the same session with follow-up prompts

### Provision a Postgres database

- Ask Pi to add Postgres to your project
- Pi runs `railway add` for the database
- Pi wires DATABASE_URL into your service variables
- Pi redeploys and confirms the connection

### Switch models mid-task

- Start a task on a fast model to scaffold
- Switch to a stronger model for the tricky logic
- Pi keeps the full session history across the switch
- Deploy the result to Railway when it passes

### Automate with an extension

- Add a Pi extension for your deploy workflow
- Expose Railway steps as reusable skills
- Run Pi in print/JSON mode from a script
- Pipe the output into your CI pipeline

## Tips for success

- Add project instructions in AGENTS.md so Pi has context
- Keep Pi minimal — add plan mode or sub-agents only if you need them
- Use print/JSON mode to script Railway deploys

## Frequently asked questions

### How do I deploy to Railway with Pi?

Ask Pi to deploy to Railway. It runs the Railway CLI (`railway up`) with its bash tool, streams the build, and reports the deployment URL — all in the same terminal session.

### Which models can I use with Pi?

Pi supports 15+ providers (Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, and more) via API key or OAuth, with mid-session model switching.

### Is Pi open source?

Yes. Pi is MIT-licensed and available on GitHub. It's a minimal harness you extend with your own skills, extensions, and themes.

## Troubleshooting

**Issue:** Railway CLI not found in the Pi session

**Solution:** Install the Railway CLI globally with `npm install -g @railway/cli` and restart your shell so `railway` is on PATH.

**Issue:** Pi can't authenticate a model provider

**Solution:** Set the provider's API key (e.g. ANTHROPIC_API_KEY or OPENAI_API_KEY) or complete OAuth, then retry.

**Issue:** Railway commands fail with permission denied

**Solution:** Run `railway login` to re-authenticate, then retry the deploy.

## Community resources

- Railway Discord: https://discord.gg/railway
- Pi on GitHub: https://github.com/earendil-works/pi

## Related agents

- [Claude Code](https://railway.com/agents/claude) — Agentic coding in your terminal. Understands your codebase, runs commands, and edits files.
- [Codex](https://railway.com/agents/codex) — Lightweight terminal agent. Reads and writes files, executes commands, and browses the web.
- [OpenCode](https://railway.com/agents/opencode) — Open-source terminal agent. Works with 75+ LLMs, TUI interface, and provider-agnostic architecture.

Open this page in a browser: https://railway.com/agents/pi
