Gemini.APIs.Interactions (GeminiEx v0.9.0)

Copy Markdown View Source

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_id tokens (last_event_id on get)

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

auth_strategy()

@type auth_strategy() :: :gemini | :vertex_ai

result(t)

@type result(t) :: {:ok, t} | {:error, Gemini.Error.t() | term()}

Functions

cancel(id, opts \\ [])

Cancel a background interaction by id.

create(input, opts \\ [])

Create a new interaction.

Required options

Provide either:

  • model: "..." (model-based), or
  • agent: "..." (agent-based)

Streaming

  • stream: true returns {:ok, stream} where stream yields InteractionSSEEvent variants.
  • Stream ends when the server sends [DONE] (independent of interaction.complete).

delete(id, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: :ok | {:error, Gemini.Error.t() | term()}

Delete an interaction by id.

get(id, opts \\ [])

Get an interaction by id.

If stream: true, returns an SSE stream. Resumption uses last_event_id.

wait_for_completion(id, opts \\ [])

@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_status optional callback fn(Interaction.t()) -> any()
  • plus all get/2 options (auth, api_version, timeout, etc.)