DEV Community

Alex Spinov
Alex Spinov

Posted on

LlamaIndex Has a Free API — Connect LLMs to Your Data in Minutes

LlamaIndex: The Data Framework for LLM Applications

LlamaIndex (formerly GPT Index) is the leading framework for building RAG (Retrieval-Augmented Generation) applications. Connect any data source to any LLM — PDFs, databases, APIs, Notion, Slack, and 160+ connectors.

Why LlamaIndex

  • 160+ data connectors — ingest from anywhere
  • Advanced RAG — not just basic vector search
  • Agents — LLMs that query your data autonomously
  • Production-ready — async, streaming, caching
  • Provider-agnostic — OpenAI, Anthropic, Ollama, etc.

The Free API (Python)

Simple RAG in 5 Lines

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

# Load documents from a directory
documents = SimpleDirectoryReader("./data").load_data()

# Create index (embeds and stores)
index = VectorStoreIndex.from_documents(documents)

# Query
query_engine = index.as_query_engine()
response = query_engine.query("What is our refund policy?")
print(response)
Enter fullscreen mode Exit fullscreen mode

Advanced RAG with Reranking

from llama_index.core import VectorStoreIndex
from llama_index.core.postprocessor import SentenceTransformerRerank
from llama_index.core.retrievers import VectorIndexRetriever
from llama_index.core.query_engine import RetrieverQueryEngine

retriever = VectorIndexRetriever(index=index, similarity_top_k=10)
reranker = SentenceTransformerRerank(top_n=3)

query_engine = RetrieverQueryEngine(
    retriever=retriever,
    node_postprocessors=[reranker]
)

response = query_engine.query("Explain the pricing model")
Enter fullscreen mode Exit fullscreen mode

Chat Engine with Memory

chat_engine = index.as_chat_engine(chat_mode="context")

response = chat_engine.chat("What products do we sell?")
print(response)

response = chat_engine.chat("Which one is the most popular?")
print(response)  # Remembers context from previous question
Enter fullscreen mode Exit fullscreen mode

Data Connectors

from llama_index.readers.notion import NotionPageReader
from llama_index.readers.slack import SlackReader
from llama_index.readers.database import DatabaseReader

# From Notion
notion_docs = NotionPageReader(integration_token="...").load_data(page_ids=["..."])

# From database
db_docs = DatabaseReader(uri="postgresql://...").load_data(query="SELECT * FROM docs")

# Combine all sources
all_docs = notion_docs + db_docs
index = VectorStoreIndex.from_documents(all_docs)
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

A customer support team was answering the same questions repeatedly. LlamaIndex RAG pipeline: index 5,000 support tickets + product docs -> chatbot answers 80% of tier-1 questions automatically. Support team focuses on complex issues only.

Quick Start

pip install llama-index
python -c "from llama_index.core import VectorStoreIndex; print(Ready!)"
Enter fullscreen mode Exit fullscreen mode

Resources


Need data ingestion for your AI apps? Check out my scraping tools on Apify or email spinov001@gmail.com for custom RAG pipelines.

Top comments (0)