The site rendered one language under two names. Tab labels were split 137 `TypeScript` / 53 `Typescript`, with three pages carrying both spellings at once (custom-agents.md 7/7, patterns.md 1/7, function-tools.md 4/1), and the language-support badges were split 67/18 the same way. Because pymdownx.tabbed slugifies tab labels to lowercase, both variants rendered and linked fine, so no link check or build warning ever flagged it -- it was visible only to readers, as two names for one SDK. Every user-visible occurrence is normalized to `TypeScript`, plus the two inconsistencies that turned up while doing it. 80 changed lines, accounted for exactly: 53 tab label === "Typescript" -> === "TypeScript" 18 badge span lst-typescript">Typescript -> TypeScript 3 prose mention cloud-run.md, mcp-tools.md, workflows/patterns.md 2 api-reference/index.md card heading and link text 1 badge div attr title="...Python and Typescript." 1 mkdocs.yml nav Typescript ADK -> TypeScript ADK 1 code fence ```javascript -> ```typescript on a .ts include 1 artifacts/index.md closing summary sentence --- 80 The first six rows are pure casing: 78 lines that differ from their originals by nothing but `Typescript` -> `TypeScript`. The last two are not, and are the reason this is not a `sed`: llm-agents.md:872 fenced `--8<-- ".../capital_agent.ts"` as ```javascript. It was the only javascript-fenced `.ts` include in docs/ (the other 189 TypeScript fences are correct), and it cost that one snippet its TypeScript highlighting. artifacts/index.md:1084 closed the page by naming languages and got the list wrong. It described reaching the artifact methods "using Python's context objects or directly interacting with the `BaseArtifactService` in Java" -- a two-language enumeration at the end of a page that carries Python, TypeScript, Go, Java and Kotlin tabs (11/10/10/10/11), and one that contradicts :556, which correctly names four of them. The enumeration is dropped rather than extended: the sentence now describes the two ways to reach these methods -- through the context object, or through `BaseArtifactService` -- which is what the page actually teaches and does not rot when a sixth language is added. docs/api-reference/index.md is included even though the rest of docs/api-reference/ is generated output that must not be touched. That tree holds 3,140 generated HTML files and exactly one hand-authored page: this one. It is Markdown, it is the only api-reference entry mkdocs.yml lists as `.md` rather than `index.html` (:272, :441), it uses Material `grid cards` and `:fontawesome-*:` shortcodes, and it carries a `CONTRIBUTORS:` note citing issues #1716 and #1717. Its TypeScript card already said "TypeScript" twice in its body text while its heading and link text said "Typescript"; those two are now consistent with the body. No generated file is modified. Not in this change: the broken `SseConnectionParams` sample in mcp-tools.md (docs-ts/p6c-mcp-ts-sample) and the `@google/adk` example version bumps (docs-ts/p6b-example-versions). Only the casing of the prose line above that sample is touched here. Verified: `mkdocs build` exits 0 with an empty warning set on both main and this branch, and the two warning sets are identical. A rendered before/after diff of the whole site shows every `__tabbed_*` id, every tab radio id and every heading anchor unchanged. Zero `=== "Typescript"` and zero `lst-typescript">Typescript` remain anywhere in the repo. Co-authored-by: Amaad Martin <amaadmartin@google.com>
11 KiB
Google Gemini models for ADK agents
ADK supports the Google Gemini family of generative AI models that provide a powerful set of models with a wide range of features. ADK provides support for many Gemini features, including Code Execution, Google Search, Context caching, Computer use and the Interactions API.
Get started
The following code examples show a basic implementation for using Gemini models in your agents:
=== "Python"
```python
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-flash-latest",
name="gemini_flash_agent",
instruction="You are a fast and helpful Gemini assistant.",
# ... other agent parameters
)
```
=== "TypeScript"
```typescript
import {LlmAgent} from '@google/adk';
// --- Example #2: using a powerful Gemini Pro model with API Key in model ---
export const rootAgent = new LlmAgent({
name: 'hello_time_agent',
model: 'gemini-flash-latest',
description: 'Gemini flash agent',
instruction: `You are a fast and helpful Gemini assistant.`,
});
```
=== "Go"
```go
import (
"google.golang.org/adk/v2/agent/llmagent"
"google.golang.org/adk/v2/model/gemini"
"google.golang.org/genai"
)
--8<-- "examples/go/snippets/agents/models/models.go:gemini-example"
```
=== "Java"
```java
// --- Example #1: using a stable Gemini Flash model with ENV variables---
LlmAgent agentGeminiFlash =
LlmAgent.builder()
// Use the latest stable Flash model identifier
.model("gemini-flash-latest") // Set ENV variables to use this model
.name("gemini_flash_agent")
.instruction("You are a fast and helpful Gemini assistant.")
// ... other agent parameters
.build();
```
=== "Kotlin"
```kotlin
import com.google.adk.kt.agents.Instruction
import com.google.adk.kt.agents.LlmAgent
import com.google.adk.kt.models.Gemini
// --- Example using a stable Gemini Flash model ---
val agentGeminiFlash = LlmAgent(
// Use the latest stable Flash model identifier
name = "gemini_flash_agent",
model = Gemini(name = "gemini-flash-latest"),
instruction = Instruction("You are a fast and helpful Gemini assistant."),
// ... other agent parameters
)
```
??? note "Note: Gemini model selector gemini-flash-latest"
Most code examples in ADK documentation use `gemini-flash-latest` to select the
[latest available](https://ai.google.dev/gemini-api/docs/models#latest)
Gemini Flash version. However, if you access Gemini from a regional endpoint,
such as `us-central1`, this selection string may not work. In that case,
use a specific model version string from the
[Gemini models](https://ai.google.dev/gemini-api/docs/models) page or
Google Cloud [Gemini models](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models) list.
Gemini model authentication
When using an AI model through a service, such as the Gemini API or Gemini
Enterprise Agent Platform on Google Cloud, you must provide an API key or
authenticate with the service. The most direct way to provide this information
is to use environment variables or an .env file. The following examples show
the most common way to configure an agent for use with the Gemini API or Gemini
Enterprise Agent Platform.
=== "Gemini API"
```
# .env configuration file
GOOGLE_API_KEY="PASTE_YOUR_GEMINI_API_KEY_HERE"
```
=== "Google Cloud Agent Platform"
```
# .env configuration file
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_CLOUD_LOCATION=location-code # example: us-central1
GOOGLE_GENAI_USE_ENTERPRISE=True
```
For more details on connecting ADK agents to Google Cloud hosted models and services, including Gemini Enterprise Agent Platform, see the Connect to Google Cloud and Agent Platform guide.
Voice and video streaming support
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 support the Gemini Live API in the documentation:
Gemini Interactions API
The Gemini Interactions API
is an alternative to the generateContent inference API, which provides
stateful conversation capabilities, allowing you to chain interactions using a
previous_interaction_id instead of sending the full conversation history with
each request. Using this feature can be more efficient for long conversations.
You can enable the Interactions API by setting the use_interactions_api=True
parameter in the Gemini model configuration, as shown in the following code
snippet:
=== "Python"
```python
from google.adk.agents.llm_agent import Agent
from google.adk.models.google_llm import Gemini
from google.adk.tools.google_search_tool import GoogleSearchTool
root_agent = Agent(
model=Gemini(
model="gemini-flash-latest",
use_interactions_api=True, # Enable Interactions API
),
name="interactions_test_agent",
tools=[
GoogleSearchTool(bypass_multi_tools_limit=True), # Converted to function tool
get_current_weather, # Custom function tool
],
)
```
For a complete code sample, see the Interactions API sample.
Known limitations
The Interactions API does not support mixing custom function calling tools with
built-in tools, such as the
Google Search,
tool, within the same agent. You can work around this limitation by configuring the
built-in tool to operate as a custom tool using the bypass_multi_tools_limit
parameter:
=== "Python"
```python
# Use bypass_multi_tools_limit=True to convert google_search to a function tool
GoogleSearchTool(bypass_multi_tools_limit=True)
```
In this example, this option converts the built-in google_search to a function
calling tool (via GoogleSearchAgentTool), which allows it to work alongside
custom function tools.
Troubleshooting
Error Code 429 - RESOURCE_EXHAUSTED
This error usually happens if the number of your requests exceeds the capacity allocated to process requests.
To mitigate this, you can do one of the following:
-
Request higher quota limits for the model you are trying to use.
-
Enable client-side retries. Retries allow the client to automatically retry the request after a delay, which can help if the quota issue is temporary.
There are two ways you can set retry options:
Option 1: Set retry options on the Agent as a part of
generate_content_config.You would use this option if you are passing the model as a name string and letting ADK create the model adapter for you.
=== "Python"
```python from google.genai import types # ... root_agent = Agent( model='gemini-flash-latest', # ... generate_content_config=types.GenerateContentConfig( # ... http_options=types.HttpOptions( # ... retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2), # ... ), # ... ), ) ```=== "Java"
```java import com.google.adk.agents.LlmAgent; import com.google.genai.types.GenerateContentConfig; import com.google.genai.types.HttpOptions; import com.google.genai.types.HttpRetryOptions; // ... LlmAgent rootAgent = LlmAgent.builder() .model("gemini-flash-latest") // ... .generateContentConfig(GenerateContentConfig.builder() // ... .httpOptions(HttpOptions.builder() // ... .retryOptions(HttpRetryOptions.builder().initialDelay(1.0).attempts(2).build()) // ... .build()) // ... .build()) .build(); ```Option 2: Retry options on this model adapter.
You would use this option if you were instantiating the instance of adapter by yourself.
=== "Python"
```python from google.genai import types # ... agent = Agent( model=Gemini( retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2), ) ) ```=== "Java"
```java import com.google.adk.agents.LlmAgent; import com.google.adk.models.Gemini; import com.google.genai.Client; import com.google.genai.types.HttpOptions; import com.google.genai.types.HttpRetryOptions; // ... LlmAgent agent = LlmAgent.builder() .model(Gemini.builder() .modelName("gemini-flash-latest") .apiClient(Client.builder() .httpOptions(HttpOptions.builder() .retryOptions(HttpRetryOptions.builder().initialDelay(1.0).attempts(2).build()) .build()) .build()) .build()) .build(); ```=== "Kotlin"
In Kotlin, you can achieve this by creating the `Client` instance yourself and passing it to the `Gemini` constructor. ```kotlin import com.google.adk.kt.agents.LlmAgent import com.google.adk.kt.models.Gemini import com.google.genai.Client import com.google.genai.types.HttpOptions import com.google.genai.types.HttpRetryOptions val client = Client.builder() .apiKey("YOUR_API_KEY") .httpOptions(HttpOptions.builder() .retryOptions(HttpRetryOptions.builder().initialDelay(1.0).attempts(2).build()) .build()) .build() val model = Gemini(client = client, name = "gemini-flash-latest") val agent = LlmAgent( name = "my_agent", model = model // ... ) ```