Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Build a private RAG chatbot on your own documents

Turn PDFs into text with Docling, embed them, store them in Qdrant and answer questions with vLLM, all on rented GPUs you control, with real commands.

Published November 26, 20265 min read

A chatbot that answers from your own files uses a pattern called RAG (retrieval-augmented generation). You split your documents into passages, turn each passage into an embedding (a list of numbers that describes its meaning), and keep them in a vector database. When someone asks a question, you embed the question, fetch the closest passages and give them to a language model together with the question. The model answers from those passages instead of from memory. This guide builds that pipeline from four templates on rented servers, so your documents never go to a third-party AI service. It is a working skeleton, not a finished product: you will still tune the passage size, the prompt and the model for your documents.

What you need

  • An Apidly account with some credit, and a terminal with curl and Python 3.
  • A few PDFs or Word files you may use.
  • No SSH key: each template has an address and an API key on its Connect tab.

The four parts

Part Template Needs a GPU?
Documents to text Docling document conversion API Yes, 4 GB of VRAM at least
Text to embeddings Embeddings and reranking server (Infinity) Yes, 4 GB at least (8 GB recommended)
Memory Qdrant vector database No, the cheapest configuration is right
Answers vLLM (OpenAI-compatible) Yes, 16 GB at least for the default model

You do not need all four running at once. Convert and embed first, stop those two servers, and keep only Qdrant and the model server for the time people ask questions. Billing is by the second while a server runs, plus its disk while it exists; see billing by the second, explained and the pricing page for current prices. The review step of every deployment shows the price per hour before you start.

Step 1: Start the servers

Start each template from Deploy (the templates page lists them) and leave the key variable empty: the platform creates a key per server. Open each server's Connect tab and note the App address and the API key. Below they appear as DOCLING_ADDRESS, EMBED_ADDRESS, QDRANT_ADDRESS and LLM_ADDRESS; every server has its own key, so use the matching one.

For the model server, the default Qwen/Qwen2.5-1.5B-Instruct is enough to test the pipeline. For answers worth reading, set the MODEL variable to a larger instruction-tuned model that fits your GPU. How much VRAM do you need? and Run an open LLM with vLLM cover the choice. Check the model's licence on its Hugging Face page first.

Step 2: Documents to text

Docling keeps headings and tables and reads scans with OCR. Upload a file and save the Markdown:

curl -X POST http://DOCLING_ADDRESS/v1/convert/file \
  -H "Authorization: Bearer DOCLING_KEY" \
  -F "files=@report.pdf" | jq -r .document.md_content > report.md

Do this for each document. The Docling tutorial has the details, including converting from a link. Scanned pages go through OCR and take longest.

Step 3: Split, embed and store

The embeddings server answers the way the OpenAI embeddings API does. The default model, BAAI/bge-small-en-v1.5, produces vectors of 384 numbers and is built for English; for other languages set EMBEDDING_MODEL to a multilingual model. Whatever model you use, the Qdrant collection must be created with the same vector size, and you must use the same model for documents and questions.

Save this as index.py and run pip install requests first. It cuts each Markdown file into passages of about 1,000 characters, embeds them in batches and stores them:

import glob, requests

EMBED = "http://EMBED_ADDRESS"
QDRANT = "http://QDRANT_ADDRESS"
EMBED_KEY = "KEY_OF_EMBEDDINGS_SERVER"
QDRANT_KEY = "KEY_OF_QDRANT"
MODEL = "BAAI/bge-small-en-v1.5"

def embed(texts):
    r = requests.post(f"{EMBED}/embeddings",
        headers={"Authorization": f"Bearer {EMBED_KEY}"},
        json={"model": MODEL, "input": texts})
    r.raise_for_status()
    return [d["embedding"] for d in r.json()["data"]]

def chunks(text, size=1000):
    cur = ""
    for p in text.split("\n\n"):
        if len(cur) + len(p) > size and cur:
            yield cur.strip()
            cur = ""
        cur += p + "\n\n"
    if cur.strip():
        yield cur.strip()

if __name__ == "__main__":
    h = {"api-key": QDRANT_KEY}
    requests.put(f"{QDRANT}/collections/docs", headers=h,
        json={"vectors": {"size": 384, "distance": "Cosine"}}).raise_for_status()

    pid = 0
    for path in glob.glob("*.md"):
        parts = list(chunks(open(path).read()))
        for i in range(0, len(parts), 32):
            batch = parts[i:i + 32]
            points = [{"id": pid + n, "vector": v,
                       "payload": {"source": path, "text": t}}
                      for n, (t, v) in enumerate(zip(batch, embed(batch)))]
            pid += len(batch)
            requests.put(f"{QDRANT}/collections/docs/points?wait=true",
                headers=h, json={"points": points}).raise_for_status()
    print("stored", pid, "passages")

The addresses use plain http; see the warning below. If the first embedding call fails, the server may still be loading its model: wait a minute and try again.

Step 4: Ask a question

Embed the question, fetch the closest passages, and send them to the model through its OpenAI-compatible endpoint. Save this as ask.py next to index.py:

import requests
from index import embed, QDRANT, QDRANT_KEY

q = "What does the report say about delivery times?"

hits = requests.post(f"{QDRANT}/collections/docs/points/query",
    headers={"api-key": QDRANT_KEY},
    json={"query": embed([q])[0], "limit": 4, "with_payload": True}
).json()["result"]["points"]

context = "\n\n".join(f"[{h['payload']['source']}]\n{h['payload']['text']}" for h in hits)

r = requests.post("http://LLM_ADDRESS/v1/chat/completions",
    headers={"Authorization": "Bearer KEY_OF_VLLM"},
    json={"model": "Qwen/Qwen2.5-1.5B-Instruct",
          "messages": [
            {"role": "system", "content": "Answer only from the context. If the answer is not there, say you do not know."},
            {"role": "user", "content": f"Context:\n{context}\n\nQuestion: {q}"}]})
print(r.json()["choices"][0]["message"]["content"])

The model value must be the name you set in MODEL. Wrap the script in your own small web page, or point a chat front end at the same endpoint; private AI chat with Open WebUI shows one.

Honest limits

  • Retrieval decides quality. If the right passage is not among the four, the model cannot use it. Try other passage sizes, more hits, or a reranking model; the embeddings template can serve rerankers too.
  • Small models make things up. The system prompt asks for "I do not know", but a small model follows it unevenly. Show the sources next to every answer so people can check.
  • Tables and scans can still come out imperfect. Read a few converted files before you index hundreds.
  • This skeleton has no sign-in, no per-user access and no updating of changed files. Build those before real users depend on it.

Keep it private

The templates serve plain http behind a key. Anyone with an address and its key can use that server, and your documents travel unencrypted between your computer and the servers. Do not share the keys, and do not index data that needs stronger protection unless you add encryption in front.

Stop what you are not using

Stop ends the compute charge and keeps the disk, which is still billed, so your Qdrant data survives. Destroy ends every charge and deletes the disk. An address can change after a start; copy it again from the Connect tab. See Start, stop and restart, and the single-server versions of this guide: Qdrant, Docling and a model API with vLLM.

Try what this guide shows

Start one of these templates on a rented GPU server. You see the price per hour before you start, and you pay by the second.

Try it on a real GPU server

Create a free account and add a balance from $10. Servers are billed by the second, and the review step shows the price per hour before you request one.

Related guides