[Python] ( A2A )Missing key inputs argument! To use the Google AI API, provide (api_key)...

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    Got it! Below is your Stack Overflow question in plaintext, using proper Markdown formatting with triple backticks for code blocks, single backticks for inline code, and 8-space indentation inside lists where needed.

    Title: Using Google ADK A2A Protocol with Multiple Remote Agents — Missing key inputs argument! error in Orchestrator

    Body:

    I’m using Google ADK (Agent Development Kit) with the A2A (Agent-to-Agent) protocol to build a multi-agent system. My setup includes:

    ‍ FruitSeller Agent (on port 8001)

    VegetableSeller Agent (on port 8002)

    Orchestrator Agent (communicates with both)

    GitHub Source: Full code is here

    Screenshot:

    Fruit Seller Agent (Similar for Vegetable Seller)

    from google.adk.a2a.utils.agent_to_a2a import to_a2a
    from google.adk.agents import Agent

    inventory = {
    "apple": {"price": 20, "stock": 10},
    "banana": {"price": 10, "stock": 10},
    "orange": {"price": 15, "stock": 10}
    }

    def show_fruits() -> str:
    return ",".join([f"{fruit.capitalize()}: ₹{data['price']}" for fruit, data in inventory.items()])

    def buy_fruit(fruit: str, quantity: int) -> str:
    if fruit not in inventory:
    return f"Sorry, {fruit} is not available."
    if inventory[fruit]["stock"] < quantity:
    return f"Sorry, only {inventory[fruit]['stock']} in stock."
    inventory[fruit]["stock"] -= quantity
    return f"Bought {quantity} {fruit} for ₹{inventory[fruit]['price'] * quantity}"

    root_agent = Agent(
    name="fruit_seller_agent",
    description="Sells fruits",
    model="gemini-2.0-flash",
    instruction="You can ask about fruits, prices, or buy them.",
    tools=[show_fruits, buy_fruit]
    )

    a2a_app = to_a2a(root_agent, port=8001)



    Orchestrator Agent

    from google.adk.agents import Agent
    from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
    from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH
    from dotenv import load_dotenv
    load_dotenv()

    fruit_agent = RemoteA2aAgent(
    name="fruit_agent",
    description="Handles fruit sales",
    agent_card=f"http://127.0.0.1:8001/{AGENT_CARD_WELL_KNOWN_PATH}",
    )

    vegetable_agent = RemoteA2aAgent(
    name="vegetable_agent",
    description="Handles vegetable sales",
    agent_card=f"http://127.0.0.1:8002/{AGENT_CARD_WELL_KNOWN_PATH}",
    )

    root_agent = Agent(
    model="gemini-2.0-flash",
    name="orchestrator_agent",
    description="Delegates fruit and vegetable sales",
    instruction="""
    If user asks for fruit -> use fruit_agent.
    If user asks for vegetable -> use vegetable_agent.
    If both -> do both sequentially.
    """,
    sub_agents=[fruit_agent, vegetable_agent],
    )



    ⚠️ Error Observed When I run both agents and query the orchestrator like:

    "What fruits do you have?"

    I get the following error:

    Missing key inputs argument! To use the Google AI API, provide (api_key) arguments.
    To use the Google Cloud API, provide (vertexai, project & location) arguments.

    ```[![adkweb][1]][1]
    ✅ What Works
    Both agents (fruit_seller, vegetable_seller) work fine individually.


    [1]: https://i.sstatic.net/0kB5iA3C.png

    Continue reading...

Compartilhe esta Página