scrolltotop

new Get your brand recommended by ChatGPT, Perplexity & AI search engines. Discover GEO.

new We help companies keep track of engineering health with monthly reports. Start your review today.

Laravel RAG

A complete, production-ready RAG pipeline for Laravel.

Home Company Open Source Laravel RAG
The Problem

RAG Pipelines Shouldn't Require a Python Sidecar

If you work in Python, you have LangChain, LlamaIndex, Haystack, and a dozen other frameworks for building RAG pipelines. If you work in Laravel, you were on your own. The options were a Python microservice alongside your app, raw pgvector queries by hand, or a hosted solution that sends your proprietary data to yet another third-party service.

None of these felt right for the Laravel ecosystem. Laravel developers are used to a certain level of craft: migrations that read like English, Eloquent models that abstract complexity without hiding it, and facades that let you do powerful things in a single expressive call. We needed a RAG pipeline that respected all of that.

The Solution

This package provides a complete RAG pipeline that lives inside your Laravel application: embed documents as vectors, retrieve the most relevant chunks using semantic or hybrid search, and generate grounded answers with any LLM. Everything speaks Eloquent, uses Laravel's queue system, and feels native to the framework.

The fluent API makes it as simple as Rag::from(Document::class)->ask('...'). Under the hood, the package handles chunking (character, sentence, markdown, or semantic strategies), embedding via Prism PHP with automatic caching, vector storage with pgvector or SQLite vec, hybrid search with Reciprocal Rank Fusion, LLM reranking, and agentic retrieval loops for complex questions.

GitHub stars License PHP 8.2+ Laravel 11/12

Key Features

  • Fluent RAG API. Ask questions against your data with Rag::from(Model::class)->ask('...').
  • Smart chunking. Four strategies: character, sentence, markdown, and semantic splitting.
  • Hybrid search. Combine semantic similarity with full-text keyword matching via RRF.
  • LLM reranking. Retrieve broadly, then let a language model score for precision.
  • Agentic retrieval. Iterative query refinement for complex, multi-faceted questions.
  • Embedding cache. SHA-256 hashed, HMAC-signed cache reduces API costs by 60-80%.
  • Streaming. Built-in streaming support for real-time user interfaces.
  • Two vector stores. pgvector for production, SQLite vec for local development.

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x
  • PostgreSQL with pgvector (or SQLite vec for development)

Installation

composer require moneo/laravel-rag
View on GitHub
Partnership is at the core of what we do.

Unsure where to start?
Let’s figure it out together 👋

Contact Us