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

Swipe sideways to see all table columns →

Provider
OpenAI
API Example
https://api.openai.com/v1/chat/completions
Provider
Anthropic
API Example
https://api.anthropic.com/v1/complete
Provider
Ollama (local)
API Example
http://localhost:11434/api/generate
Provider
Google Gemini
API Example
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

Swipe sideways to see all table columns →

Tool
LangChain
Use For
Full framework for chaining LLM + DB
Tool
Ollama
Use For
Run LLMs locally
Tool
ChromaDB
Use For
Lightweight vector database (local)
Tool
Pinecone
Use For
Cloud vector database
Tool
FAISS
Use For
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

Swipe sideways to see all table columns →

Concept
LLM
Explanation
AI model that understands/generates text
Concept
LLM API
Explanation
Lets you use LLMs in your own app
Concept
Embedding
Explanation
Convert text into vector representation
Concept
Vector DB
Explanation
Store and search these embeddings
Concept
Semantic Search
Explanation
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 MacBook Pro 14-inch
Apple Apple MacBook Pro 14-inch specifications

Experience unrivaled performance with the latest Apple MacBook Pro, available in 14-inch and 16-inch models powered by the revolutionary M6, M5 Pro, and M5 Max chips. Built for Apple Intelligence, these powerhouse laptops feature advanced Thunderbolt 5 ports, Wi-Fi 7, and optional Nano-texture displays for minimal glare. Maximize your creative potential with up to 128GB of unified memory in a sleek Space Black or Silver finish.

Display size
14-inch
Screen Type
Standard display (low reflectivity) or Nano-texture display (reduces reflections and glare in bright lighting)
External Display Support
Support for up to three external displays (M5 Pro) / Support for up to four external displays (M5 Max)
M6 Chip
12‑core CPU, 12‑core GPU, Dual 16‑core Neural Engine
See all specifications →
Apple Apple MacBook Pro 16-inch
Apple Apple MacBook Pro 16-inch specifications

Experience unrivaled performance with the latest Apple MacBook Pro, available in 14-inch and 16-inch models powered by the revolutionary M6, M5 Pro, and M5 Max chips. Built for Apple Intelligence, these powerhouse laptops feature advanced Thunderbolt 5 ports, Wi-Fi 7, and optional Nano-texture displays for minimal glare. Maximize your creative potential with up to 128GB of unified memory in a sleek Space Black or Silver finish.

Display size
16-inch
Screen Type
Standard display (low reflectivity) or Nano-texture display (reduces reflections and glare in bright lighting)
External Display Support
Support for up to three external displays (M5 Pro) Support for up to four external displays (M5 Max)
M5 Pro Chip
18‑core CPU, 20‑core GPU, 16‑core Neural Engine
See all specifications →
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 →
Google Google Pixel 12
Google Google Pixel 12 specifications

Upgrade to the Google Pixel 12, an advanced 5G AI smartphone. Experience seamless performance powered by the custom Google Tensor G7 processor. Enjoy a stunning 6.3-inch OLED Actua display and take flawless photos with the powerful 50MP dual-camera system. Built with an adaptive all-day battery and seamless Google Gemini AI integration, it is the perfect unlocked device for everyday brilliance.

Size (inches)
6.02 x 2.83 x 0.34
Weight (ounces)
6.95
Display size (inches)
6.3-inch (diagonal) OLED display
Resolution (pixels)
1080 x 2424 pixels
See all specifications →
Google Google Pixel 12 Pro
Google Google Pixel 12 Pro specifications

Discover the new Google Pixel 12 Pro, the ultimate 5G AI smartphone. Powered by the next-generation Google Tensor G7 chip and built-in Gemini AI, it delivers blazing-fast performance. Capture professional-grade photos with the advanced 50MP Pro Triple Camera system featuring 5x optical zoom. Complete with a stunning 6.3-inch Super Actua display, all-day adaptive battery, and a premium titanium frame. Upgrade to the smartest Android phone today.

Size (inches)
6.02 x 2.83 x 0.33
Weight (ounces)
7.3
Display size (inches)
6.31-inch LTPO OLED display
Resolution (pixels)
2856 x 1280 pixels
See all specifications →
Google Google Pixel 12 Pro XL
Google Google Pixel 12 Pro XL specifications

Go bigger with the Google Pixel 12 Pro XL, the ultimate large-screen 5G AI smartphone. It boasts a massive 6.8-inch OLED display and the lightning-fast Google Tensor G7 chip. Capture master-level photography using the 50MP Pro Triple Camera setup. Equipped with a massive 5500mAh battery for extended endurance and fast 67W charging, this unlocked flagship redefines premium power.

Size (inches)
6.43 x 3.07 x 0.34
Weight (ounces)
8.18
Display size (inches)
6.8-inch LTPO OLED Super Actua display
Resolution (pixels)
2992 x 1344 pixels
See all specifications →
Google Google Pixel 12 Pro Fold
Google Google Pixel 12 Pro Fold specifications

Transform your mobile experience with the Google Pixel 12 Pro Fold. This unlocked 5G AI foldable smartphone unfolds into a gorgeous 8-inch dual-UTG inner OLED display for next-level multitasking and entertainment. Powered by the Google Tensor G7 chip, it features flexible triple-camera photography, advanced Gemini AI, and a highly durable folding hinge design.

Size (inches) - Unfolded
6.24 x 5.64 x 0.16
Size (inches) - Folded
6.24 x 2.87 x 0.35
Weight (ounces)
7.58
Main Display
8.0-inch Foldable LTPO OLED, 120Hz
See all specifications →

Samsung specifications

Explore Samsung devices →