Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/agents/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ This method orchestrates the sub-agents using standard Python async/await and co
These are standard `LlmAgent` definitions, responsible for specific tasks. Their `output_key` parameter is crucial for placing results into the `session.state` where other agents or the custom orchestrator can access them.

```python
GEMINI_FLASH = "gemini-2.0-flash-exp" # Define model constant
GEMINI_FLASH = "gemini-2.0-flash" # Define model constant
--8<-- "examples/python/snippets/agents/custom-agent/storyflow_agent.py:llmagents"
```

Expand Down
8 changes: 4 additions & 4 deletions docs/agents/llm-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ First, you need to establish what the agent *is* and what it's *for*.

* **`description` (Optional, Recommended for Multi-Agent):** Provide a concise summary of the agent's capabilities. This description is primarily used by *other* LLM agents to determine if they should route a task to this agent. Make it specific enough to differentiate it from peers (e.g., "Handles inquiries about current billing statements," not just "Billing agent").

* **`model` (Required):** Specify the underlying LLM that will power this agent's reasoning. This is a string identifier like `"gemini-2.0-flash-exp"`. The choice of model impacts the agent's capabilities, cost, and performance. See the [Models](models.md) page for available options and considerations.
* **`model` (Required):** Specify the underlying LLM that will power this agent's reasoning. This is a string identifier like `"gemini-2.0-flash"`. The choice of model impacts the agent's capabilities, cost, and performance. See the [Models](models.md) page for available options and considerations.

```python
# Example: Defining the basic identity
capital_agent = LlmAgent(
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
name="capital_agent",
description="Answers user questions about the capital city of a given country."
# instruction and tools will be added next
Expand All @@ -46,7 +46,7 @@ The `instruction` parameter is arguably the most critical for shaping an `LlmAge
```python
# Example: Adding instructions
capital_agent = LlmAgent(
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
name="capital_agent",
description="Answers user questions about the capital city of a given country.",
instruction="""You are an agent that provides the capital city of a country.
Expand Down Expand Up @@ -84,7 +84,7 @@ def get_capital_city(country: str) -> str:

# Add the tool to the agent
capital_agent = LlmAgent(
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
name="capital_agent",
description="Answers user questions about the capital city of a given country.",
instruction="""You are an agent that provides the capital city of a country... (previous instruction text)""",
Expand Down
65 changes: 37 additions & 28 deletions docs/agents/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,55 @@ The following sections guide you through using these methods based on your needs

This is the most direct way to use Google's flagship models within ADK.

**Integration Method:** Pass the model's identifier string directly to the `model` parameter of `LlmAgent`.
**Integration Method:** Pass the model's identifier string directly to the `model` parameter of `LlmAgent` (or its alias, `Agent`).

**Backend Options & Setup:**

The `google-genai` library, used internally by ADK for Gemini, can connect through two backends:
The `google-genai` library, used internally by ADK for Gemini, can connect through either Google AI Studio or Vertex AI.

1. **Google AI Studio:**
* **Use Case:** Best for rapid prototyping and development.
* **Setup:** Typically requires an API key set as an environment variable:
!!!note "Model support for voice/video streaming"

```shell
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
export GOOGLE_GENAI_USE_VERTEXAI=FALSE
```
In order to use voice/video streaming in ADK, you will need to use Gemini models that support the Live API. You can find the **model ID(s)** that supports the Gemini Live API in the documentation:

- [Google AI Studio: Gemini Live API](https://ai.google.dev/gemini-api/docs/models#live-api)
- [Vertex AI: Gemini Live API](https://cloud.google.com/vertex-ai/generative-ai/docs/live-api)

### Google AI Studio

* **Use Case:** Google AI Studio is the easiest way to started with Gemini. All you need is the [API key](https://aistudio.google.com/app/apikey). Best for rapid prototyping and development.
* **Setup:** Typically requires an API key set as an environment variable:

```shell
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
export GOOGLE_GENAI_USE_VERTEXAI=FALSE
```

* **Models:** Find available models on the [Google AI for Developers site](https://ai.google.dev/gemini-api/docs/models).
* **Models:** Find all available models on the [Google AI for Developers site](https://ai.google.dev/gemini-api/docs/models).

2. **Vertex AI:**
* **Use Case:** Recommended for production applications, leveraging Google Cloud infrastructure.
* **Setup:**
* Authenticate using Application Default Credentials (ADC):
### Vertex AI

```shell
gcloud auth application-default login
```
* **Use Case:** Recommended for production applications, leveraging Google Cloud infrastructure. Gemini on Vertex AI supports enterprise-grade features, security, and compliance controls.
* **Setup:**
* Authenticate using Application Default Credentials (ADC):

* Set your Google Cloud project and location:
```shell
gcloud auth application-default login
```

```shell
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
export GOOGLE_CLOUD_LOCATION="YOUR_VERTEX_AI_LOCATION" # e.g., us-central1
```
* Set your Google Cloud project and location:

* Explicitly tell the library to use Vertex AI:
```shell
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
export GOOGLE_CLOUD_LOCATION="YOUR_VERTEX_AI_LOCATION" # e.g., us-central1
```

```shell
export GOOGLE_GENAI_USE_VERTEXAI=TRUE
```
* Explicitly tell the library to use Vertex AI:

```shell
export GOOGLE_GENAI_USE_VERTEXAI=TRUE
```

* **Models:** Find available model IDs in the [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models).
* **Models:** Find available model IDs in the [Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models).

**Example:**

Expand All @@ -62,7 +71,7 @@ from google.adk.agents import LlmAgent
# --- Example using a stable Gemini Flash model ---
agent_gemini_flash = LlmAgent(
# Use the latest stable Flash model identifier
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
name="gemini_flash_agent",
instruction="You are a fast and helpful Gemini assistant.",
# ... other agent parameters
Expand Down
12 changes: 6 additions & 6 deletions docs/agents/multi-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ The foundation for structuring multi-agent systems is the parent-child relations
from google.adk.agents import LlmAgent, BaseAgent

# Define individual agents
greeter = LlmAgent(name="Greeter", model="gemini-2.0-flash-exp")
greeter = LlmAgent(name="Greeter", model="gemini-2.0-flash")
task_doer = BaseAgent(name="TaskExecutor") # Custom non-LLM agent

# Create parent agent and assign children via sub_agents
coordinator = LlmAgent(
name="Coordinator",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
description="I coordinate greetings and tasks.",
sub_agents=[ # Assign sub_agents here
greeter,
Expand Down Expand Up @@ -196,7 +196,7 @@ image_tool = AgentTool(agent=image_agent) # Wrap the agent
# Parent agent uses the AgentTool
artist_agent = LlmAgent(
name="Artist",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
instruction="Create a prompt and use the ImageGen tool to generate the image.",
tools=[image_tool] # Include the AgentTool
)
Expand Down Expand Up @@ -229,7 +229,7 @@ support_agent = LlmAgent(name="Support", description="Handles technical support

coordinator = LlmAgent(
name="HelpDeskCoordinator",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
instruction="Route user requests: Use Billing agent for payment issues, Support agent for technical problems.",
description="Main help desk router.",
# allow_transfer=True is often implicit with sub_agents in AutoFlow
Expand Down Expand Up @@ -317,15 +317,15 @@ summarizer = LlmAgent(name="Summarizer", description="Summarizes text.")
# Mid-level agent combining tools
research_assistant = LlmAgent(
name="ResearchAssistant",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
description="Finds and summarizes information on a topic.",
tools=[AgentTool(agent=web_searcher), AgentTool(agent=summarizer)]
)

# High-level agent delegating research
report_writer = LlmAgent(
name="ReportWriter",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
instruction="Write a report on topic X. Use the ResearchAssistant to gather information.",
tools=[AgentTool(agent=research_assistant)]
# Alternatively, could use LLM Transfer if research_assistant is a sub_agent
Expand Down
16 changes: 13 additions & 3 deletions docs/get-started/quickstart-streaming.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# ADK Streaming Quickstart {#adk-streaming-quickstart}

With this quickstart, you'll learn to create a simple agent and use ADK Streaming to enable audio and video communication with it. We will install ADK, set up a basic "Google Search" agent, try running the agent with Streaming with `adk web` tool, and then explain how to build a simple asynchronous web app by yourself using ADK Streaming and [FastAPI](https://fastapi.tiangolo.com/).
With this quickstart, you'll learn to create a simple agent and use ADK Streaming to enable voice and video communication with it that is low-latency and bidirectional. We will install ADK, set up a basic "Google Search" agent, try running the agent with Streaming with `adk web` tool, and then explain how to build a simple asynchronous web app by yourself using ADK Streaming and [FastAPI](https://fastapi.tiangolo.com/).

**Note:** This guide assumes you have experience using a terminal in Windows, Mac, and Linux environments.

## Supported models for voice/video streaming {#supported-models}

In order to use voice/video streaming in ADK, you will need to use Gemini models that support the Live API. You can find the **model ID(s)** that supports the Gemini Live API in the documentation:

- [Google AI Studio: Gemini Live API](https://ai.google.dev/gemini-api/docs/models#live-api)
- [Vertex AI: Gemini Live API](https://cloud.google.com/vertex-ai/generative-ai/docs/live-api)

## 1. Setup Environment & Install ADK {#1.-setup-installation}

Create & Activate Virtual Environment (Recommended):
Expand Down Expand Up @@ -38,7 +45,9 @@ adk-streaming/ # Project folder

### agent.py

Copy-paste the following code block to the [`agent.py`](http://agent.py). Please note that ADK Streaming works with `gemini-2.0-flash-exp` model only.
Copy-paste the following code block to the [`agent.py`](http://agent.py).

For `model`, please double check the model ID as described earlier in the [Models section](#supported-models).

```py
from google.adk.agents import Agent
Expand All @@ -48,7 +57,8 @@ root_agent = Agent(
# A unique name for the agent.
name="basic_search_agent",
# The Large Language Model (LLM) that agent will use.
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash-live-001", # Google AI Studio
#model="gemini-2.0-flash-live-preview-04-09" # Vertex AI Studio
# A short description of the agent's purpose.
description="Agent to answer questions using Google Search.",
# Instructions to set the agent's behavior.
Expand Down
23 changes: 16 additions & 7 deletions docs/get-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,25 @@ There are multiple ways to interact with your agent:
![adk-web-dev-ui-function-call.png](../assets/adk-web-dev-ui-function-call.png)

**Step 5.** You can also enable your microphone and talk to your agent:

!!!note "Model support for voice/video streaming"

In order to use voice/video streaming in ADK, you will need to use Gemini models that support the Live API. You can find the **model ID(s)** that supports the Gemini Live API in the documentation:

- [Google AI Studio: Gemini Live API](https://ai.google.dev/gemini-api/docs/models#live-api)
- [Vertex AI: Gemini Live API](https://cloud.google.com/vertex-ai/generative-ai/docs/live-api)

You can then replace the `model` string in `root_agent` in the `agent.py` file you created earlier ([jump to section](#agentpy)). Your code should look something like:

```py
root_agent = Agent(
name="weather_time_agent",
model="replace-me-with-model-id", #e.g. gemini-2.0-flash-live-001
...
```

![adk-web-dev-ui-audio.png](../assets/adk-web-dev-ui-audio.png)

!!!note "Model support"

Currently only `gemini-2.0-flash-exp` supports talking to your agent via
audio/video, and can be used either with your API key from Google AI
Studio or via
[Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-live-api).

=== "Terminal (adk run)"

Run the following command, to chat with your Google Search agent.
Expand Down
5 changes: 2 additions & 3 deletions docs/get-started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "False"
### Define Model Constants for easier use

```
MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash"

MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash-exp"

# Note: Specific model names might change. Refer to LiteLLM/Provider documentation.
# Note: Specific model names might change. Refer to LiteLLM or the model provider's documentation.
MODEL_GPT_4O = "openai/gpt-4o"
MODEL_CLAUDE_SONNET = "anthropic/claude-3-sonnet-20240229"

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/responsible-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def validate_tool_params(

# Hypothetical Agent setup
root_agent = LlmAgent( # Use specific agent type
model='gemini-2.0-flash-exp',
model='gemini-2.0-flash',
name='root_agent',
instruction="...",
before_tool_callback=validate_tool_params, # Assign the callback
Expand Down
2 changes: 1 addition & 1 deletion docs/sessions/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This example demonstrates the basic flow using the `InMemory` services for simpl
# --- Constants ---
APP_NAME = "memory_example_app"
USER_ID = "mem_user"
MODEL = "gemini-2.0-flash-exp" # Use a valid model
MODEL = "gemini-2.0-flash" # Use a valid model

# --- Agent Definitions ---
# Agent 1: Simple agent to capture information
Expand Down
2 changes: 1 addition & 1 deletion docs/sessions/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ from google.genai.types import Content, Part
# Define agent with output_key
greeting_agent = LlmAgent(
name="Greeter",
model="gemini-2.0-flash-exp", # Use a valid model
model="gemini-2.0-flash", # Use a valid model
instruction="Generate a short, friendly greeting.",
output_key="last_greeting" # Save response to state['last_greeting']
)
Expand Down
6 changes: 3 additions & 3 deletions docs/tools/google-cloud-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Note: this tutorial includes an agent creation. If you already have an agent, yo
from .tools import sample_toolset

root_agent = LlmAgent(
model='gemini-2.0-flash-exp',
model='gemini-2.0-flash',
name='enterprise_assistant',
instruction='Help user, leverage the tools you have access to',
tools=sample_toolset.get_tools(),)
Expand Down Expand Up @@ -169,7 +169,7 @@ When running the agent, make sure to run adk web in project\_root\_folder
from .tools import connector_tool

root_agent = LlmAgent(
model='gemini-2.0-flash-exp',
model='gemini-2.0-flash',
name='connector_agent',
instruction="Help user, leverage the tools you have access to",
tools=connector_tool.get_tools(),
Expand Down Expand Up @@ -217,7 +217,7 @@ When running the agent, make sure to run adk web in project\_root\_folder
from .tools import integration_tool, connector_tool

root_agent = LlmAgent(
model='gemini-2.0-flash-exp',
model='gemini-2.0-flash',
name='integration_agent',
instruction="Help user, leverage the tools you have access to",
tools=integration_tool.get_tools(),
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/mcp-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async def get_agent_async():
tools, exit_stack = await get_tools_async()
print(f"Fetched {len(tools)} tools from MCP server.")
root_agent = LlmAgent(
model='gemini-2.0-flash-exp', # Adjust if needed
model='gemini-2.0-flash', # Adjust if needed
name='maps_assistant',
instruction='Help user with mapping and directions using available tools.',
tools=tools,
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/openapi-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Follow these steps to integrate an OpenAPI spec into your agent:

my_agent = LlmAgent(
name="api_interacting_agent",
model="gemini-2.0-flash-exp", # Or your preferred model
model="gemini-2.0-flash", # Or your preferred model
tools=api_tools, # Pass the list of generated tools
# ... other agent config ...
)
Expand Down
4 changes: 2 additions & 2 deletions docs/tools/third-party-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ADK provides the `LangchainTool` wrapper to integrate tools from the LangChain e
# Define the ADK agent, including the wrapped tool
my_agent = Agent(
name="langchain_tool_agent",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
description="Agent to answer questions using TavilySearch.",
instruction="I can answer your questions by searching the internet. Just ask me anything!",
tools=[adk_tavily_tool] # Add the wrapped tool here
Expand Down Expand Up @@ -125,7 +125,7 @@ ADK provides the `CrewaiTool` wrapper to integrate tools from the CrewAI library
# Define the ADK agent
my_agent = Agent(
name="crewai_search_agent",
model="gemini-2.0-flash-exp",
model="gemini-2.0-flash",
description="Agent to find recent news using the Serper search tool.",
instruction="I can find the latest news for you. What topic are you interested in?",
tools=[adk_serper_tool] # Add the wrapped tool here
Expand Down
Loading