# `Gemini.APIs.Interactions`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L1)

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`.

# `auth_strategy`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L33)

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

# `result`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L34)

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

# `cancel`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L100)

```elixir
@spec cancel(
  String.t(),
  keyword()
) :: result(Gemini.Types.Interactions.Interaction.t())
```

Cancel a background interaction by id.

# `create`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L55)

```elixir
@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), 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`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L114)

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

Delete an interaction by id.

# `get`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L79)

```elixir
@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`.

# `wait_for_completion`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/apis/interactions.ex#L135)

```elixir
@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.)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
