class documentation

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_caller Undocumented

Inherited from SimplePlugin:

Method configure_client See base class.
Method configure_replayer See base class.
Method configure_worker See base class.
Async Method connect_service_client See base class.
Method name See base class.
Async Method run_replayer See base class.
Async Method run_worker See base class.
Instance Variable activities Undocumented
Instance Variable data_converter Undocumented
Instance Variable interceptors Undocumented
Instance Variable nexus_service_handlers Undocumented
Instance Variable run_context Undocumented
Instance Variable workflow_failure_exception_types Undocumented
Instance Variable workflow_runner Undocumented
Instance Variable workflows Undocumented
Instance Variable _name Undocumented
def __init__(self, client: GeminiClient, extra_credentials: google.auth.credentials.Credentials | None = None, mcp_servers: dict[str, McpSessionFactory] | None = None, mcp_connection_idle_timeout: timedelta | None = None): (source)

Initialize the Gemini plugin.

Parameters
client:GeminiClientA fully configured genai.Client instance. All credential management, HTTP client configuration, etc. is the responsibility of the caller.
extra_credentials:google.auth.credentials.Credentials | NoneOptional 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.
mcp_servers:dict[str, McpSessionFactory] | NoneMCP 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.
mcp_connection_idle_timeout:timedelta | NoneHow long a worker-process MCP connection stays open while idle before being disconnected (the timer resets on each reuse). Defaults to 5 minutes.
_api_caller = (source)

Undocumented