1. Setting Up Your Development Environment¶
Alright, let's roll up our sleeves and get our hands dirty! Before we can start building our amazing agent, we need to set up our workspace. This involves two main parts: getting the necessary credentials from Google Cloud and preparing our local Python environment.
1. Setting up Google Cloud¶
Our agent needs a way to talk to Google's services. To do this, we need to generate some "keys" that grant our application permission. Specifically, we'll need access to two services:
- Generative Language API: This is how we'll access the powerful Gemini models.
- Custom Search API: This will be our agent's tool for searching the web.
Let's get them set up.
No Billing Required
I have been using the Gemini Models and search api for 5-6 months now and haven't spent a penny on experimentation and haven't require to even add a Billing account to my current Gemini Project. The current free tier (as of 9/6/25 ) is very generous and will cover for most of one's usecase to get started on this journey.
a) Enable the APIs¶
First, we need to tell Google which services we intend to use.
- Navigate to the Google Cloud Console.
- Select an existing project or create a new one.
- In the search bar at the top, type "APIs & Services" and select it.
- Click on "+ ENABLED APIS AND SERVICES".
- Search for and enable these two APIs one by one:
Generative Language API
Custom Search API
Once enabled, your "Enabled APIs & services" dashboard should look something like this :
b) Create an API Key¶
Now that the services are enabled, we need a key to authenticate our requests.
- In the left-hand navigation pane of "APIs & Services", click on Credentials.
- Click "+ Create credentials" and select "API key" from the dropdown.
- A new API key will be generated for you. Copy this key immediately and save it somewhere safe for the next step.
Your credentials screen will now show your newly created key.
Protect Your API Key!
Treat your API key like a password. Do not share it publicly or commit it to a version control system like Git. We'll set up a secure way to use it in our project in just a moment.
c) Create a Programmable Search Engine ID¶
The Google Custom Search tool requires one more piece of information: a Search Engine ID. This tells Google what to search (in our case, the entire web).
- Go to the Programmable Search Engine control panel.
- Click "Add" to create a new search engine.
- In the "What to search?" section, enable the "Search the entire web" option.
- Give your search engine a name (e.g., "LangGraph Tutorial Search") and click "Create".
- After creation, you'll be taken to a dashboard. Click on "Search engine ID" to copy your ID (it usually starts with
cx
). Keep this ID handy; we'll need it soon.
2. Setting Up Your Local Python Project¶
With our keys in hand, it's time to set up our local project directory and the environment.
a) Create the Project and Virtual Environment¶
A virtual environment is an isolated Python workspace. It allows us to install packages for a specific project without affecting other projects or the system-wide Python installation. It's a critical best practice for keeping dependencies clean and manageable.
Open your terminal or command prompt and run the following commands:
You'll know it's working when you see (venv)
at the beginning of your terminal prompt.
b): Store Your Credentials Securely¶
Let's create a .env
file to store our secret keys. This file will be read by our application but must not be committed to Git.
- Create a file named
.env
in your project's root directory. - Add your keys to it like so:
.gitignore
and add .env
and venv/
to it. This tells Git to ignore these files. c) Install Initial Python Packages¶
Finally, let's install the Python libraries we'll need to get started. We'll add more as we go, but this is our starting set.
Run this command in your activated virtual environment:
Here’s a quick breakdown of what we just installed:
langgraph
: The core framework for building our agent.langchain-google-genai
: The specific LangChain integration for Google's Gemini models.langchain-google-community
: The integration for Google Search and other community-maintained tools.python-dotenv
: A handy utility to load the variables from our.env
file.
It's good practice to keep a requirements.txt
file. Let's create one now.
And that's it! Our setup is complete. We've enabled the necessary Google services, secured our keys, and prepared our local Python environment.
In the next section, we'll dive into the fun part: writing code and building our very first, simple LangGraph agent. Let's go!