Why local first

This course defaults to running LLMs on your own machine using Ollama. Why? Because local is free forever, private (your prompts never leave your machine), works offline, and teaches you the real internals of how agents work. Every prompt you send stays in your control.

We use Gemini only as a comparison and for tasks that need live internet (news, stock prices, etc.). But the core course is local. You'll own your infrastructure from day one.

What you'll install today:
  • Ollama — runs LLMs locally on your machine (the main engine)
  • Miniconda — Python environment manager (if you don't have it)
  • Python packages — ollama, google-generativeai, python-dotenv, requests
  • Free Gemini API key — for comparison and live data (optional but recommended)

Pick your platform

Jump to the section for your operating system below. Every OS ends up at the same place: a working python test_ollama.py and python test_gemini.py.

Mac setup

1. Install Homebrew (if you don't have it)

First, check if Homebrew is already installed:

bash

If you see a version number, skip to step 2. If not, paste this from brew.sh:

bash

2. Install Ollama

bash

Start the service in the background:

bash

The & runs it in the background. On recent Macs, brew services start ollama also works.

3. Pull your first local model

bash

This downloads a 4.7 GB model (one-time, 3-10 min depending on your internet). This is your main chat model for the entire course.

4. Install Miniconda (if you don't have conda)

Check first:

bash

If missing, download the macOS installer from conda.io/miniconda and run the .pkg file.

5. Create the course environment

bash
Important:
From now on, every time you work on the course, run conda activate ramayai first.

Windows setup

1. Install Ollama

Download the Windows installer from ollama.com/download/windows and run the .exe. Ollama will auto-start on login.

Verify in a new PowerShell window:

powershell

2. Pull your first model

powershell

3. Install Miniconda

Download from conda.io/miniconda and run the .exe. During installation, tick "Add Miniconda to my PATH" (despite the warning—it makes life easier).

4. Open Anaconda Prompt

Open Start menu and search for "Anaconda Prompt" (NOT regular PowerShell—conda only works inside Anaconda Prompt by default on Windows).

5. Create the course environment

powershell
Important:
On Windows, always open "Anaconda Prompt" to work on the course. Regular PowerShell won't have conda available.

Linux setup

1. Install Ollama (one-liner)

bash

This also auto-starts the service via systemd. Verify:

bash

2. Pull your first model

bash

3. Install Miniconda

bash

Follow the prompts and accept defaults. Close and reopen your terminal.

4. Create the course environment

bash

Get your free Gemini key

  1. Go to aistudio.google.com/app/apikey and sign in with any Gmail account.
  2. Click "Create API key" → "Create API key in new project"
  3. Copy the key — it starts with AIza...
  4. Keep it handy. You'll paste it into .env in the next section.
Security warning:
Never share this key in chat, GitHub, or screenshots. Anyone with it can use your quota. If you leak it, revoke it immediately at aistudio.google.com/app/apikey and create a new one.

Download starter files

We've prepared a small bundle: llm.py (provider-agnostic wrapper), test_ollama.py, test_gemini.py, requirements.txt, .env.example, and .gitignore.

All platforms: Create a working folder

On Mac/Linux:

bash

On Windows (in Anaconda Prompt):

powershell

Copy these files into your folder

File 1: llm.py

pythonProvider-agnostic wrapper

File 2: test_ollama.py

pythonSmoke test — local Ollama

File 3: test_gemini.py

pythonSmoke test — Gemini free tier

File 4: requirements.txt

txt

File 5: .env (copy from .env.example and fill in your key)

txt

File 6: .gitignore

txt

Install packages

bash

Edit .env with your Gemini key

Open .env in your editor and replace paste_your_gemini_key_here with your actual API key.

Run the smoke tests

Now test both providers to make sure everything is wired correctly.

Test Ollama (local)

bash

Expected output: a sentence like "An AI agent is a system that perceives its environment and takes actions based on that perception."

Test Gemini (cloud)

bash

Expected output: a similar sentence from Gemini.

If both print replies, you're done. Go to Lesson 01.

Troubleshooting

ModuleNotFoundError: No module named 'ollama'

You're not in the ramayai environment. Run:

bash
models/gemini-2.0-flash is not found or 404

Your installed SDK doesn't support that model version. Update the model name in llm.py (default is already gemini-2.5-flash). Or update the SDK:

bash
Quota exceeded or limit: 0 on Gemini

Your Google account's free-tier allocation is exhausted—usually happens with workspace (non-@gmail.com) accounts or accounts with broken billing. Fix:

Connection refused / Could not connect to Ollama

Ollama service isn't running. Start it:

  • Mac: ollama serve & or brew services start ollama
  • Windows: Open Ollama from Start menu
  • Linux: sudo systemctl start ollama
Ollama call takes 2+ minutes

Your laptop is slow or low on RAM. Try a smaller model:

bash

Then call it with:

python
pip install fails on Windows with SSL errors

Make sure you're in Anaconda Prompt, not regular PowerShell. Conda's certificate store is different.

Python version is 3.9 / union syntax error

You're running system Python, not your conda env. Run:

bash

Test your knowledge

Question 1 of 5
Why do we default to local models in this course?
Question 2 of 5
What command pulls a model in Ollama?
Question 3 of 5
What goes in your .env file?
Question 4 of 5
What should you do if you leak your API key in a screenshot?
Question 5 of 5
On Windows, which terminal must you use for this course?
0
/5
Great work! Your local AI stack is ready.
Continue to Lesson 01 →
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

Your local AI stack is live.
Now go build real agents.

Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Agentic Engineer →