---
title: "Deploy Agent Zero | (Just Updated) Autonomous AI Agent with Web UI, Login and API Key Preset"
description: "Agent Zero: self-hosted autonomous AI agent with web UI, login and API"
category: "AI/ML"
url: https://railway.com/deploy/agent-zero-or-just-updated-autonomous-ai
---

# Deploy Agent Zero | (Just Updated) Autonomous AI Agent with Web UI, Login and API Key Preset

Agent Zero: self-hosted autonomous AI agent with web UI, login and API

**[Deploy Agent Zero | (Just Updated) Autonomous AI Agent with Web UI, Login and API Key Preset on Railway](https://railway.com/template/agent-zero-or-just-updated-autonomous-ai)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/agent-zero-or-just-updated-autonomous-ai/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** AI/ML

## Template content

### agent-zero

- **Image:** agent0ai/agent-zero:v2.15@sha256:05d6ab347bd7db4b6bd5a7d902c9965281ff852ff23f29fffcc1c8919e628bd8
- **Start command:** `/bin/sh -c 'echo IyEvYmluL3NoCiMgUmFpbHdheSBib290IGZvciBBZ2VudCBaZXJvIChhZ2VudDBhaS9hZ2VudC16ZXJvKS4gUnVucyBhcyByb290LCBsaWtlIHRoZSBpbWFnZSdzIG93biBpbml0LgojCiMgVHdvIHRoaW5ncyBpbiB0aGUgaW1hZ2UgZG8gbm90IGZpdCBSYWlsd2F5LCBhbmQgYm90aCBhcmUgZml4ZWQgaGVyZSBiZWNhdXNlIGEgdGVtcGxhdGUgdmFyaWFibGUKIyBjYW5ub3QgY2FycnkgYSBsaXRlcmFsIChhIGxpdGVyYWwgZGVmYXVsdCBwdWJsaXNoZXMgYXMgYSBibGFuayByZXF1aXJlZCBmaWVsZCk6CiMKIyAxLiBUaGUgVUkgcG9ydCBpcyBoYXJkY29kZWQuIC9leGUvc2VsZl91cGRhdGVfbWFuYWdlci5weSBsYXVuY2hlcyBgcnVuX3VpLnB5IC0tcG9ydD04MGAsIGFuZAojICAgIFdFQl9VSV9QT1JUIGlzIGlnbm9yZWQgb24gdGhhdCBwYXRoLiBSYWl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FTEZfVVBEQVRFX0hFQUxUSF9VUkw9Imh0dHA6Ly8xMjcuMC4wLjE6JHtQT1JUfS9hcGkvaGVhbHRoIgpleGVjIC9leGUvaW5pdGlhbGl6ZS5zaCAiJHtCUkFOQ0g6LW1haW59Igo= | base64 -d > /tmp/boot.sh; exec /bin/sh /tmp/boot.sh'`
- **Health check:** /api/health
- **Public domain:** Yes

## Documentation

# Deploy and Host Agent Zero on Railway

**Built for an LLM agent to deploy and use.** There is no setup form and nothing to fill in: the login secret and the API-key seed are generated at deploy time, and the contract below lists every address, variable name and one script that proves the login and the API key work.

Agent Zero is an open source, general purpose AI agent framework. It runs a multi-agent system in its own Linux container: it writes and executes code, browses the web, keeps persistent memory and can create tools as it works. You drive it from a web UI or from its HTTP API.

## About Hosting Agent Zero

This template runs one service: the official `agent0ai/agent-zero` v2.15 image, pinned by digest, with a volume on `/a0/usr` that holds memory, knowledge, projects, uploads, scheduler tasks and settings. The image hardcodes its UI port to 80; the start command moves it to Railway's injected `PORT` so the healthcheck and the public domain reach it.

The UI is behind a login. The user name is `admin` and the secret is `AUTH_PASSWORD`, generated per deploy and stable across redeploys. The API key for the external API is derived from three values you already have: `A0_PERSISTENT_RUNTIME_ID`, the user name and `AUTH_PASSWORD`. If you change the login secret inside the UI, the new value is stored on the volume and wins over the variable, and the key changes with it (Settings, External Services shows the current key).

Agent Zero needs a language model before it can answer. Add the provider key as a variable on the `agent-zero` service, for example `API_KEY_OPENROUTER`, `API_KEY_ANTHROPIC` or `API_KEY_OPENAI`, then choose the model under Settings. Until then the UI, login, API authentication and health all work, and a chat request returns the provider's authentication error.

### Agent contract

- Public URL: `A0_PUBLIC_URL` (`https://` plus the service's `RAILWAY_PUBLIC_DOMAIN`). The web UI is at `/`.
- Private URL: `http://agent-zero.railway.internal:8080`, exposed as `A0_PRIVATE_URL`.
- Credentials: `AUTH_PASSWORD` (UI login secret, user name `admin`) and `A0_PERSISTENT_RUNTIME_ID` (seed for the API key).
- Auth: the UI needs the login form (`POST /login` with `username` and `password` fields). The external API under `/api/api_*` needs the header `X-API-KEY`, whose value is the first 16 characters of the URL-safe base64 of `sha256("RUNTIME_ID:admin:PASSWORD")`, with `RUNTIME_ID` the value of `A0_PERSISTENT_RUNTIME_ID` and `PASSWORD` the value of `AUTH_PASSWORD`, without padding; the script below computes it.
- Health: `GET /api/health` returns 200 without credentials.
- API: `POST /api/api_message` (send a task, returns the reply and a `context_id`), `GET /api/api_log_get`, `POST /api/api_reset_chat`, `POST /api/api_terminate_chat`, `GET /api/api_files_get`.

```bash
# run with A0_PUBLIC_URL, AUTH_PASSWORD and A0_PERSISTENT_RUNTIME_ID set
KEY=$(printf '%s' "$A0_PERSISTENT_RUNTIME_ID:admin:$AUTH_PASSWORD" | openssl dgst -sha256 -binary | base64 | tr '+/' '-_' | tr -d '=' | cut -c1-16)
curl -s -o /dev/null -w "health: %{http_code}\n" "$A0_PUBLIC_URL/api/health"
curl -s -o /dev/null -w "ui without login: %{http_code}\n" "$A0_PUBLIC_URL/"
curl -s -o /dev/null -w "login: %{http_code}\n" -X POST "$A0_PUBLIC_URL/login" --data-urlencode "username=admin" --data-urlencode "password=$AUTH_PASSWORD"
curl -s -o /dev/null -w "api with wrong key: %{http_code}\n" -H "X-API-KEY: wrong" "$A0_PUBLIC_URL/api/api_log_get?context_id=x"
curl -s -o /dev/null -w "api with key: %{http_code}\n" -H "X-API-KEY: $KEY" "$A0_PUBLIC_URL/api/api_log_get?context_id=x"
```

A fresh deploy prints `health: 200`, `ui without login: 302`, `login: 302`, `api with wrong key: 401` and `api with key: 404` (the key was accepted; the 404 only says that chat context `x` does not exist). To run a task, add a model provider key as described above, then `POST /api/api_message` with the same header and a JSON body such as `{"message": "list the files in /a0/usr"}`.

## Why Deploy Agent Zero on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Agent Zero on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Agent-ready** - generated login secret, API-key seed, contract block and one working script; no setup form.
- **Login on from the first request** - the UI is never public and unauthenticated.
- **State survives redeploys** - memory, knowledge, projects and settings live on a volume.
- **A working port** - the image's hardcoded port 80 is moved to Railway's injected port, so the healthcheck passes.
- **Always on** - the agent keeps its scheduled tasks running while you are away.

## Common Use Cases

- **A coding and ops agent you can reach from anywhere** - give it a task from the browser or over the API and read the result later.
- **An agent that other agents call** - one service posts a task to `/api/api_message` and reads back the answer.
- **Scheduled research and monitoring** - use the built-in scheduler for recurring web research or checks.

## Dependencies for Agent Zero Hosting

- One Railway volume on `/a0/usr`, created by the template.
- A language model provider key, added by you after deploy.

### Deployment Dependencies

- [Agent Zero repository](https://github.com/agent0ai/agent-zero)
- [Official image](https://hub.docker.com/r/agent0ai/agent-zero)
- [Agent Zero documentation](https://github.com/agent0ai/agent-zero/tree/main/docs)

### Implementation Details

| Variable | Purpose |
| --- | --- |
| `AUTH_PASSWORD` | Login secret for the web UI (user `admin`) and part of the API key, generated per deploy. |
| `A0_PERSISTENT_RUNTIME_ID` | Per-deploy seed for the API key, written to the volume at boot. |
| `A0_PUBLIC_URL` | HTTPS address for clients outside Railway. |
| `A0_PRIVATE_URL` | Address on the private network, for services in the same project. |

The start command sets the user name to `admin`, moves the UI to Railway's injected `PORT` and then runs the image's own init. The container also runs an SSH server and a local SearXNG search engine; neither is exposed.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/agent-zero-or-just-updated-autonomous-ai
