Deploy LangServe RAG API + pgvector
Deploy and Host with Railway
langserve
Just deployed
postgres
Just deployed
/var/lib/postgresql/data
Deploy and Host LangServe RAG API + pgvector on Railway
Run a production-shaped LangServe/FastAPI starter with Postgres, pgvector, health checks, ingest/search routes, and API-key protection.
About Hosting LangServe RAG API + pgvector on Railway
langserve: public FastAPI/LangServe servicepostgres: private Postgres database with pgvector/health,/ingest,/search, and/rag/invokeendpoints- Generated API key for protected write/invoke routes
- No bundled model provider key
Why Deploy LangServe RAG API + pgvector on Railway
The published template deploy test created langserve and postgres; both reached SUCCESS; /health, /ingest, and /rag/invoke returned HTTP 200; and vector search still found the ingested document after restarting langserve.
This is a useful RAG API starter, not a novelty prompt demo.
Common Use Cases
- RAG API prototypes
- Private document search starters
- LangServe evaluation environments
- pgvector integration tests
- AI backend starter services
Dependencies for LangServe RAG API + pgvector Hosting
The app requires Postgres with pgvector for document storage and vector search. Model provider keys are intentionally not bundled, and should be supplied by the deployer when generated answers are needed.
Deployment Dependencies
DATABASE_URL: private Postgres connection stringAPP_API_KEY: generated bearer token for protected endpointsOPENAI_API_KEY: optional deployer-provided provider keyOPENAI_MODEL: chat model to use when a provider key is supplied
After Deploy
- Set the model provider key your app needs.
- Call
/health. - Ingest a small test document.
- Call
/searchor/rag/invokewith the generated API key.
Support Checklist
If a deploy fails, include langserve and postgres deployment IDs, the /health response, and logs mentioning pgvector, database setup, or API key validation.
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
