The Interactions API is currently in Beta. Features and API signatures may change.
Method
Input
required
The inputs for the interaction. Can be:
- A string message
- A list of content parts (text, images, etc.)
- Structured input object
string
required
The name of the model to use. Example:
gemini-2.0-flash-expboolean
default:"false"
Whether to stream the response incrementally. When
true, returns a Stream[InteractionSSEEvent] instead of Interaction.boolean
default:"false"
Whether to run the interaction in the background. Background interactions can be retrieved later using the interaction ID.
GenerationConfig
Configuration parameters for the model:
string
System instruction to guide the model’s behavior
list[Tool]
A list of tool declarations the model may call during interaction
boolean
default:"false"
Whether to store the interaction for later retrieval. Stored interactions can be accessed using their ID.
string
The ID of a previous interaction to provide context
object
JSON schema for structured output
string
MIME type for the response (e.g.,
application/json)list[string]
Requested modalities:
text, image, or audioResponse
Non-Streaming Response
string
Unique identifier for the interaction
string
The model used for the interaction
Input
The input provided (if
include_input was true)Output
The generated output from the model
string
State of the interaction:
PENDING, RUNNING, COMPLETED, FAILEDstring
Timestamp when the interaction was created
object
Token usage information
Streaming Response
Whenstream=True, returns a Stream[InteractionSSEEvent] with incremental updates.
Usage
Basic Interaction
Streaming Interaction
Background Interaction with Polling
With Previous Context
With Generation Config
With Tools
Structured Output
Notes
- Interactions are currently Beta and available through the Gemini API
- Stored interactions can be retrieved using interactions.get
- Background interactions are useful for long-running operations
- Streaming provides real-time incremental responses
- Previous interaction context helps maintain conversation history
Error Handling
See Also
- interactions.get - Retrieve interaction details