Back to Docs
Recipe

Recipe: Chat with your docs

Build a RAG-powered chat interface that answers questions from your uploaded documents using embeddings and vector search.

Overview

This recipe walks through connecting Meridian to a vector database, chunking uploaded PDFs and markdown files, generating embeddings, and streaming answers back to the user with source citations.

Prerequisites

  • Meridian project with API key
  • Pinecone or Qdrant vector database
  • Node.js 18+ runtime

Steps

  1. Ingest documents

    Use the Meridian upload endpoint to accept PDFs. Chunk with a 512-token sliding window and store embeddings in your vector DB.

  2. Build the chat route

    Create an API route that accepts a user query, retrieves the top 5 relevant chunks via cosine similarity, and constructs a prompt with context.

  3. Stream the response

    Call Meridian chat completions with streaming enabled. Pipe tokens to the client and render citations as inline footnotes.

Next steps

Add hybrid search by combining keyword BM25 with vector results. Explore the embeddings guide for advanced chunking strategies.

Need help? Join the Meridian Discord or open a ticket on GitHub Discussions.