Engineering4 min read

Getting Started with Gemini Pro 2.5: Build a Simple AI Agent

A practical guide to using Google’s Gemini Pro 2.5 to create a basic AI agent. Covers installation, setup, and step-by-step code examples. Ideal for developers exploring the model’s reasoning and coding features. No hype—just useful instructions.

Tega Adeyemi
Tega Adeyemi
Getting Started with Gemini Pro 2.5: Build a Simple AI Agent

Google DeepMind’s Gemini Pro 2.5 is a new AI model that pushes the boundaries of reasoning and coding. It's Google’s most intelligent AI model (so far). Designed as a “thinking model,” Gemini Pro 2.5 processes complex problems with humanlike step‑by‑step reasoning and supports multimodal inputs—from text to images and code repositories. In today’s guide, we’ll introduce you to the framework, explore its benefits, and walk you through setting up and building your first simple agent. For a full presentation of the model’s capabilities, see the official Gemini presentation and consult the Developer Documentation.

Model choice is the easy decision; the agent harness around it (gates, observability, recovery) is the harder work we cover in Cohorte's Building Accountable AI Agents course (E3).

Presentation of the Framework

Gemini Pro 2.5 is part of Google’s Gemini family of models, known for their extensive reasoning capabilities. Key features include:

These features make Gemini Pro 2.5 a robust tool for developers, researchers, and content creators looking to tackle complex challenges.

Benefits of Using Gemini Pro 2.5

Leveraging Gemini Pro 2.5 provides several advantages:

Getting Started

Prerequisites

Before diving in, ensure you have:

Installation and Setup

1. Create a Virtual Environment and Install Dependencies:

Open your terminal and run:

python -m venv gemini_env
source gemini_env/bin/activate  # On Windows, use: gemini_env\Scripts\activate
pip install google-generativeai

2. Configure Your API Key and Import the Library:

In your Python script, set up the Gemini client:

import google.generativeai as genai

# Replace 'YOUR_API_KEY' with your actual Gemini API key.
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-pro-exp-03-25")

This snippet imports the necessary library, configures the API key, and sets the model to Gemini Pro 2.5 Experimental.

First Steps & First Run

Before building a full agent, test the model with a simple prompt:

# A simple test prompt
prompt = "Explain the significance of Occam's Razor in simple terms."

response = model.generate_content(prompt)
print(response.text)

Run this script by executing:

python your_script.py

You should receive a clear, concise explanation of Occam's Razor—a great sign that your Gemini setup is working correctly.

Step-by-Step Example: Building a Simple Agent

Let’s build a simple agent that can answer user queries. This agent will:

Step 1: Define the Agent’s Purpose

For this example, our agent will function as a basic conversational assistant.

Step 2: Write the Agent Code

Below is a complete Python script that sets up and runs a basic conversational loop:

import google.generativeai as genai

# Configure the Gemini API with your API key
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-2.5-pro-exp-03-25")

def ask_agent(prompt):
    """Send a prompt to Gemini Pro 2.5 and return the response."""
    response = model.generate_content(prompt)
    return response.text

def run_agent():
    print("Welcome to the Gemini Pro 2.5 Agent!")
    print("Type 'exit' to quit.\n")
    while True:
        user_input = input("You: ")
        if user_input.lower() == "exit":
            print("Agent: Goodbye!")
            break
        # Process the user input and generate a response
        answer = ask_agent(user_input)
        print(f"Agent: {answer}\n")

if __name__ == "__main__":
    run_agent()

Code Explanation

This step-by-step example demonstrates how to integrate Gemini Pro 2.5 into your application to build an autonomous agent capable of handling user queries.

Final Thoughts

Gemini Pro 2.5 represents a significant leap forward in AI model capabilities, thanks to its advanced “thinking” mechanism, multimodal support, and extended context window. Whether you’re a developer looking to automate coding tasks, a researcher analyzing large datasets, or a content creator exploring new frontiers, this model offers unprecedented power and flexibility.

By following this guide—from installation to building a basic agent—you now have the foundation to experiment further. Leverage the official Gemini presentation and consult the Developer Documentation for additional insights and advanced use cases.

Until the next one,

Tega AdeyemiMarch 26, 2025