Setup: Colab, Model Providers, Libraries and Prices
This takes about ten minutes. You do it once.
Many lessons need no key at all: the arithmetic, the estimator, the ingestion pipeline, the queue, the web service and the simulations on the shared data all run inside the notebook. The lessons that call a hosted model are marked in each module README and in this table:
| Module | Lessons that call a hosted model |
|---|---|
| 1 | Lesson 1 (the same question twice) |
| 2 | Lesson 1 (one optional call) |
| 3 | Lessons 2 and 5 (token counts and timing, measured) |
| 4 | Lessons 1 and 2, and the lab |
| 6 | Lessons 2 and 3, and the lab |
| 7 | Lessons 1, 2 and 4, and the lab |
| 8 | Lessons 1 and 2 (lesson 3 optional), and the lab |
| 9 | Lessons 1, 2, 4 and 6 (lesson 3 optional), and the lab |
| 10 | Lesson 1 (the lab optional) |
| 11 | Lesson 2 |
| 12 | Lessons 1 and 2, and the lab |
| 13 | Lessons 1 and 2, and the lab |
| 16 | The capstone lab |
Modules 5, 14 and 15 make no hosted calls.
1. Colab
All code runs in Google Colab on the free CPU. Open a new notebook, paste each code block into a cell in order, and run it. No lesson needs a GPU.
The course targets the Python version Colab runs, which was 3.12 at the last check recorded for this series (13 October 2026); the course's own test environment is Python 3.12.15. Print it once in your first notebook:
import sys
print(sys.version)Code walkthrough
sys.versionis the version of Python running your notebook. If it does not start with3.12(or a later 3.x), some pinned libraries may refuse to install; the run-locally page says which.
2. Choose a model provider
You only need one provider. 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-weight models very fast | Google Colab, or your own computer | Free plan with limits |
| Google Gemini | Google's own models, through the Gemini 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 (07-run-locally.md) | Free; you supply the computer |
In Colab, choose Groq or Gemini. They need a free key and nothing else. Ollama runs the model on your machine, so no key is needed and no text leaves your computer, which is one of the options Leila weighs in Module 7 when a tenant's contract restricts where its data may go.
Free plans limit requests 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. Module 14 reads the limit headers and treats them as a capacity ceiling.
3. Get a key
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
4. 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. (Module 10 lesson 5 is about the same rule at company scale: secrets never live in code.)
- In the left sidebar of your notebook, 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.
5. The setup cell
Every lesson that calls a hosted model begins with these cells. Paste them, set PROVIDER, and run.
The course uses LangChain, a widely used Python library that gives every model provider the same interface, so the rest of your code does not care which one you chose. That is also the first architectural idea of the course: the model is a dependency behind one boundary, not something written all through the code (Module 4 lesson 3).
%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. In the course's test run on 18 October 2026 it printed ready on both Groq and Gemini.
Code walkthrough
%pip install ...installs the libraries once per notebook:langchain(the framework),langgraph(its companion for multi-step workflows, used from Module 8) and one connector per provider. This line is the same in every course in the series.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).llm.invoke(...)sends one message and returns a reply;.textis the reply as a string.
Two tiers, for the routing lessons. From Module 7 the gateway routes between a small, cheap model and a large one. Lessons that need the large tier add this line after the setup cell, and nothing else changes:
LARGE = {"groq": "groq:openai/gpt-oss-120b", "gemini": "google_genai:gemini-3.8-flash", "ollama": "ollama:llama3.2:3b"}
big = init_chat_model(LARGE[PROVIDER], temperature=0, max_retries=6)Code walkthrough
LARGEnames the stronger model for each provider; Ollama keeps the same local model, because a laptop rarely runs a second, larger one.bigis the large-tier model object, created the same way asllm. The gateway decides which of the two each request goes to.
What the providers report back
Every reply carries usage_metadata, the provider's own count of tokens. The estimator in Module 3 is checked against it. In the course's test run on 18 October 2026 the shapes were:
| Provider | usage_metadata keys seen | Notes |
|---|---|---|
Groq (gpt-oss-20b, gpt-oss-120b) | input_tokens, output_tokens, total_tokens, output_token_details.reasoning | Reasoning tokens are counted inside output_tokens and billed as output. Groq's prompt-caching page reports cached input in the raw response as usage.prompt_tokens_details.cached_tokens; Module 8 lesson 2 reads it |
Gemini (gemini-3.5-flash-lite, gemini-3.8-flash) | the same, plus input_token_details.cache_read | gemini-3.5-flash-lite printed a warning that it "uses fixed sampling defaults" and ignores temperature. Expect its answers to vary between runs |
When the provider rejects a request or a reply
Sometimes a provider returns an error instead of a reply: a malformed answer, a model name that no longer exists, a brief outage. max_retries does not help when the request itself is the problem. The course handles it the same way everywhere: try once more, and if that also fails, say so plainly instead of crashing.
def ask(model, messages):
"""Returns (reply, None), or (None, reason) after two refusals."""
for attempt in range(2): # one retry: the next reply is usually fine
try:
return model.invoke(messages), None
except Exception as err:
last = err
return None, f"provider_error: {type(last).__name__}"Code walkthrough
asksends the messages and returns the reply with no reason, or no reply with a reason.- On an error it tries once more; after a second error it gives up and names the error. In the test run, a made-up model name gave
provider_error: NotFoundErroron Groq andprovider_error: GoogleModelNotFoundErroron Gemini.
Lessons use this shape: a request the model could not answer gets the result "provider_error" and is counted as a failure in every score, so one bad reply never stops a notebook and never quietly improves a result. This small function is also the seed of the gateway: Module 7 turns "try once more" into a fallback chain across providers, and Module 11 adds timeouts, a retry budget and a circuit breaker.
Lessons that run the golden sets (54 Ask questions, 18 Cases tasks) cache every reply to disk, so a rerun does not pay twice and stays inside the free plans.
6. Prices and limits (checked 18 October 2026)
This is the course's one table of model prices. Lessons that count cost say "prices from course-guide/02" and use these numbers (the same numbers are PRICE_SNAPSHOT in 06-shared-data.md). When a provider changes them, this table changes and the lessons follow. US dollars per 1,000,000 tokens, standard paid tier.
| Model (as written in the setup cell) | Gateway tier | Input | Cached input | Output | Notes |
|---|---|---|---|---|---|
groq:openai/gpt-oss-20b | small (default) | $0.075 | $0.0375 | $0.30 | 131,072-token context, up to 65,536 output. Cached input is 50% off; the cache expires after 2 hours unused |
groq:openai/gpt-oss-120b | large | $0.15 | $0.075 | $0.60 | Same context and caching |
google_genai:gemini-3.5-flash-lite | small (default) | $0.30 | $0.03 | $2.50 | Batch: $0.15 input, $1.25 output |
google_genai:gemini-3.8-flash | large | $0.75 | $0.075 | $3.75 | Until 31 December 2026; doubles to $1.50 and $7.50 on 1 January 2027. Batch: $0.375 and $1.875 |
ollama:llama3.2:3b | local | $0 | $0 | No fee per token; you pay for the machine. A 2.0 GB download | |
google_genai:gemini-embedding-2 (shown, not used) | $0.20 | Hosted embeddings; the course embeds locally with sentence-transformers for $0 |
The roadmap's illustrative prices. The worked estimate in Module 3 uses "$1 per million input, $5 per million output" and "a tier at a fifth the price". Those are round numbers for arithmetic, not any provider's price, and the course labels them illustrative wherever they appear.
Limits. Groq's rate-limits page lists 30 requests a minute, 1,000 a day, 8,000 tokens a minute and 200,000 tokens a day for the two gpt-oss models, labelled as base limits for its Developer plan; your own limits are on your console's limits page. Google's rate-limits page says Gemini limits depend on your usage tier and are shown in Google AI Studio.
Deprecations to know about. Groq's deprecations page lists llama-3.1-8b-instant and llama-3.3-70b-versatile as shut down on 16 August 2026, although its models page still listed them on 18 October 2026. Do not use them. Google lists gemini-2.0-flash and gemini-3-pro-preview as shut down. Module 7 lesson 4 uses these as the example of deprecation as a planned event.
Sources (all read 18 October 2026): Groq, Supported models, Prompt caching, Rate limits, Deprecations; Google, Gemini models, Gemini Developer API pricing, Rate limits; Ollama, llama3.2. These are the numbers in this course most likely to go out of date.
7. Closed and managed models, shown but not run
Lessons show how the same call looks on OpenAI or Anthropic models and on the three big cloud platforms, using the official SDK or LangChain snippet from their current documentation, labelled not run here. The course does not call them, so no key is needed and no number in the course comes from them.
| Platform | What it is (from its own documentation, read 18 October 2026) | Python package a snippet uses |
|---|---|---|
| Amazon Bedrock | AWS's managed model service; its Converse API gives one interface across models (Converse and ConverseStream) | boto3 1.43.114 |
| Google Gemini Enterprise Agent Platform | Google Cloud's AI platform, formerly Vertex AI (renamed in the 22 April 2026 release notes) | google-genai 2.31.0 |
| Microsoft Foundry | Microsoft's AI platform, formerly Azure AI Foundry; Azure OpenAI resources are upgraded to Foundry resources | openai |
| OpenAI, Anthropic | Closed model providers with their own APIs | openai 3.35.1, anthropic 1.15.0 |
Versions are the latest on PyPI on 18 October 2026, recorded so a snippet names a real version. With LiteLLM installed (Module 7), pip chooses openai 2.54.0, because LiteLLM 1.106.0 requires a version below 3.0.
8. The libraries
Colab already ships numpy, pandas, torch and transformers. Each lesson installs only what it imports, in one cell near the top, with the version pinned so your run matches the course's. numpy, pandas and torch stay at Colab's own versions, because forcing them can make Colab ask you to restart the runtime.
Versions are the latest releases on PyPI, read on 18 October 2026; "Released" is the upload date of that release.
| Library | Pin | Released | First used | What it is for |
|---|---|---|---|---|
| pytest | pytest==9.1.1 | 19 Jun 2026 | Module 1 (lab) | The repository's tests |
| tiktoken | tiktoken==0.14.0 | 17 Aug 2026 | Module 3 | Estimating tokens before a call (the provider's count is the truth) |
| pydantic | pydantic==2.14.1 | 11 Oct 2026 | Module 4 | Validating structured data at boundaries |
| langchain, langchain-core | langchain==1.4.6, langchain-core==1.6.12 | 14 and 16 Oct 2026 | Module 4 | The model client; the setup cell installs them unpinned with -U |
| langchain-groq, langchain-google-genai, langchain-ollama | 1.1.3, 4.4.2, 1.1.0 | Jun, Oct and Apr 2026 | Module 4 | Provider connectors |
| scikit-learn | scikit-learn==1.9.1 | added 18 Oct 2026 | Module 4 (lesson 2) | The trained intent classifier compared with the rule and generative routers |
| presidio-analyzer, presidio-anonymizer (optional) | 2.2.364 | added 18 Oct 2026 | Module 5 (lesson 3) | Open-source personal-data detection, with spaCy's en_core_web_sm model. Conflict: Presidio 2.2.364 requires numpy below 2.5.0, so it cannot be installed beside the labs' numpy==2.5.4 (pip ResolutionImpossible, checked 19 October 2026). Run its cell in a notebook of its own; Intake's default is the regex-v2 detector |
| openlineage-python | openlineage-python==1.54.0 | added 18 Oct 2026 | Module 5 (lesson 3) | Lineage events in the OpenLineage format |
| sentence-transformers | sentence-transformers==6.1.0 | 18 Sep 2026 | Module 6 | Local embeddings; requires huggingface-hub below 2.0 |
| huggingface-hub | huggingface-hub==1.33.0 | 24 Sep 2026 | Module 6 | Pin it in every cell that installs sentence-transformers, langchain-huggingface or litellm (see below) |
| faiss-cpu | faiss-cpu==1.15.1 | 16 Sep 2026 | Module 6 | An in-memory vector index |
| chromadb | chromadb==1.5.9 | 5 May 2026 | Module 6 | An embedded vector database |
| qdrant-client | qdrant-client==1.19.1 | 16 Sep 2026 | Module 6 | Qdrant in local mode in Colab, and the client for the Qdrant server locally |
| rank-bm25 | rank-bm25==0.2.2 | 16 Feb 2022 | Module 6 | Keyword search; old but stable |
| transformers | Colab's own; locally transformers==5.20.1 | 16 Oct 2026 | Module 7 | Timing prefill and decode on a small model on CPU |
| litellm | litellm==1.106.0 | 18 Oct 2026 | Module 7 | The open-source gateway library, compared with the hand-built gateway |
| langgraph | langgraph==1.2.16 | 16 Oct 2026 | Module 8 | Workflows, state, checkpoints and approvals |
| langgraph-checkpoint-sqlite | langgraph-checkpoint-sqlite==3.1.2 | 12 Oct 2026 | Module 8 | SqliteSaver, a checkpoint store in a file; install it beside langgraph==1.2.16 |
| redis, fakeredis, rq | redis==8.1.0, fakeredis==2.40.0, rq==2.12.0 | Jul, Oct and Aug 2026 | Module 8 | A job queue; fakeredis stands in for a Redis server in Colab |
| mcp | mcp==2.3.0 | 2 Oct 2026 | Module 9 | The official Model Context Protocol SDK (specification revision 2026-07-28) |
| a2a-sdk | a2a-sdk==1.2.2 | 5 Oct 2026 | Module 9 (Recommended topics) | The Agent2Agent protocol SDK; Module 9 lesson 4 runs it in-process |
| temporalio | temporalio==1.34.0 | added 18 Oct 2026 | Module 8 (lesson 4) | The durable-workflow SDK; it needs a Temporal server, so the lesson's steps run locally, not in Colab (see 07-run-locally.md) |
| fastapi, httpx | fastapi==0.143.5, httpx==0.28.1 | 18 Oct 2026, 6 Dec 2024 | Module 10 | The web service; httpx is what TestClient uses |
| opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp | 1.45.1 | 6 Oct 2026 | Module 13 | Standard tracing |
| arize-phoenix, arize-phoenix-otel, openinference-instrumentation-langchain | 20.23.0, 0.17.2, 0.1.79 | Sep and Oct 2026 | Module 13 | A self-hostable trace viewer; Elastic License 2.0 (source-available) |
| ragas | ragas==0.4.3 | 13 Jan 2026 | Module 13 (optional) | An open evaluation library, compared with the hand-built harness |
Libraries used only on your own computer (uvicorn, psycopg, pgvector, langfuse, a Temporal server for temporalio, docker) are on 07-run-locally.md.
The huggingface-hub pin. The newest huggingface-hub was 2.2.0 (8 October 2026), but sentence-transformers 6.1.0, langchain-huggingface 1.2.3 and litellm 1.106.0 all require a version below 2.0. Colab may already have a 2.x version. Every cell that installs one of them pins it:
%pip install -q sentence-transformers==6.1.0 huggingface-hub==1.33.0Code walkthrough
sentence-transformers==6.1.0installs the embedding library at the course's version;huggingface-hub==1.33.0keeps the download library below 2.0, which sentence-transformers needs. If Colab then asks you to restart the runtime, do so and run the cells again from the top.
Two libraries the course does not use, and why. arq (a Redis job queue) requires redis below 6, which conflicts with the pinned redis 8.1.0, so the course uses RQ. langchain-mcp-adapters 0.3.2 requires mcp below 2.0, so Module 9 writes its own short adapter between MCP tools and LangGraph instead.
Checked on paper, not yet in Colab. On 18 October 2026 a pip install --dry-run of the course's libraries (with huggingface-hub==1.33.0, leaving out arize-phoenix and the serving engines), for Python 3.12 on Linux, wheels only, resolved with no conflict: 193 packages. That proves the pins fit together; the first lesson pilot installs and imports them in Colab and records the result here.
9. Open models from Hugging Face (no key)
| Model | Licence | First used | What it is for |
|---|---|---|---|
sentence-transformers/all-MiniLM-L6-v2 | Apache 2.0 (as recorded in this series on 14 October 2026) | Module 6 | Embedding Northdesk's documents and questions |
Snowflake/snowflake-arctic-embed-xs | Apache 2.0 (model card, read 23 October 2026) | Module 6 (lesson 1) | A candidate embedding model, measured against MiniLM on Northdesk's questions |
cross-encoder/ms-marco-MiniLM-L6-v2 | Apache 2.0 (model card, as Module 6 lesson 1 records) | Module 6 (lesson 1) | The reranker |
HuggingFaceTB/SmolLM2-135M-Instruct | Apache 2.0 (read on the Hub, 18 October 2026) | Module 7 (lesson 3) | Timing prefill and decode on CPU |
BAAI/bge-base-en-v1.5 | MIT (read on the Hub, 19 October 2026) | Module 14 (lesson 2) | The embedding model Ask migrates to: 768 dimensions, 512 word pieces |
Each lesson names any model it downloads, with its licence read from the Hugging Face Hub on the day it was written; licences can change, so check the model card before you ship one.
10. 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 | See 07-run-locally.md: create the .env file |
AuthenticationError (401) | The key is wrong or was deleted | Create a new key and update the secret |
provider_error: NotFoundError or GoogleModelNotFoundError | The model name is out of date | Put a current model name in MODELS |
RateLimitError (429) | You hit the free plan's limit | Wait a minute, or switch PROVIDER; golden-set runs cache replies so a rerun costs nothing |
pip says a package requires huggingface-hub<2.0 | A newer hub was installed | Reinstall with huggingface-hub==1.33.0 in the same cell, then restart the runtime |
A warning that temperature will be ignored | The Gemini model uses fixed sampling | Nothing to do; expect answers to vary a little between runs |
| A connection error with Ollama | Ollama is not running | Ollama runs on your own computer only: see 07-run-locally.md |