class GoogleGenAIPlugin(SimplePlugin): (source)
Constructor: GoogleGenAIPlugin(client, extra_credentials, mcp_servers, mcp_connection_idle_timeout)
A Temporal Worker Plugin configured for the Google Gemini SDK.
Warning
This class is experimental and may change in future versions. Use with caution in production environments.
This plugin registers the gemini_api_client_async_request activity
using the provided genai.Client with real credentials. Workflows
construct a temporalio.contrib.google_genai.TemporalAsyncClient
to get an AsyncClient backed by a TemporalApiClient that routes all
API calls through this activity.
No credentials are passed to or from the workflow. Auth material never appears in Temporal's event history.
Example (Gemini Developer API):
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"]) plugin = GoogleGenAIPlugin(client)
Example (Vertex AI):
client = genai.Client(
vertexai=True, project="my-project", location="us-central1",
)
plugin = GoogleGenAIPlugin(client)
Example (with separate GCS credentials for file registration):
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"]) gcs_creds, _ = google.auth.default() plugin = GoogleGenAIPlugin(client, extra_credentials=gcs_creds)
| Method | __init__ |
Initialize the Gemini plugin. |
| Instance Variable | _api |
Undocumented |
Inherited from SimplePlugin:
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Async Method | connect |
See base class. |
| Method | name |
See base class. |
| Async Method | run |
See base class. |
| Async Method | run |
See base class. |
| Instance Variable | activities |
Undocumented |
| Instance Variable | data |
Undocumented |
| Instance Variable | interceptors |
Undocumented |
| Instance Variable | nexus |
Undocumented |
| Instance Variable | run |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflows |
Undocumented |
| Instance Variable | _name |
Undocumented |
GeminiClient, extra_credentials: google.auth.credentials.Credentials | None = None, mcp_servers: dict[ str, McpSessionFactory] | None = None, mcp_connection_idle_timeout: timedelta | None = None):
(source)
¶
temporalio.plugin.SimplePlugin.__init__Initialize the Gemini plugin.
| Parameters | |
client:GeminiClient | A fully configured genai.Client instance. All credential management, HTTP client configuration, etc. is the responsibility of the caller. |
extragoogle.auth.credentials.Credentials | None | Optional Google Cloud credentials used for operations that require explicit auth (e.g. files.register_files()). If not provided, the client's own credentials are used. |
mcpdict[ | MCP servers to expose to workflows, keyed by name. Each value is a factory returning an async context manager that yields a connected, initialized mcp.ClientSession. A workflow references a server by name with TemporalMcpClientSession(name) in a generate_content tools list; list_tools / call_tool then run as the {name}-list-tools / {name}-call-tool activities against a worker-side connection. Requires the mcp package. |
mcptimedelta | None | How long a worker-process MCP connection stays open while idle before being disconnected (the timer resets on each reuse). Defaults to 5 minutes. |