---
title: "Deploy PrivateGPT Docs Q&A + Auth Gateway"
description: "Private docs Q&A API with RAG and citations, behind a login gateway"
category: "AI/ML"
url: https://railway.com/deploy/privategpt-docs-qanda-auth-gateway
---

# Deploy PrivateGPT Docs Q&A + Auth Gateway

Private docs Q&A API with RAG and citations, behind a login gateway

**[Deploy PrivateGPT Docs Q&A + Auth Gateway on Railway](https://railway.com/template/privategpt-docs-qanda-auth-gateway)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/privategpt-docs-qanda-auth-gateway/manifest.json

- **Creator:** Protemplate
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### PrivateGPT https://avatars.githubusercontent.com/u/143802295?v=4

- **Image:** zylonai/private-gpt:1.0.1
- **Start command:** `sh -c 'echo c2V0IC1lCjogIiR7UEdQVF9QUk9KRUNUX1JPT1Q6P1BHUFRfUFJPSkVDVF9ST09UIGlzIHJlcXVpcmVkfSIKOiAiJHtQR1BUX0FVVEhfVVNFUk5BTUU6P1BHUFRfQVVUSF9VU0VSTkFNRSBpcyByZXF1aXJlZH0iCjogIiR7UEdQVF9BVVRIX1BBU1NXT1JEOj9QR1BUX0FVVEhfUEFTU1dPUkQgaXMgcmVxdWlyZWR9IgpST09UPSIkUEdQVF9QUk9KRUNUX1JPT1QiCm1rZGlyIC1wICIkUk9PVC9sb2NhbF9kYXRhIgojIFVwc3RyZWFtIHNldHRpbmdzLnlhbWwgaGFyZGNvZGVzIHNlcnZlci5hdXRoLmVuYWJsZWQ6IGZhbHNlIChubyBlbnYgZXhwYW5zaW9uKSwgc28gdHVybiB0aGUgQVBJCiMgYXV0aCBvbiB0aHJvdWdoIHRoZSBhdXRvLWxvYWRlZCBzZXR0aW5ncy5vdmVycmlkZS55YW1sLiBUaGUgc2VjcmV0IGlzIHRoZSBmdWxsIEF1dGhvcml6YXRpb24KIyBoZWFkZXIsIGJ1aWx0IGZyb20gdGhlIHNhbWUgY3JlZGVudGlhbHMgYXMgdGhlIENhZGR5IGd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XhlYyBwcml2YXRlLWdwdCBzZXJ2ZSAtLWhvc3QgMC4wLjAuMAo= | base64 -d > /tmp/start.sh && exec sh /tmp/start.sh'`
- **Health check:** /health

### privategpt-gateway https://avatars.githubusercontent.com/u/143802295?v=4

- **Image:** caddy:2.11-alpine
- **Start command:** `sh -c 'echo c2V0IC1lCjogIiR7UE9SVDo/UE9SVCBpcyByZXF1aXJlZH0iCjogIiR7VUlfVVNFUk5BTUU6P1VJX1VTRVJOQU1FIGlzIHJlcXVpcmVkfSIKOiAiJHtVSV9QQVNTV09SRDo/VUlfUEFTU1dPUkQgaXMgcmVxdWlyZWR9Igo6ICIke1VQU1RSRUFNOj9VUFNUUkVBTSBpcyByZXF1aXJlZH0iCkhBU0g9IiQoY2FkZHkgaGFzaC1wYXNzd29yZCAtLXBsYWludGV4dCAiJFVJX1BBU1NXT1JEIikiCmNhdCA+IC9ldGMvY2FkZHkvQ2FkZHlmaWxlIDw8RU9GCnsKCWF1dG9faHR0cHMgb2ZmCglhZG1pbiBvZmYKCXNlcnZlcnMgewoJCXByb3RvY29scyBoMSBoMmMKCX0KfQo6JFBPUlQgewoJQGNyb3Nzc2l0ZSB7CgkJbm90IG1ldGhvZCBHRVQgSEVBRCBPUFRJT05TCgkJaGVhZGVyX3JlZ2V4cCBTZWMtRmV0Y2gtU2l0ZSBeKGNyb3NzLXNpdGV8c2FtZS1zaXRlKSQKCX0KCXJvdXRlIHsKCQlyZXNwb25kIC9nYXRld2F5LWhlYWx0aCAib2siIDIwMAoJCXJlc3BvbmQgQGNyb3Nzc2l0ZSAiQ3Jvc3Mtc2l0ZSByZXF1ZXN0IGJsb2NrZWQiIDQwMwoJCWJhc2ljX2F1dGggewoJCQkkVUlfVVNFUk5BTUUgJEhBU0gKCQl9CgkJcmVkaXIgLyAvdWkvIDMwMgoJCXJldmVyc2VfcHJveHkgJFVQU1RSRUFNCgl9Cn0KRU9GCmV4ZWMgY2FkZHkgcnVuIC0tY29uZmlnIC9ldGMvY2FkZHkvQ2FkZHlmaWxlIC0tYWRhcHRlciBjYWRkeWZpbGUK | base64 -d > /tmp/start.sh && exec sh /tmp/start.sh'`
- **Health check:** /gateway-health
- **Public domain:** Yes

## Documentation

# Deploy and Host PrivateGPT on Railway

PrivateGPT 1.0 is an open source API layer for private AI apps. It handles ingestion, retrieval with citations, agentic RAG, tools and MCP connectors, and exposes a Claude style Messages API. It also ships a workbench UI for chatting with your documents. PrivateGPT does not run models itself. It connects to any OpenAI compatible inference server: OpenAI by default, or your own Ollama, vLLM, llama.cpp or LiteLLM service.

## About Hosting PrivateGPT

This template runs PrivateGPT as a private service with its built in API auth switched on, behind a Caddy gateway that is the only public service. The gateway puts a basic auth login in front of the workbench and the API and blocks cross site write requests. The vector store (embedded Qdrant), the document store and the skills database all sit on one volume, so documents survive redeploys.

First steps after deploy:

1. Open the gateway URL. Sign in as `admin` with the `UI_PASSWORD` generated on the **privategpt-gateway** service (Variables tab). You land on the workbench at `/ui/`.
2. Upload a document, then ask questions about it. Answers include citations.
3. To use the API, send the same credentials as HTTP Basic auth to the gateway URL, for example `curl -u admin:$UI_PASSWORD https:///v1/models`. Browse the API reference at `/docs`.

## Common Use Cases

- Chat with company documents and get answers with citations, without sending files to a hosted RAG product
- Give an internal app a Messages API with retrieval, tools and MCP connectors built in
- Point the same stack at your own inference server (Ollama, vLLM, LiteLLM) when you move off OpenAI

## Dependencies for PrivateGPT Hosting

- **PrivateGPT** (`zylonai/private-gpt:1.0.1`): private only, volume at `/home/worker/app/local_data`.
- **privategpt-gateway** (`caddy:2.11-alpine`): the only public service, with the login prompt.
- An OpenAI compatible inference server and its key (OpenAI by default).

### Deployment Dependencies

- PrivateGPT: https://github.com/zylon-ai/private-gpt
- Caddy: https://caddyserver.com
- OpenAI API keys: https://platform.openai.com/api-keys

### Key Variables

| Variable | Service | Purpose |
|---|---|---|
| `OPENAI_API_KEY` | PrivateGPT | Required. Key for the inference server. Boot fails if the default model cannot be found. |
| `OPENAI_API_BASE` | PrivateGPT | Inference server URL. Defaults to `https://api.openai.com/v1`. |
| `PGPT_LLM_DEFAULT` | PrivateGPT | Default chat model (`gpt-5.4-mini`). |
| `PGPT_MODELS_EMBEDDING_NAME` / `_EMBED_DIM` | PrivateGPT | Embedding model and vector size (`text-embedding-3-small`, 1536). Set both before your first upload. |
| `UI_USERNAME` / `UI_PASSWORD` | privategpt-gateway | Login for the gateway. PrivateGPT's own API auth uses the same pair. |

Notes: anyone who has the login can run code through the built in code execution tool, read files the container can see (through ingest by URI), and reach other private services, so share it only with people you would trust with the server itself. The image is about 1.2 GB compressed; the Hobby plan or higher is recommended.

## Why Deploy PrivateGPT 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 PrivateGPT 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.


## 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/privategpt-docs-qanda-auth-gateway
