Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Googleapis Python genai Interactions Resource

From Leeroopedia
Revision as of 12:49, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Googleapis_Python_genai_Interactions_Resource.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains REST_API, Interactions
Last Updated 2026-02-15 14:00 GMT

Overview

Concrete tool for managing Interactions API REST operations (create, get, delete, cancel) with streaming support.

Description

The InteractionsResource and AsyncInteractionsResource classes provide the REST resource layer for the Interactions API, supporting both synchronous and asynchronous creation, retrieval, deletion, and cancellation of interactions. Create and get operations support optional SSE streaming via Stream[InteractionSSEEvent].

Usage

Internal infrastructure. Accessed via the GeminiNextGenAPIClient.interactions property when using the Interactions API surface.

Code Reference

Source Location

Signature

class InteractionsResource(SyncAPIResource):
    def create(
        self,
        *,
        api_version: str | None = None,
        input: interaction_create_params.Input,
        config: interaction_create_params.Config | NotGiven = NOT_GIVEN,
        model: str | NotGiven = NOT_GIVEN,
        stream: bool | None = None,
    ) -> Interaction | Stream[InteractionSSEEvent]: ...

    def get(
        self,
        id: str,
        *,
        api_version: str | None = None,
        stream: bool | None = None,
    ) -> Interaction | Stream[InteractionSSEEvent]: ...

    def delete(self, id: str, *, api_version: str | None = None) -> object: ...
    def cancel(self, id: str, *, api_version: str | None = None) -> Interaction: ...

Import

from google.genai._interactions.resources.interactions import InteractionsResource

I/O Contract

Inputs

Name Type Required Description
input Input (TypedDict) Yes (create) Interaction input with turns
config Config (TypedDict) No Generation config, tools, system instructions
model str No Model ID (alternative to config.model)
stream bool No Enable SSE streaming response
id str Yes (get/delete/cancel) Interaction ID

Outputs

Name Type Description
create returns Interaction or Stream[InteractionSSEEvent] Created interaction or SSE stream
get returns Interaction or Stream[InteractionSSEEvent] Retrieved interaction or SSE stream
cancel returns Interaction Cancelled interaction state

Usage Examples

# Internal usage via the client
from google.genai._interactions._client import GeminiNextGenAPIClient

client = GeminiNextGenAPIClient(api_key="GEMINI_API_KEY")

# Create an interaction (streaming)
stream = client.interactions.create(
    input={"turns": [{"role": "user", "content": [{"text": "Hello"}]}]},
    model="gemini-2.0-flash",
    stream=True,
)
for event in stream:
    print(event)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment