✨ Build a Bot with No More APIs 🎀


Intro
Hello folks! My name is Sudharshini Jothikumar.
In this blog, we are going to explore how to create a bot without using any paid APIs — fully free, offline-friendly, and with minimal code. Whether you're a beginner or just tired of API keys and limits, this one's for you
🧠 Wait… What Are All These Fancy Words?
Sometimes we casually throw around cool tech terms like LLM, LLaMA, Ollama, LangChain, and RAG...
But do we really know what they mean? 😅
Let’s break them down in a simple, friendly way 💖
🦙 LLaMA – Meta’s Very Own LLM
LLaMA stands for "Large Language Model Meta AI"
It’s an open-source AI model created by Meta (Facebook) to understand and generate human-like text.
Think of LLaMA as a brain that was trained on lots of data from the internet — books, posts, articles, code — so it can talk like a human!
🧰 Ollama – Running LLaMA on Your Laptop
Ollama is a magical tool that lets you run LLaMA (and other models) directly on your PC or server — no internet required, no APIs, no cloud!
🧱 LangChain – Build Chatbots Like LEGO
LangChain is a Python (and JS) library designed to help you build chatbots and AI assistants more easily.
It connects:
Your AI model (like LLaMA)
Tools (like memory, databases)
Logic (like chains and prompts)
🔁 RAG – Teach Your Bot Custom Knowledge
RAG stands for Retrieval-Augmented Generation.
It’s a way to train your AI assistant on your own documents or data (like PDFs, medical records, books).🧪 Step 1: Install Ollama
Ollama helps you run LLMs like LLaMA on your own computer — no internet required after download. ✨
👉 Download Ollama from here:
🔗 https://ollama.comJust pick your OS (Windows, Mac, or Linux) and follow the installation guide. It’s super easy.
🔧 Step 2: Open Your Terminal
After installation, open your command line/terminal and simply type:
ollama
If it runs without errors, Ollama is installed properly! 🥳
🦙 Step 3: Pick a Model – TinyLLaMA
Since LLaMA is a family of models (like
llama2
,llama3
,codellama
, etc.), let’s start simple and light.We’ll use TinyLLaMA – a lightweight model that works great on normal laptops 💻✨
📥 Step 4: Pull the Model
Now in your terminal, type:
ollama pull tinyllama
This will download the TinyLLaMA model to your system. It may take a few minutes depending on your internet speed.
🚀 Step 5: Run the Model
Once the download is done, just type:
ollama run tinyllama
Boom! You now have your own offline chatbot running right on your PC. 🎉
You can start chatting with it directly in the terminal like:
> Hello! < Hi there! How can I help you today?
🧪 Step 6: Create a Virtual Environment and activate(Optional but Recommended!)
Before we start writing our bot logic in Python, let’s first set up a virtual environment — a clean workspace for our bot project.
This keeps your dependencies organized and avoids messing with your system Python 🧼🐍
🪟 For Windows:
Open Command Prompt (or PowerShell), then type:
python -m venv chatbot powershell -ExecutionPolicy Bypass -File .\chatbot-env\Scripts\Activate.ps1
You’ll know it’s activated when your terminal prompt shows something like:
scssCopyEdit(chatbot-env) C:\Users\Sudharshini\Desktop>
🐧 For Linux/macOS:
Open your terminal and type:
python3 -m venv chatbot-env source chatbot-env/bin/activate
You’ll see:
rubyCopyEdit(chatbot-env) sudharshini@ubuntu:~$
🧪 Step 7: Install Python Packages for Your Bot
🔍 Installation
pip install langchain langchain-ollama ollama
🧠 Step 8: Write Your First Chatbot –
main.py
It’s time to bring your bot to life! 🪄
Let’s create a Python file calledmain.py
and add this code inside:
from langchain_ollama import OllamaLLM def main(): llm = OllamaLLM(model="tinyLlama") print("Welcome to the chatbot! Type 'exit' to quit.") while True: question = input("You: ").strip() if question.lower() == "exit": print("Goodbye!") break if question == "": continue print("Bot is thinking...") try: answer = llm.invoke(question) print(f"Bot: {answer}") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": main()
📝 What This Code Does
Creates a chatbot using your local TinyLLaMA model
Takes user input through the terminal
Sends it to the model and displays the response
Runs in a loop until you type
exit
▶️ Run the Bot (Inside Virtual Environment)
In your terminal, make sure you're inside your virtual environment, then run:
python main.py
You should see:
Welcome to the chatbot! Type 'exit' to quit. You:
🌐 What’s Next?
Now that you've built a fully working chatbot in your terminal using LangChain + Ollama + TinyLLaMA...
💡 Why not make it talk through a website?
In the next blog, we’ll explore:
✅ How to create a Django web app
✅ How to integrate your local chatbot with a web frontend
✅ Make it interactive with a chat interface
✅ Still… no API keys! 😌Stay tuned for Part 2: Integrate Your AI Bot with Django 🎀
From command line to cute website – we're just getting started 💻🌐💕
Subscribe to my newsletter
Read articles from Sudharshini Jothikumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sudharshini Jothikumar
Sudharshini Jothikumar
I am Sudharshini, a dynamic force in the world of technology and creativity, currently pursuing my MSc in Software Systems. With a passion for problem-solving, I have not only honed my skills but emerged victorious in numerous hackathons, showcasing my prowess in the ever-evolving realm of software development. Beyond the lines of code, I am also a wordsmith, having penned and published two captivating books that reflect my diverse interests. My ability to weave narratives demonstrates a depth of creativity that extends beyond the digital domain. I am also a national-level champion in both Silambam and Adimurai, showcasing my physical prowess and discipline. Whether it's mastering the intricacies of software architecture or gracefully wielding traditional weapons, I embodied a perfect blend of the modern and the traditional. In a world where versatility is key, I stand out as a multifaceted individual, seamlessly navigating the realms of technology, literature, and martial arts with finesse. My journey is not just a narrative of achievements but a testament to the limitless possibilities that arise when one embraces a holistic approach to life.