Deploy agentgateway LLM + MCP Gateway with UI Login

agentgateway LLM and MCP gateway with a login-protected admin UI

Deploy agentgateway LLM + MCP Gateway with UI Login

Just deployed

Just deployed

Deploy and Host agentgateway on Railway

agentgateway is an open source proxy for AI traffic, written in Rust. It puts one endpoint in front of LLM providers (OpenAI compatible API), MCP servers and agent to agent traffic, with a web UI for models, API keys, budgets, guardrails, policies and request logs.

About Hosting agentgateway

This template runs the official ghcr.io/agentgateway/agentgateway:v1.7.0 image with a Railway volume at /config, where agentgateway keeps a SQLite database with everything you configure in the UI plus request logs. The official image has no shell and by default serves its UI without any login, so the template adds a small Caddy service in front. Caddy is the only public service: it asks for a username and password on the UI and passes API traffic straight through. The gateway itself stays on the private network. API keys are on from the first boot: the LLM and MCP endpoints refuse requests without the generated key. The UI password, the API key and an internal proxy token are generated for you.

Common Use Cases

  • Unified LLM API: one OpenAI compatible base URL for OpenAI, Anthropic, Gemini, Bedrock, Azure, Ollama and more
  • MCP gateway: multiplex several remote MCP servers behind one authenticated /mcp endpoint
  • API keys and budgets: per app or per team keys with spend limits and model allow lists
  • Guardrails and policies: prompt guards, rate limits, authorization rules, header and body transformations
  • Observability: request logs and cost analytics in the UI, Prometheus metrics, OpenTelemetry export
  • Private gateway for other Railway services: keep provider keys off your app containers

Dependencies for agentgateway Hosting

  • Railway volume at /config (included)
  • Caddy login gateway (included)
  • Provider API keys: optional at boot, add providers and models in the UI
  • No database service required: SQLite is the upstream default. Postgres is an optional alternative

Deployment Dependencies

Implementation Details

What is included:

ServiceImagePublicRole
agentgatewayghcr.io/agentgateway/agentgateway:v1.7.0NoUI, LLM API, MCP and routes on port 4000, SQLite on the volume
Caddycaddy:2.11-alpineYesLogin prompt on the UI paths, pass through for the rest

Key variables:

# agentgateway
PORT=15021
AGENTGATEWAY_API_KEY=agw_sk_${{secret(40)}}
UI_PROXY_TOKEN=${{secret(48)}}
RAILWAY_RUN_UID=0

# Caddy
PORT=8080
UI_USERNAME=admin
UI_PASSWORD=${{secret(24)}}
UI_PROXY_TOKEN=${{agentgateway.UI_PROXY_TOKEN}}
UPSTREAM=${{agentgateway.RAILWAY_PRIVATE_DOMAIN}}:4000

The gateway receives its baseline configuration inline in the start command and stores everything you change in the UI in the database on the volume, so your setup survives redeploys.

First steps after deploy

  1. Open the Caddy service domain and sign in with UI_USERNAME (admin) and the generated UI_PASSWORD from the Caddy service variables. Anonymous visitors get a 401.
  2. Add a provider and a model in the UI. Optionally set OPENAI_API_KEY on the agentgateway service and enter $OPENAI_API_KEY in the key field so the key is not stored in the database.
  3. Call https:///v1/chat/completions with Authorization: Bearer . Requests without a key are refused, so nobody who finds the URL can spend your provider credits.
  4. Add remote MCP servers under MCP and connect clients to https:///mcp with the same key.

Good to know: custom HTTP routes you create under Traffic are open unless you add an auth policy to them. stdio MCP servers are not supported by the official image, use remote ones. Keep one replica, since SQLite and Railway volumes are single instance.

Why Deploy agentgateway 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 agentgateway on Railway, you get a pinned, health checked AI gateway with a login protected UI, generated secrets, persistent storage, managed SSL, and private networking to the rest of your Railway project.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
Weaviate
Vector database with hybrid search and an API key-protected API

GitHub Locker
1
View Template
Möbius Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1