# `Gemini.Utils.PollingHelpers`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/utils/polling_helpers.ex#L1)

Shared helper functions for polling operations.

These helpers are used by API modules that need to poll for
operation completion (batches, tunings, documents, etc.).

# `maybe_add`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/utils/polling_helpers.ex#L48)

```elixir
@spec maybe_add(keyword(), atom(), any()) :: keyword()
```

Conditionally adds a key-value pair to a keyword list if value is not nil.

Used for building optional query parameters.

## Examples

    iex> PollingHelpers.maybe_add([], :page_token, "abc123")
    [page_token: "abc123"]

    iex> PollingHelpers.maybe_add([], :page_token, nil)
    []

# `timed_out?`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/utils/polling_helpers.ex#L29)

```elixir
@spec timed_out?(integer(), integer()) :: boolean()
```

Check if a polling operation has timed out.

## Parameters

- `start_time` - The start time in monotonic milliseconds (from `System.monotonic_time(:millisecond)`)
- `timeout` - The timeout duration in milliseconds

## Examples

    iex> start = System.monotonic_time(:millisecond)
    iex> PollingHelpers.timed_out?(start, 5000)
    false

    iex> start = System.monotonic_time(:millisecond) - 6000
    iex> PollingHelpers.timed_out?(start, 5000)
    true

---

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