Interactions API (experimental).
Interactions are stateful, server-managed conversations that support:
- CRUD lifecycle (create/get/cancel/delete)
- background execution (
background: true) - SSE streaming with resumable
event_idtokens (last_event_idonget)
Streaming is enabled via stream: true (POST body on create, query param on get) and must
not rely on ?alt=sse.
Summary
Functions
Cancel a background interaction by id.
Create a new interaction.
Delete an interaction by id.
Get an interaction by id.
Poll an interaction until it reaches a terminal state.
Types
@type auth_strategy() :: :gemini | :vertex_ai
@type result(t) :: {:ok, t} | {:error, Gemini.Error.t() | term()}
Functions
@spec cancel( String.t(), keyword() ) :: result(Gemini.Types.Interactions.Interaction.t())
Cancel a background interaction by id.
@spec create( Gemini.Types.Interactions.Input.t(), keyword() ) :: result(Gemini.Types.Interactions.Interaction.t() | Enumerable.t())
Create a new interaction.
Required options
Provide either:
model: "..."(model-based), oragent: "..."(agent-based)
Streaming
stream: truereturns{:ok, stream}wherestreamyieldsInteractionSSEEventvariants.- Stream ends when the server sends
[DONE](independent ofinteraction.complete).
@spec delete( String.t(), keyword() ) :: :ok | {:error, Gemini.Error.t() | term()}
Delete an interaction by id.
@spec get( String.t(), keyword() ) :: result(Gemini.Types.Interactions.Interaction.t() | Enumerable.t())
Get an interaction by id.
If stream: true, returns an SSE stream. Resumption uses last_event_id.
@spec wait_for_completion( String.t(), keyword() ) :: result(Gemini.Types.Interactions.Interaction.t())
Poll an interaction until it reaches a terminal state.
Options:
:poll_interval_ms(default: 2000):timeout_ms(default: 300000):on_statusoptional callbackfn(Interaction.t()) -> any()- plus all
get/2options (auth, api_version, timeout, etc.)