Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      10 Top Node.js Development Companies for Enterprise-Scale Projects (2025-2026 Ranked & Reviewed)

      July 4, 2025

      12 Must-Know Cost Factors When Hiring Node.js Developers for Your Enterprise

      July 4, 2025

      Mirantis reveals Lens Prism, an AI copilot for operating Kubernetes clusters

      July 3, 2025

      Avoid these common platform engineering mistakes

      July 3, 2025

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025

      Xbox layoffs and game cuts wreak havoc on talented developers and the company’s future portfolio — Weekend discussion 💬

      July 5, 2025

      Microsoft plans to revamp Recall in Windows 11 with these new features

      July 5, 2025

      This 4K OLED monitor has stereo speakers that follow you — but it’s missing something “imPORTant”

      July 5, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Flaget – new small 5kB CLI argument parser

      July 5, 2025
      Recent

      Flaget – new small 5kB CLI argument parser

      July 5, 2025

      The dog days of JavaScript summer

      July 4, 2025

      Databricks Lakebase – Database Branching in Action

      July 4, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025
      Recent

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025

      Xbox layoffs and game cuts wreak havoc on talented developers and the company’s future portfolio — Weekend discussion 💬

      July 5, 2025

      Microsoft plans to revamp Recall in Windows 11 with these new features

      July 5, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Machine Learning»Step-by-Step Guide to Create an AI agent with Google ADK

    Step-by-Step Guide to Create an AI agent with Google ADK

    May 21, 2025

    Agent Development Kit (ADK) is an open-source Python framework that helps developers build, manage, and deploy multi-agent systems. It’s designed to be modular and flexible, making it easy to use for both simple and complex agent-based applications.

    In this tutorial, we’ll create a simple AI agent using ADK. The agent will have access to two tools:

    • get_company_overview
    • get_earnings

    Step 1: Setting up the dependencies

    Google API Key

    To use Google’s AI services, you’ll need an API key:

    • Visit https://aistudio.google.com/apikey
    • Sign in and generate your API key
    • Copy and store it securely — we’ll use it later in the tutorial.

    AlphaVantage API Key

    For accessing financial data, we’ll use the Alpha Vantage API:

    • Go to https://www.alphavantage.co/
    • Click “Get your free API key” or visit this direct link
    • Enter your email and follow the instructions
    • Once you receive your API key, copy and save it securely. We’ll use it to authenticate requests to financial endpoints.

    Python Libraries

    We only need one package:

    Copy CodeCopiedUse a different Browser
    pip install google-adk

    Step 2: Creating the Folder structure

    Set up your project folder with the following structure:

    Copy CodeCopiedUse a different Browser
    parent_folder/
    │
    └───multi_agent/
        ├── __init__.py
        ├── agent.py
        └── .env

    __init__.py

    Paste the following code into multi_agent/__init__.py:

    Copy CodeCopiedUse a different Browser
    from . import agent

    .env

    Create a .env file inside the multi_agent folder and paste the following:

    Copy CodeCopiedUse a different Browser
    GOOGLE_GENAI_USE_VERTEXAI=FALSE
    GOOGLE_API_KEY="<YOUR_GOOGLE_API_KEY>"
    ALPHA_VANTAGE_API_KEY="<YOUR_ALPHA_VANTAGE_KEY"

    Replace the placeholders with your actual API keys

    agent.py

    Paste the following code in the agent.py file:

    Copy CodeCopiedUse a different Browser
    from google.adk.agents import Agent
    import requests
    import os
    from typing import Optional
    
    ALPHA_VANTAGE_API_KEY = os.getenv("ALPHA_VANTAGE_API_KEY")
    
    def get_company_overview(symbol: str) -> dict:
        """
        Get comprehensive company information and financial metrics
       
        Args:
            symbol: Stock ticker symbol (e.g., IBM)
       
        Returns:
            dict: Company overview data or error
        """
        if not ALPHA_VANTAGE_API_KEY:
            return {"status": "error", "error": "Missing API key"}
       
        base_url = "https://www.alphavantage.co/query"
        params = {
            "function": "OVERVIEW",
            "symbol": symbol,
            "apikey": ALPHA_VANTAGE_API_KEY
        }
       
        try:
            response = requests.get(base_url, params=params)
            response.raise_for_status()
            data = response.json()
           
            if "Error Message" in data:
                return {"status": "error", "error": data["Error Message"]}
               
            # Filter key metrics
            key_metrics = {
                "Description": data.get("Description"),
                "Sector": data.get("Sector"),
                "MarketCap": data.get("MarketCapitalization"),
                "PERatio": data.get("PERatio"),
                "ProfitMargin": data.get("ProfitMargin"),
                "52WeekHigh": data.get("52WeekHigh"),
                "52WeekLow": data.get("52WeekLow")
            }
           
            return {
                "status": "success",
                "symbol": symbol,
                "overview": key_metrics
            }
           
        except Exception as e:
            return {"status": "error", "error": str(e)}
    
    def get_earnings(symbol: str) -> dict:
        """
        Get annual and quarterly earnings (EPS) data with analyst estimates and surprises
       
        Args:
            symbol: Stock ticker symbol (e.g., IBM)
       
        Returns:
            dict: Earnings data with estimates or error message
        """
        if not ALPHA_VANTAGE_API_KEY:
            return {"status": "error", "error": "Missing API key"}
       
        base_url = "https://www.alphavantage.co/query"
        params = {
            "function": "EARNINGS",
            "symbol": symbol,
            "apikey": ALPHA_VANTAGE_API_KEY
        }
       
        try:
            response = requests.get(base_url, params=params)
            response.raise_for_status()
            data = response.json()
           
            if "Error Message" in data:
                return {"status": "error", "error": data["Error Message"]}
               
            # Process annual and quarterly earnings
            annual_earnings = data.get("annualEarnings", [])[:5]  # Last 5 years
            quarterly_earnings = data.get("quarterlyEarnings", [])[:4]  # Last 4 quarters
           
            # Format surprise percentages
            for q in quarterly_earnings:
                if "surprisePercentage" in q:
                    q["surprise"] = f"{q['surprisePercentage']}%"
           
            return {
                "status": "success",
                "symbol": symbol,
                "annual_earnings": annual_earnings,
                "quarterly_earnings": quarterly_earnings,
                "metrics": {
                    "latest_eps": quarterly_earnings[0]["reportedEPS"] if quarterly_earnings else None
                }
            }
           
        except Exception as e:
            return {"status": "error", "error": str(e)}
       
       
    root_agent = Agent(
        name="Financial_analyst_agent",
        model="gemini-2.0-flash",
        description=(
            "Agent to give company overviews with key financial metrics."
        ),
        instruction=(
            "You are a helpful AI agent that provides company overviews and earnings information"
        ),
        tools=[get_company_overview, get_earnings],
    )

    In this script, we define a financial analysis agent using the Google Agent Development Kit (ADK). The agent is designed to answer user queries by accessing real-time financial data through the Alpha Vantage API. Specifically, it exposes two tools: get_company_overview and get_earnings. The get_company_overview function retrieves key company details such as sector, market capitalization, P/E ratio, and 52-week high/low values. The get_earnings function provides both annual and quarterly earnings data, including reported EPS and surprise percentages.To create the agent, we use the Agent class from the google.adk.agents module, giving it a name, a model (e.g., Gemini 2.0 Flash), a description, and an instruction prompt. The agent is then equipped with the two tools mentioned above, allowing it to respond to questions related to company financials.

    Step 3: Running the Agent

    To run the agent, navigate to the parent directory of your agent project (e.g. using cd ..)

    Copy CodeCopiedUse a different Browser
    parent_folder/      ← Navigate to this directory in your terminal
    │
    └───multi_agent/
        ├── __init__.py     # Initializes the module
        ├── agent.py        # Contains the agent logic and tools
        └── .env            # Stores your API keys securely

    After navigating, run the following code:

    Copy CodeCopiedUse a different Browser
    adk web

    Open the URL provided (usually http://localhost:8000 or http://127.0.0.1:8000) directly in your browser. You’ll see a simple chat interface where you can interact with your agent using the input textbox.

    Additionally, you can inspect each step of the agent’s reasoning by clicking on Actions. This allows you to view:

    • The tools being called
    • The inputs and outputs of each function
    • The responses generated by the language model

    GitHub Link

    You can find the entire code along with folder structure at this link: https://github.com/mohd-arham-islam/ADK-demo

    The post Step-by-Step Guide to Create an AI agent with Google ADK appeared first on MarkTechPost.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleSampling Without Data is Now Scalable: Meta AI Releases Adjoint Sampling for Reward-Driven Generative Modeling
    Next Article Generative AI in the Enterprise: Transforming Everything from Content to Code🚀

    Related Posts

    Machine Learning

    How to Evaluate Jailbreak Methods: A Case Study with the StrongREJECT Benchmark

    July 5, 2025
    Machine Learning

    Soup-of-Experts: Pretraining Specialist Models via Parameters Averaging

    July 4, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    How to Build a GraphQL API in Django

    Development

    The product design process

    Web Development

    CVE-2025-6953 – TOTOLINK A3002RU HTTP POST Request Handler Buffer Overflow Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Microsoft Edge is killing off Wallet feature name on Windows 11

    Operating Systems

    Highlights

    Hackers Exploited Ivanti Connect Secure 0-Day to Install DslogdRAT & Web Shell

    April 24, 2025

    Hackers Exploited Ivanti Connect Secure 0-Day to Install DslogdRAT & Web Shell

    Recent attacks against Japanese organizations have revealed sophisticated hackers exploiting a zero-day vulnerability in Ivanti Connect Secure VPN appliances.
    The attacks, occurring around December 20 …
    Read more

    Published Date:
    Apr 24, 2025 (3 hours, 42 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-22457

    CVE-2025-0282

    CVE-2025-5589 – StreamWeasels Kick Integration for WordPress Stored Cross-Site Scripting

    June 14, 2025

    Copilot on Windows 11 is gaining the ability to see and interact with your apps — but only when you ask it to

    April 4, 2025

    CVE-2025-20980 – Android libsavscmn Out-of-Bounds Write

    May 7, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.