Deploy langserve-pgvector-rag
LangServe RAG API starter with Postgres and pgvector.
langserve
Just deployed
postgres
Just deployed
/var/lib/postgresql/data
Deploy and Host LangServe + Postgres/pgvector on Railway
Deploy a useful LangServe RAG API starter on Railway with FastAPI, Postgres, pgvector, ingestion/search endpoints, and optional OpenAI answer generation.
About Hosting LangServe + Postgres/pgvector
LangServe turns LangChain runnables into HTTP APIs. This template provides a real starter rather than a toy prompt demo: it includes document ingestion, pgvector-backed retrieval, a LangServe /rag/invoke route, API-key protection, and an optional OpenAI model call.
Why Deploy LangServe + Postgres/pgvector on Railway
Railway provides the app service, private Postgres networking, persistent pgvector storage, generated API keys, and a public HTTPS endpoint. The app is useful immediately for retrieval testing and can become a production RAG API by adding a provider key.
Common Use Cases
- RAG API starter
- Internal document retrieval service
- LangServe endpoint demo with durable storage
- OpenAI-compatible context retrieval backend
- FastAPI/LangChain starter for Railway
Dependencies for LangServe + Postgres/pgvector Hosting
The app requires Postgres with pgvector for document storage and vector search. OPENAI_API_KEY is optional for validation but should be supplied for LLM-generated answers.
Deployment Dependencies
DATABASE_URL: private Postgres connection stringAPP_API_KEY: generated bearer token for protected endpointsOPENAI_API_KEY: deployer-provided provider key for generated answersOPENAI_MODEL: chat model to use when a provider key is supplied
Template Content
langserve
python:3.12-slimPORT
APP_API_KEY
DATABASE_URL
OPENAI_MODEL
OPENAI_API_KEY
REQUIRE_API_KEY
EMBEDDING_DIMENSIONS
LANGSERVE_COLLECTION
PGVECTOR_CONNECTION_STRING
postgres
pgvector/pgvector:pg17PGDATA
POSTGRES_DB
POSTGRES_USER
POSTGRES_PASSWORD
