module documentation

Temporal activity that executes Gemini SDK API calls with real credentials.

The TemporalApiClient in the workflow dispatches calls here. This activity holds a user-provided genai.Client and forwards structured requests. Credentials are fetched/refreshed only within the activity — they never appear in workflow event history.

Class GeminiApiCaller Wraps a genai.Client and exposes Temporal activities for SDK calls.
Function _classify_api_error Map a Gemini APIError to an ApplicationError Temporal can act on.
Async Function _drain_interaction_stream Collect every SSE event from an interaction stream, heartbeating per event.
Function _resolve_http_options Reconstruct HttpOptions from serializable overrides, or None.
Constant _RETRYABLE_HTTP_STATUS Undocumented
def _classify_api_error(err: genai_errors.APIError) -> ApplicationError: (source)

Map a Gemini APIError to an ApplicationError Temporal can act on.

Transient statuses (timeouts, rate limits, 5xx) stay retryable so the activity's retry policy applies; everything else (e.g. 4xx client errors) is marked non-retryable so the workflow fails fast instead of retrying a request that cannot succeed.

async def _drain_interaction_stream(stream: Any) -> _GeminiInteractionStreamedResponse: (source)

Collect every SSE event from an interaction stream, heartbeating per event.

stream is the SDK's async streaming response; its concrete class is not a stable public name, so it is typed structurally — only async with / async for / event.model_dump(...) are used.

def _resolve_http_options(overrides: Any) -> HttpOptions | None: (source)

Reconstruct HttpOptions from serializable overrides, or None.

_RETRYABLE_HTTP_STATUS = (source)

Undocumented

Value
frozenset(set([408, 429, 500, 502, 503, 504]))