D Dev Duniya
Back to Journal
4 min read

Understanding LLM APIs & Vector Databases: A Beginner's Guide to Building AI-Powered Apps

Ashish Yadav

Ashish Yadav

Published on Dev Duniya
Keep exploring
Compare the details before you buy.
Understanding LLM APIs & Vector Databases: A Beginner's Guide to Building AI-Powered Apps

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:


📚 Table of Contents

  1. What is an LLM?
  2. What is an LLM API?
  3. What is a Vector Database?
  4. Why Do LLMs Need Vector Databases?
  5. How They Work Together (Flow Diagram)
  6. Popular LLM APIs & Vector DBs
  7. Build a Simple AI App (Concept)
  8. Tools to Use: LangChain, Ollama, ChromaDB, Pinecone
  9. Summary & What to Learn Next

🤖 What is an LLM?

LLM (Large Language Model) is a type of AI trained on huge amounts of text to understand and generate human-like language.

Examples:

  • GPT-4 (OpenAI)
  • Claude (Anthropic)
  • LLaMA (Meta)
  • Mistral
  • Gemini (Google)

These models can:

  • Chat like a human
  • Answer questions
  • Summarize documents
  • Generate code
  • Translate languages

🌐 What is an LLM API?

An LLM API is a way to use these powerful models in your own apps without hosting them yourself.

Examples of LLM APIs:

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

Example Request (OpenAI):

POST /v1/chat/completions
{
  "model": "gpt-4",
  "messages": [
    {"role": "user", "content": "What is Laravel?"}
  ]
}

📦 What is a Vector Database?

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:

  • Semantic search (search by meaning, not keywords)
  • Context storage (store memory for LLMs)
  • Recommendations
  • Question answering over your own data

Common Vector DBs:

  • Pinecone
  • ChromaDB
  • Weaviate
  • Milvus
  • Qdrant
  • FAISS (local, offline)

🧠 Why Do LLMs Need Vector Databases?

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.

Use Cases:

  • AI chatbots with your company docs
  • Personal AI assistants that remember
  • AI that answers questions from textbooks or legal docs

🔄 How LLM + Vector DB Work Together (Diagram)

      +--------------+       +------------------+       +--------------+
      | User Message | ----> | Embedding Model  | ----> | Vector DB    |
      +--------------+       +------------------+       +--------------+
                                      |                          |
                           Search for similar vectors            |
                                      |                          |
                                +------------------+             |
                                | Relevant Context | <-----------+
                                +------------------+
                                         ↓
                           +--------------------------+
                           |   LLM API (ChatGPT etc)  |
                           | + Context + User Message |
                           +--------------------------+
                                         ↓
                                AI Response to User

🛠️ Step-by-Step: How to Build an AI App

Let’s walk through the basic steps:

1. Choose an LLM

  • Use OpenAI, Ollama (local), or Claude.

2. Load Your Data

  • Load files (PDFs, docs, etc.)

3. Split and Embed

  • Break data into chunks.
  • Convert chunks into vectors using an embedding model (e.g., OpenAI, HuggingFace, BGE).
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
embedding = model.encode("This is a sentence.")

4. Store in a Vector DB

import chromadb
client = chromadb.Client()
client.create_collection("docs").add(
    documents=["Laravel is a PHP framework..."],
    embeddings=[embedding]
)

5. Accept User Query

6. Convert Query to Vector

7. Search Similar Chunks

results = client.get_nearest("What is Laravel?")

8. Pass Results + User Prompt to LLM

prompt = "Answer the following using this context:\n\n[context here]"
response = llm_api.generate(prompt)

⚙️ Popular Tools for LLMs & Vector DBs

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

🧪 Example Project: Chat with Your PDF

  • Use pdfminer to extract text from PDF
  • Chunk it and embed with HuggingFace or OpenAI
  • Store in ChromaDB
  • Search + inject results into GPT-3.5 prompt

Want a full code example? Just ask!


📌 Summary

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


🎯 What To Learn Next?

  • Learn LangChain basics
  • Explore Pinecone, Qdrant, or ChromaDB
  • Build a “Chat with Your Docs” app
  • Try Ollama for local LLMs
  • Explore OpenAI's embedding API

🙋 Questions or Want a Code Tutorial?

Let me know if you'd like this guide with:

  • Example Python code
  • LangChain integration
  • Full working app (Flask / Laravel + LLM)

Would you like this blog as a Notion post, Markdown file, or HTML blog format? Let me know!

Keep reading

12 latest articles

The newest stories from Dev Duniya, excluding the article you are reading.

All articles →

From the product catalog

Explore device specifications

Specification cards update automatically from published catalog products, grouped by brand.

Apple specifications

Explore Apple devices →
Apple Apple iPhone Duo
Apple Apple iPhone Duo specifications

Apple iPhone Duo is a new-generation iPhone model focused on a sleek design, powerful performance, and everyday usability. Explore iPhone Duo specifications, features, display, cameras, battery, and expected price in the USA. Get the latest information about Apple iPhone Duo and its key features. Compare iPhone Duo with other popular Apple iPhone models.

Size (inches)
Open: 4.64 x 6.48 x 0.21 Closed: 4.64 x 3.31 x 0.44
Weight (ounces)
8.96
Display size (inches)
Inner: 7.6-inch (diagonal) all-screen OLED folding display Outer: 5.4-inch (diagonal) all-screen OLED display
Resolution (pixels)
Inner: 1878-by-2670-pixel resolution at 430 ppi Outer: 1398-by-2034-pixel resolution at 460 ppi
See all specifications →
Apple Apple iPhone 18 Pro Max
Apple Apple iPhone 18 Pro Max specifications

Apple iPhone 18 Pro Max is a high-end flagship smartphone designed for powerful performance and advanced photography. Explore iPhone 18 Pro Max specifications, features, display, cameras, battery, and expected price in the USA. Discover the latest upgrades and key features of Apple’s largest Pro iPhone. Compare iPhone 18 Pro Max with other premium flagship smartphones.

Size (inches)
6.43 x 3.07 x 0.34
Weight (ounces)
8.78
Display size (inches)
6.9-inch (diagonal) all-screen OLED display
Resolution (pixels)
2868-by-1320-pixel resolution at 460 ppi
See all specifications →
Apple Apple iPhone 18 Pro
Apple Apple iPhone 18 Pro specifications

Apple iPhone 18 Pro is a premium flagship smartphone with advanced performance and an upgraded camera system. Explore iPhone 18 Pro specifications, features, display, cameras, battery, and expected price in the USA. Get the latest details about Apple’s new Pro model and its key upgrades. Compare iPhone 18 Pro features with other flagship smartphones.

Size (inches)
5.91 x 2.83 x 0.34
Weight (ounces)
7.44
Display size (inches)
6.3-inch (diagonal) all-screen OLED display
Resolution (pixels)
2622-by-1206-pixel resolution at 460 ppi
See all specifications →

Google specifications

Explore Google devices →

Samsung specifications

Explore Samsung devices →