#113 · Primary category: Knowledge Base & RAG

rag_api

api api-rest embeddings fastapi langchain pgvector postgresql psql python rag vector vector-database

ID-based RAG FastAPI: Integration with Langchain and PostgreSQL/pgvector

Project last updated:08/15/26

GitHub Stars

888

Forks

390

Contributors

36

License

MIT

Why we included this project

The pitch here is simple: if you already keep a PostgreSQL database around, this FastAPI service lets you point retrieval at it without standing up a separate vector store. It indexes documents into pgvector embeddings, with LangChain handling the vector-store plumbing, and exposes REST routes to add, fetch, and delete documents. The distinguishing choice is that embeddings are scoped by file rather than mixed into one big corpus, so a query can be aimed at a specific document, which is exactly the shape a chat client wants; that's why it sits behind LibreChat's file attachments. The API is small enough to bend to other ID-based uses. One thing to weigh before running it multi-user: recent work tightened retrieval scope so reads and deletes are limited to an owner set resolved from the authenticated token before ranking, meaning a caller can't reach or wipe chunks outside its scope just by naming a foreign file id. It does assume a working pgvector database and, in a multi-tenant setup, an upstream caller that issues tokens with the right owner claims.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category