Deploy agentgateway LLM + MCP Gateway with UI Login
agentgateway LLM and MCP gateway with a login-protected admin UI
Caddy
Just deployed
agentgateway
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
/mcpendpoint - 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
- agentgateway documentation
- Docker install guide
- Configuration reference
- agentgateway GitHub repository
Implementation Details
What is included:
| Service | Image | Public | Role |
|---|---|---|---|
| agentgateway | ghcr.io/agentgateway/agentgateway:v1.7.0 | No | UI, LLM API, MCP and routes on port 4000, SQLite on the volume |
| Caddy | caddy:2.11-alpine | Yes | Login 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
- Open the Caddy service domain and sign in with
UI_USERNAME(admin) and the generatedUI_PASSWORDfrom the Caddy service variables. Anonymous visitors get a 401. - Add a provider and a model in the UI. Optionally set
OPENAI_API_KEYon the agentgateway service and enter$OPENAI_API_KEYin the key field so the key is not stored in the database. - Call
https:///v1/chat/completionswithAuthorization: Bearer. Requests without a key are refused, so nobody who finds the URL can spend your provider credits. - Add remote MCP servers under MCP and connect clients to
https:///mcpwith 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
Caddy
caddy:2.11-alpineagentgateway
ghcr.io/agentgateway/agentgateway:v1.7.0
