Setting Up
Packages and a key.
To follow along, you need Python, a few packages, and a free API key for a language model. We'll use Google's Gemini for answers, and small free models that run on your own computer, for search.

- Python
- A few packages
- A free API key
Installing the packages
Install the packages with pip. Lang chain connects to the language model. Sentence transformers runs embedding models locally. Rank BM 25 does keyword search, and faiss does fast vector search. Then put your Gemini key in an environment variable.
pip install langchain langchain-google-genai langchain-text-splitters
pip install sentence-transformers rank-bm25 faiss-cpu numpy pypdf
# get a free key at aistudio.google.com, then:
export GOOGLE_API_KEY="your-key-here"Checking the setup
Let's check that everything is installed. We print the version of each package, and whether a key is set, without printing the key itself. Run it. Every package is there, and the key is set.
import os
from importlib.metadata import version
for package in ["langchain", "sentence-transformers", "rank-bm25", "faiss-cpu", "pypdf"]:
print(f"{package:22} {version(package)}")
has_key = bool(os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY"))
print("API key set:", has_key)langchain 1.5.0 sentence-transformers 6.2.0 rank-bm25 0.2.2 faiss-cpu 1.15.1 pypdf 7.0.1 API key set: True
Summary
Install the packages, and keep your key in an environment variable, never in your code. Next, your first model call.
Key takeaways- pip install
- Key in an environment variable
- Check versions