FrameworksGoogle ADK

Google ADK

Use Nemo Router with Google's Agent Development Kit

Last updated

Google's Agent Development Kit (ADK) supports custom LLM backends via the OpenAI-compatible model wrapper. Point it at Nemo Router and guardrails, caching, and rate-limits auto-apply.

Installation

pip install google-adk openai

Setup

import os
from google.adk.models.lite_llm import LiteLlm
from google.adk.agents import LlmAgent

llm = LiteLlm(
    model="openai/claude-sonnet-4-20250514",
    api_base="https://api.nemorouter.ai/v1",
    api_key=os.environ["NEMOROUTER_API_KEY"],
)

agent = LlmAgent(
    name="research_agent",
    description="A research assistant powered by Nemo Router",
    model=llm,
)

Run an Agent

from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

session_service = InMemorySessionService()
runner = Runner(agent=agent, session_service=session_service)

response = runner.run(
    user_id="user-1",
    session_id="session-1",
    new_message="What are the latest advances in quantum computing?",
)

for event in response:
    print(event.content.parts[0].text)

Per-Request Overrides

Pass nemo_* fields via extra_body or additional_kwargs on the LiteLlm instance:

llm = LiteLlm(
    model="openai/gpt-4o",
    api_base="https://api.nemorouter.ai/v1",
    api_key=os.environ["NEMOROUTER_API_KEY"],
    extra_body={
        "nemo_prompt_template_id": "your-summarizer-id",
        "nemo_prompt_variables": {"language": "Spanish"},
        "nemo_guardrail_ids": ["guardrail-uuid-1"],
        "nemo_cache": False,
    },
)

Tools

Standard ADK tool wiring — guardrails check the user input before tools execute:

from google.adk.tools import FunctionTool

def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"72°F and sunny in {city}"

agent = LlmAgent(
    name="weather_agent",
    model=llm,
    tools=[FunctionTool(get_weather)],
)

Next Steps

Was this page helpful?