DevDuniya
May 16, 2025
The rise of Large Language Models (LLMs) like ChatGPT, Claude, Mistral, and LLaMA has changed the way we build smart apps. But if you want these AI tools to actually remember things, search through documents, or respond with your data, then you need one more ingredient: a vector database.
In this blog, we’ll cover everything you need to know to get started with LLM APIs and vector databases:
LLM (Large Language Model) is a type of AI trained on huge amounts of text to understand and generate human-like language.
Examples:
These models can:
An LLM API is a way to use these powerful models in your own apps without hosting them yourself.
Provider | API Example |
---|---|
OpenAI | https://api.openai.com/v1/chat/completions |
Anthropic | https://api.anthropic.com/v1/complete |
Ollama (local) | http://localhost:11434/api/generate |
Google Gemini | Via Google AI Studio |
POST /v1/chat/completions
{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "What is Laravel?"}
]
}
A vector database is a special kind of database that stores data in the form of vectors – numerical representations of words, sentences, or documents.
These are used for:
LLMs are stateless – they don’t remember anything between questions.
Want to make ChatGPT search your PDFs? You need to convert those PDFs to embeddings and store them in a vector DB.
+--------------+ +------------------+ +--------------+
| User Message | ----> | Embedding Model | ----> | Vector DB |
+--------------+ +------------------+ +--------------+
| |
Search for similar vectors |
| |
+------------------+ |
| Relevant Context | <-----------+
+------------------+
↓
+--------------------------+
| LLM API (ChatGPT etc) |
| + Context + User Message |
+--------------------------+
↓
AI Response to User
Let’s walk through the basic steps:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
embedding = model.encode("This is a sentence.")
import chromadb
client = chromadb.Client()
client.create_collection("docs").add(
documents=["Laravel is a PHP framework..."],
embeddings=[embedding]
)
results = client.get_nearest("What is Laravel?")
prompt = "Answer the following using this context:\n\n[context here]"
response = llm_api.generate(prompt)
Tool | Use For |
---|---|
LangChain | Full framework for chaining LLM + DB |
Ollama | Run LLMs locally |
ChromaDB | Lightweight vector database (local) |
Pinecone | Cloud vector database |
FAISS | Facebook’s open-source vector search |
pdfminer
to extract text from PDFWant a full code example? Just ask!
Concept | Explanation |
---|---|
LLM | AI model that understands/generates text |
LLM API | Lets you use LLMs in your own app |
Embedding | Convert text into vector representation |
Vector DB | Store and search these embeddings |
Semantic Search | Find text with similar meaning |
Together, they power:
✅ AI search
✅ Smart chatbots
✅ Custom ChatGPT with your own data
embedding
APILet me know if you'd like this guide with:
Would you like this blog as a Notion post, Markdown file, or HTML blog format? Let me know!