Setup: Colab, Your Model Provider, and Running Locally
This takes about ten minutes. You do it once.
1. Choose a provider
The course works with three ways of reaching a language model. You only need one. You switch by changing one word in the setup cell.
| Provider | What it is | Where you run it | Cost |
|---|---|---|---|
| Groq | A cloud service that runs open models very fast | Google Colab, or your own computer | Free plan with daily limits |
| Google Gemini | Google's own models, through an API | Google Colab, or your own computer | Free tier with limits |
| Ollama | A program that runs a model on your own machine | Your own computer, in a code editor | Free; you supply the computer |
If you are using Colab, choose Groq or Gemini. They need a free key and nothing else.
If you want Ollama, work on your own computer in an editor such as VS Code. Ollama runs the model on your machine, so no key is needed and nothing you type leaves your computer. Section 5 shows the local setup.
Free plans limit how many requests you can send per minute and per day. If you hit a limit you get an error with the number 429. Wait a minute and try again, or switch provider.
Model names change. The names below were checked against each provider's documentation in October 2026. If a call fails with "model not found", open the provider's model list (links below) and put a current name into the setup cell. Nothing else in the lesson needs to change.
2. Get a key (Groq or Gemini)
Groq
- Go to console.groq.com and sign in.
- Open API Keys and create a key.
- Copy it. You will not be shown it again.
Model list: console.groq.com/docs/models
Google Gemini
- Go to aistudio.google.com and sign in.
- Choose Get API key and create a key.
- Copy it.
Model list: ai.google.dev/gemini-api/docs/models
3. Store the key safely in Colab
Never paste a key into a code cell. Notebooks get shared, and a key in a shared notebook is a key someone else can spend.
- Open colab.research.google.com and create a new notebook.
- In the left sidebar, click the key icon (Secrets).
- Add a secret. The name must be exactly
GROQ_API_KEY(for Groq) orGOOGLE_API_KEY(for Gemini). The value is your key. - Turn on Notebook access for it.
The secret is remembered across notebooks. For each new notebook you only switch access on.
4. The setup cell
Every lesson that calls a model begins with these two cells. Paste them, set PROVIDER, and run.
The course uses LangChain, a widely used Python library for building applications on language models. One of the things it does is give every provider the same interface, so the rest of your code does not care which one you chose. Later modules also use LangGraph, its companion library for building multi-step workflows and agents.
%pip install -q -U langchain langgraph langchain-groq langchain-google-genai langchain-ollamaimport os
from langchain.chat_models import init_chat_model
PROVIDER = "groq" # "groq" or "gemini" in Colab; "ollama" on your own computer
MODELS = {"groq": "groq:openai/gpt-oss-20b", "gemini": "google_genai:gemini-3.5-flash-lite", "ollama": "ollama:llama3.2:3b"}
KEY = {"groq": "GROQ_API_KEY", "gemini": "GOOGLE_API_KEY", "ollama": None}[PROVIDER]
if KEY and KEY not in os.environ:
from google.colab import userdata # keys live in Colab's Secrets panel
os.environ[KEY] = userdata.get(KEY)
llm = init_chat_model(MODELS[PROVIDER], temperature=0, max_retries=6)print(llm.invoke("Reply with the single word: ready").text)If it prints ready (or something close), you are set up.
Code walkthrough
%pip install ...installs the libraries once per notebook.langchainandlanggraphare the frameworks; the threelangchain-...packages are the connectors for each provider.PROVIDER = "groq"is the one word you change to switch provider.MODELSnames the model for each provider asprovider:model-name. This is the only place model names appear, so when a name changes you edit one line.KEYis the name of the secret the provider needs. Ollama needs none.- The
ifblock runs only in Colab when the key is not already set: it copies your key from the Secrets panel into an environment variable, which is where LangChain looks for it. init_chat_model(...)creates the model object,llm.temperature=0asks for the most consistent output.max_retries=6makes the client wait and try again when the provider says "too many requests" (a 429), which Groq's free plan does when a run passes 8,000 tokens a minute; it does not retry a reply the provider rejected as malformed (Module 5 handles those).llm.invoke(...)sends one message and returns a reply;.textis the reply as a string.
Why one cell works for three providers
init_chat_model reads the part before the colon (groq, google_genai, ollama) and builds the right connector. All connectors offer the same methods: .invoke() to get a reply, .stream() to get it piece by piece, and so on. Your code talks to llm and never mentions the provider again.
This is also how real teams avoid being locked to one provider: the provider is a setting, not something written all through the code.
Prices and limits (checked 9 and 10 October 2026)
This is the course's one table of model prices and limits. Lessons that count cost say "prices from course-guide/02" and use these numbers; when a provider changes them, this table changes and the lessons follow. Prices are US dollars per 1,000,000 tokens on each provider's paid plan. Standard prices were checked on 9 October 2026; cached, batch and context-window figures on 10 October 2026.
Model (as written in MODELS) | Input | Output | Cached input | Batch | Context window |
|---|---|---|---|---|---|
groq:openai/gpt-oss-20b (course default) | $0.075 | $0.30 | $0.0375 (50% off) | Not checked | 131,072 tokens, up to 65,536 output |
groq:openai/gpt-oss-120b (stronger) | $0.15 | $0.60 | $0.075 (50% off) | Not checked | 131,072 tokens, up to 65,536 output |
google_genai:gemini-3.5-flash-lite (course default) | $0.30 | $2.50 | $0.03 | $0.15 input, $1.25 output | 1,048,576 input tokens |
google_genai:gemini-3.8-flash (stronger) | $0.75 | $3.75 | $0.075 until 31 December 2026, then $0.15 | Half the standard price | Not checked |
ollama:llama3.2:3b and ollama:llama3.2:1b | $0 | $0 | $0 | $0 |
Notes on the table:
- Gemini's output price includes thinking tokens.
gemini-3.8-flash's listed price holds until 31 December 2026; from 1 January 2027 it is $1.50 input and $7.50 output.- The Gemini context window comes from the models API (checked 10 October 2026).
- A cached price applies only to a repeated prompt prefix of a minimum length. Groq's minimum is 128 to 1,024 tokens depending on the model (its docs give no per-model figure); Gemini's newer Flash models need 4,096 tokens.
- Ollama has no fee per token; you pay for the machine.
Free-plan limits. Groq's rate-limits page lists, for openai/gpt-oss-20b on the free plan, 30 requests a minute, 1,000 a day, 8,000 tokens a minute and 200,000 tokens a day. The tokens-a-minute limit is the one learners hit first: an agent run sends the whole conversation and the tool definitions on every step, so a few quick steps can pass 8,000 tokens within a minute and return a 429 error that mentions tokens per minute. Wait a minute and run the cell again, or switch PROVIDER.
Sources: Groq, "Supported models" (https://console.groq.com/docs/models) and "Rate limits" (https://console.groq.com/docs/rate-limits); Google, "Gemini Developer API pricing" (https://ai.google.dev/gemini-api/docs/pricing). Free plans change often and your own limits are on each provider's console page; these are the most likely numbers in this course to go out of date.
One extra library: the Model Context Protocol SDK
Module 4, and the later modules that serve tools over the Model Context Protocol (MCP), need the official MCP Python SDK. Those lessons install it in their own cell, after the setup cell:
%pip install -q -U "mcp>=2.3,<3"Code walkthrough
mcpis the official Python SDK for MCP. Version 2.3.0 (released 2 October 2026) implements the current MCP specification, dated 2026-07-28. Both were checked on 9 October 2026, on pypi.org/project/mcp and modelcontextprotocol.io."mcp>=2.3,<3"takes the newest 2.x release and refuses a future 3.0, which may change the code you write. MCP is moving fast; Module 4 says what is likely to change.
On your own computer, add "mcp>=2.3,<3" to the pip install line in section 5.
5. Running on your own computer (required for Ollama)
You can run every lesson locally with any provider. For Ollama it is the way to do it.
Install
- Python 3.10 or newer from python.org. Check with
python --version(on some systemspython3 --version). - A code editor. VS Code with the Python and Jupyter extensions is a good choice. Cursor, PyCharm and others work the same way.
- Ollama, if you are using it, from ollama.com/download. After installing, download the course's default model once, in a terminal:
ollama pull llama3.2:3bThat is a download of about 2 GB. The model runs acceptably on a recent laptop with 8 GB of memory or more. A small local model makes more mistakes than the cloud models. That is useful for this course: several "break it" steps are easier to see on a small model.
Create a project folder
In a terminal:
mkdir agentic-ai-engineer-course
cd agentic-ai-engineer-course
python -m venv .venvSwitch the virtual environment on:
# macOS and Linux
source .venv/bin/activate
# Windows (PowerShell)
.venv\Scripts\Activate.ps1Then install the libraries:
pip install -U langchain langgraph langchain-groq langchain-google-genai langchain-ollama pydantic python-dotenv ipykernelKeys on your own computer
Ollama needs no key. For Groq or Gemini, create a file named .env in the project folder:
GROQ_API_KEY=paste-your-key-here
GOOGLE_API_KEY=paste-your-key-hereand add these two lines at the very top of the setup cell:
from dotenv import load_dotenv
load_dotenv()Never share the .env file or commit it to Git.
Run the lessons
Open the folder in your editor and create a new notebook file, for example module-05-lesson-1.ipynb. Select the .venv Python when asked. A notebook in VS Code works like Colab: paste each code block into a cell and run it.
Set PROVIDER = "ollama" in the setup cell. You can skip the %pip install cell, because you installed the libraries already.
On a Mac: FAISS and PyTorch together
On macOS, loading FAISS and PyTorch in the same Python process can crash with an OpenMP error, because each brings its own copy of the OpenMP library. If you see it, set two environment variables in the terminal before you start Python, Jupyter or your editor:
export KMP_DUPLICATE_LIB_OK=TRUE
export OMP_NUM_THREADS=1The first tells OpenMP to accept the second copy; it is a workaround, not a fix. The second keeps OpenMP to one thread, which is slower on large indexes but fine for the small ones in this course. Module 9 (Retrieval for Agents) is where this course loads a vector index next to an embedding model. You do not need this in Colab.
From notebook cells to a project
In a job you would not keep code in notebook cells. The course grows one repository, a single package called returns_desk/. Module 1 starts it: the setup cell becomes returns_desk/llm.py with the llm object created once, the shared data goes in returns_desk/data.py, and a tests/ folder holds the checks as pytest tests. Later modules add their files inside the same package: the tools in Module 3, the MCP server in Module 4, the loop in Module 5, and so on. Module 15 runs the agent as a background worker from that package, and Module 16 puts it in a container and deploys it. Labs that must run in a temporary folder for testing create returns_desk/ there with the same layout and say so. The project page (course-guide/03) lists which module adds which file.
6. When something goes wrong
| What you see | What it means | What to do |
|---|---|---|
SecretNotFoundError | The secret is missing or misnamed | Check the name is exactly GROQ_API_KEY or GOOGLE_API_KEY |
NotebookAccessError | The secret exists but this notebook cannot read it | Turn on Notebook access for the secret |
ModuleNotFoundError: google.colab | Running locally with no key set | Create the .env file and add the two load_dotenv lines |
AuthenticationError (401) | The key is wrong or was deleted | Create a new key and update the secret |
NotFoundError (404) mentioning the model | The model name is out of date | Put a current model name in MODELS |
RateLimitError (429) | You hit the free plan's limit, often Groq's tokens-a-minute limit during an agent run | Wait a minute, or switch PROVIDER |
| A connection error with Ollama | Ollama is not running | Open the Ollama app, or run ollama serve in a terminal |
| Ollama says the model is not found | The model has not been downloaded | Run ollama pull llama3.2:3b |