You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agents/models.md
+70-41Lines changed: 70 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,17 +28,18 @@ The following sections guide you through using these methods based on your needs
28
28
29
29
## Using Google Gemini Models
30
30
31
-
This is the most direct way to use Google's flagship models within ADK.
31
+
This section covers authenticating with Google's Gemini models, either through Google AI Studio for rapid development or Google Cloud Vertex AI for enterprise applications. This is the most direct way to use Google's flagship models within ADK.
32
+
33
+
**Integration Method:** Once you are authenticated using one of the below methods, you can pass the model's identifier string directly to the
34
+
`model` parameter of `LlmAgent`.
32
35
33
-
**Integration Method:** Pass the model's identifier string directly to the
34
-
`model` parameter of `LlmAgent` (or its alias, `Agent`).
35
36
36
-
**Backend Options & Setup:**
37
+
!!!tip
37
38
38
-
The `google-genai` library, used internally by ADK for Gemini, can connect
39
-
through either Google AI Studio or Vertex AI.
39
+
The `google-genai` library, used internally by ADK for Gemini models, can connect
40
+
through either Google AI Studio or Vertex AI.
40
41
41
-
!!!note "Model support for voice/video streaming"
42
+
**Model support for voice/video streaming**
42
43
43
44
In order to use voice/video streaming in ADK, you will need to use Gemini
44
45
models that support the Live API. You can find the **model ID(s)** that
@@ -49,51 +50,76 @@ through either Google AI Studio or Vertex AI.
49
50
50
51
### Google AI Studio
51
52
52
-
***Use Case:** Google AI Studio is the easiest way to get started with Gemini.
53
-
All you need is the [API key](https://aistudio.google.com/app/apikey). Best
54
-
for rapid prototyping and development.
55
-
***Setup:** Typically requires an API key:
56
-
* Set as an environment variable or
57
-
* Passed during the model initialization via the `Client` (see example below)
53
+
This is the simplest method and is recommended for getting started quickly.
58
54
59
-
```shell
60
-
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
61
-
export GOOGLE_GENAI_USE_VERTEXAI=FALSE
62
-
```
55
+
***Authentication Method:** API Key
56
+
***Setup:**
57
+
1.**Get an API key:** Obtain your key from [Google AI Studio](https://aistudio.google.com/apikey).
58
+
2.**Set environment variables:** Create a `.env` file (Python) or `.properties` (Java) in your project's root directory and add the following lines. ADK will automatically load this file.
59
+
60
+
```shell
61
+
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
62
+
export GOOGLE_GENAI_USE_VERTEXAI=FALSE
63
+
```
64
+
65
+
(or)
66
+
67
+
Pass these variables during the model initialization via the `Client` (see example below).
63
68
64
69
***Models:** Find all available models on the
65
70
[Google AI for Developers site](https://ai.google.dev/gemini-api/docs/models).
66
71
67
-
### Vertex AI
72
+
### Google Cloud Vertex AI
68
73
69
-
***Use Case:** Recommended for production applications, leveraging Google Cloud
70
-
infrastructure. Gemini on Vertex AI supports enterprise-grade features,
71
-
security, and compliance controls.
72
-
***Setup:**
73
-
* Authenticate using Application Default Credentials (ADC):
74
+
For scalable and production-oriented use cases, Vertex AI is the recommended platform. Gemini on Vertex AI supports enterprise-grade features, security, and compliance controls. Based on your development environment and usecase, *choose one of the below methods to authenticate*.
74
75
75
-
```shell
76
-
gcloud auth application-default login
77
-
```
76
+
**Pre-requisites:** A Google Cloud Project with [Vertex AI enabled](https://console.cloud.google.com/apis/enableflow;apiid=aiplatform.googleapis.com).
78
77
79
-
* Configure these variables either as environment variables or by providing them directly when initializing the Model.
[Vertex AI documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models).
96
99
100
+
### **Method B: Vertex AI Express Mode**
101
+
[Vertex AI Express Mode](https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview) offers a simplified, API-key-based setup for rapid prototyping.
102
+
103
+
1. **Sign up for Express Mode** to get your API key.
### **Method C: Service Account (for Production & Automation)**
111
+
112
+
For deployed applications, a service account is the standard method.
113
+
114
+
1. [**Create a Service Account**](https://cloud.google.com/iam/docs/service-accounts-create#console) and grant it the `Vertex AI User` role.
115
+
2. **Provide credentials to your application:**
116
+
***On Google Cloud:** If you are running the agent in Cloud Run, GKE, VM or other Google Cloud services, the environment can automatically provide the service account credentials. You don't have to create a key file.
117
+
* **Elsewhere:** Create a [service account key file](https://cloud.google.com/iam/docs/keys-create-delete#console) and point to it with an environment variable:
Service account credentials or API keys are powerful credentials. Never expose them publicly. Use a secret manager like [Google Secret Manager](https://cloud.google.com/secret-manager) to store and access them securely in production.
188
+
160
189
## Using Anthropic models
161
190
162
191
{ title="This feature is currently available for Java. Python support for direct Anthropic API (non-Vertex) is via LiteLLM."}
This step may take several minutes to finish. Each deployed agent has a unique identifier. You can run the following command to get the resource_name identifier for your deployed agent:
151
+
This step may take several minutes to finish.
152
+
153
+
You can check and monitor the deployment of your ADK agent on the [Agent Engine UI](https://console.cloud.google.com/vertex-ai/agents/agent-engines) on Google Cloud.
154
+
155
+
Each deployed agent has a unique identifier. You can run the following command to get the resource_name identifier for your deployed agent:
152
156
153
157
```python
154
158
remote_app.resource_name
155
159
```
156
160
157
161
The response should look like the following string:
* Authenticate to Google Cloud, from the terminal by running
168
-
`gcloud auth login`.
169
-
* [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
170
-
2. When using Python, open the **`.env`** file located inside (`multi_tool_agent/`). Copy-paste
164
+
1. Set up a [Google Cloud project](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#setup-gcp) and [enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
165
+
2. Set up the [gcloud CLI](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#setup-local).
166
+
3. Authenticate to Google Cloud from the terminal by running `gcloud auth login`.
167
+
4. When using Python, open the **`.env`** file located inside (`multi_tool_agent/`). Copy-paste
171
168
the following code and update the project ID and location.
172
169
173
170
```env title="multi_tool_agent/.env"
@@ -222,6 +219,17 @@ agent will be unable to function.
222
219
There are multiple ways to interact with your agent:
223
220
224
221
=== "Dev UI (adk web)"
222
+
223
+
!!! success "Authentication Setup for Vertex AI Users"
224
+
If you selected **"Gemini - Google Cloud Vertex AI"** in the previous step, you must authenticate with Google Cloud before launching the dev UI.
225
+
226
+
Run this command and follow the prompts:
227
+
```bash
228
+
gcloud auth application-default login
229
+
```
230
+
231
+
**Note:** Skip this step if you're using "Gemini - Google AI Studio".
232
+
225
233
Run the following command to launch the **dev UI**.
[Weave by Weights & Biases (WandB)](https://weave-docs.wandb.ai/) provides a powerful platform for logging and visualizing model calls. By integrating Google ADK with Weave, you can track and analyze your agent's performance and behavior using OpenTelemetry (OTEL) traces.
4
+
5
+
## Prerequisites
6
+
7
+
1. Sign up for an account at [WandB](https://wandb.ai).
8
+
9
+
2. Obtain your API key from [WandB Authorize](https://wandb.ai/authorize).
10
+
11
+
3. Configure your environment with the required API keys:
-**Environment Variables**: Ensure your environment variables are correctly set for both WandB and Google API keys.
115
+
-**Project Configuration**: Replace `<your-entity>/<your-project>` with your actual WandB entity and project name.
116
+
-**Entity Name**: You can find your entity name by visiting your [WandB dashboard](https://wandb.ai/home) and checking the **Teams** field in the left sidebar.
117
+
-**Tracer Provider**: It's critical to set the global tracer provider before using any ADK components to ensure proper tracing.
118
+
119
+
By following these steps, you can effectively integrate Google ADK with Weave, enabling comprehensive logging and visualization of your AI agents' model calls, tool invocations, and reasoning processes.
120
+
121
+
## Resources
122
+
123
+
-**[Send OpenTelemetry Traces to Weave](https://weave-docs.wandb.ai/guides/tracking/otel)** - Comprehensive guide on configuring OTEL with Weave, including authentication and advanced configuration options.
124
+
125
+
-**[Navigate the Trace View](https://weave-docs.wandb.ai/guides/tracking/trace-tree)** - Learn how to effectively analyze and debug your traces in the Weave UI, including understanding trace hierarchies and span details.
126
+
127
+
-**[Weave Integrations](https://weave-docs.wandb.ai/guides/integrations/)** - Explore other framework integrations and see how Weave can work with your entire AI stack.
0 commit comments