Gemini API¶
Gemini Minions inherit google.adk.Agent, create isolated in-memory sessions, and return native
ADK events.
gemini
¶
Assembly: minions Filename: gemini.py Author: Terry D. Eppler Created: 09-05-2026
Last Modified By: Terry D. Eppler Last Modified On: 09-06-2026
gemini.py
Copyright © 2026 Terry D. Eppler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov
Minion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Agent
Provider-native Gemini workflow agent.
Initialize a Gemini Minion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
Gemini model identifier. |
required |
instructions
|
str
|
System instructions for the agent. |
required |
tools
|
Sequence[GeminiTool] | None
|
Optional Google ADK tools. |
None
|
max_turns
|
int
|
Maximum model calls per execution. |
10
|
name
|
str | None
|
Optional name overriding the implementation default. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Configuration is stored on the provider-native agent. |
Source code in gemini.py
normalize_name(name: str) -> str
staticmethod
¶
Create a valid Google ADK agent identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable agent name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Normalized ADK identifier. |
Source code in gemini.py
create_runner() -> Runner
¶
Create an isolated provider runner.
Returns:
| Name | Type | Description |
|---|---|---|
Runner |
Runner
|
Google ADK runner with automatic session creation. |
Source code in gemini.py
create_content(prompt: str) -> types.Content
¶
Create provider-native user content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User input for the workflow. |
required |
Returns:
| Type | Description |
|---|---|
Content
|
types.Content: Google Gen AI content object. |
Source code in gemini.py
select_result(events: Sequence[Event]) -> Event
¶
Select the final event from an invocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[Event]
|
Events emitted by Google ADK. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Event |
Event
|
Final-response event or the last emitted event. |
Source code in gemini.py
run(prompt: str) -> Event
¶
Execute the complete Gemini workflow synchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User input for the workflow. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Event |
Event
|
Final provider-native event. |
Source code in gemini.py
run_async(prompt: str) -> Event
async
¶
Execute the complete Gemini workflow asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User input for the workflow. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Event |
Event
|
Final provider-native event. |
Source code in gemini.py
stream(prompt: str) -> AsyncIterator[Event]
async
¶
Stream a complete Gemini workflow with automatic tool handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User input for the workflow. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
Event |
AsyncIterator[Event]
|
Provider-native streamed ADK event. |
Source code in gemini.py
DataMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for data workflows.
Source code in gemini.py
GovernanceMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for governance workflows.
Source code in gemini.py
ResearchMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for research workflows.
Source code in gemini.py
CodingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for software workflows.
Source code in gemini.py
WritingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for writing workflows.
Source code in gemini.py
PlanningMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for planning workflows.
Source code in gemini.py
ComplianceMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for compliance, legal, and budget workflows.
Source code in gemini.py
BusinessMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for business, finance, and marketing workflows.
Source code in gemini.py
ImageGenerationMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for image-generation workflows.
Source code in gemini.py
ImageAnalysisMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for image-analysis workflows.
Source code in gemini.py
ImageEditingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for image-editing workflows.
Source code in gemini.py
TranslationMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for translation workflows.
Source code in gemini.py
TranscriptionMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for transcription workflows.
Source code in gemini.py
SpeechMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
¶
Bases: Minion
Gemini Minion specialized for speech workflows.