Setting Up
Packages and a key.
To follow along, you need Python, a few packages, and an API key for a model. We'll use Google's Gemini, which has a free tier, but every example works with other providers too.

- Python
- A few packages
- An API key
Installing the packages
Install three packages with pip. LangGraph is the graph library. Lang chain gives us models and tools. Lang chain google gen AI connects to Gemini. Then get a free key from Google AI Studio, and store it in an environment variable.
pip install langgraph langchain langchain-google-genai
# get a key at aistudio.google.com, then:
export GOOGLE_API_KEY="your-key-here"Checking the setup
Let's check everything is ready. We print the installed LangGraph version, and whether a key is set, without ever printing the key itself. Run it. Version one point two, and the key is there.
import os
from importlib.metadata import version
print("LangGraph version:", version("langgraph"))
has_key = bool(os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY"))
print("API key set:", has_key)LangGraph version: 1.2.19 API key set: True
Summary
Install langgraph, langchain, and langchain google gen AI, and keep your key in an environment variable. Next, your very first graph.
Key takeaways- pip install langgraph
- Key in an environment variable
- Never in your code