Get up and running with LiquidIndex in under 10 minutes. This guide walks you through building a complete multi-tenant RAG system that your users can immediately start using.

Prerequisites

1

Create a Project

Create a project and generate an API key in the LiquidIndex dashboard (requires card on file).
2

Install Dependencies

npm install express axios dotenv
3

Set Environment Variables

Create a .env file in your project root:
.env
PROJECT_ID=your_project_id_here
API_KEY=your_api_key_here

Build Your RAG Backend

This guide shows you how to build a Multi-Tenant system. You’ll create three simple endpoints that handle the complete RAG workflow: customer creation, file uploads, and semantic search.

1. Create a Customer

Create an endpoint to register new customers in your system. Each customer gets their own isolated data space.
lqx.js
app.post("/create-customer", async (req, res) => {
    const url = 'https://api.liquidindex.dev/customer/create'
    const response = await axios.post(url, {
        project_id: process.env.PROJECT_ID,
        name: req.body.name,
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    const customer_id = response.data.customer_id
    return res.status(200).json({ customer_id: customer_id });
});

You can view the API reference here

2. Create an Upload Session

Generate a secure upload URL where your customers can upload their documents. LiquidIndex handles all the file processing and indexing automatically.
lqx.js
app.post("/create-session", async (req, res) => {
    const { customer_id } = req.body;
    const url = 'https://api.liquidindex.dev/session/multi-tenant'
    const response = await axios.post(url, {
        project_id: process.env.PROJECT_ID,
        services: ["all"],
        customer_id: customer_id,
        success_url: "http://localhost:3000?success=true",
        cancel_url: "http://localhost:3000?cancel=true",
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    res.redirect(303, response.data.url);
});
You can view the API reference here

3. Query Customer Data

Perform semantic search across a customer’s uploaded documents. Get relevant chunks and AI-generated answers in one API call.
lqx.js
app.post("/query", async (req, res) => {
    const url = 'https://api.liquidindex.dev/query/customer'
    const { query, customer_id } = req.body;
    const response = await axios.post(url, {
        customer_id: customer_id,
        query: query,
        top_k: 5
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    return res.status(200).json(response.data);
});
You can view the API reference here

Complete Working Example

Copy and paste this complete server code to get started immediately. This gives you a fully functional RAG backend in under 50 lines of code:
app.js
require('dotenv').config();
const express = require("express");
const app = express();
const axios = require("axios");

app.use(express.json());

const ROUTE = "https://api.liquidindex.dev"

app.post("/create-customer", async (req, res) => {
    const response = await axios.post(`${ROUTE}/customer/create`, {
        project_id: process.env.PROJECT_ID,
        name: req.body.name,
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    return res.status(200).json({ customer_id: response.data.customer_id });
});


app.post("/create-session", async (req, res) => {
    const { customer_id } = req.body;
    const response = await axios.post(`${ROUTE}/session/multi-tenant`, {
        project_id: process.env.PROJECT_ID,
        services: ["all"],
        customer_id: customer_id,
        success_url: "http://localhost:3000?success=true",
        cancel_url: "http://localhost:3000?cancel=true",
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    res.redirect(303, response.data.url);
});


app.post("/query", async (req, res) => {
    const { query, customer_id } = req.body;
    const response = await axios.post(`${ROUTE}/query/customer`, {
        customer_id: customer_id,
        query: query,
        top_k: 5
    }, {
        headers: {
            Authorization: `Bearer ${process.env.API_KEY}`,
        }
    });
    return res.status(200).json(response.data);
});

app.listen(5000, () => {
  console.log("Server is running on port 5000");
});

Test Your Implementation

1

Start Your Server

node app.js
2

Create a Customer

curl -X POST http://localhost:5000/create-customer \
  -H "Content-Type: application/json" \
  -d '{"name": "Test Customer"}'
3

Create Upload Session

curl -X POST http://localhost:5000/create-session \
  -H "Content-Type: application/json" \
  -d '{"customer_id": "CUSTOMER_ID_FROM_STEP_2"}'
Visit the returned URL to upload documents.
4

Query the Data

curl -X POST http://localhost:5000/query \
  -H "Content-Type: application/json" \
  -d '{"customer_id": "CUSTOMER_ID", "query": "What is this document about?"}'

What’s Next?