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."}
* 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.
0 commit comments