# `Gemini.Types.Live.SlidingWindow`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.13.0/lib/gemini/types/live/sliding_window.ex#L1)

Sliding window context compression configuration.

The SlidingWindow method operates by discarding content at the beginning
of the context window. The resulting context will always begin at the start
of a USER role turn. System instructions and any prefix turns will always
remain at the beginning of the result.

## Fields

- `target_tokens` - Target number of tokens to keep. Default is trigger_tokens/2

## Example

    %SlidingWindow{target_tokens: 8000}

# `t`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.13.0/lib/gemini/types/live/sliding_window.ex#L19)

```elixir
@type t() :: %Gemini.Types.Live.SlidingWindow{target_tokens: integer() | nil}
```

# `from_api`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.13.0/lib/gemini/types/live/sliding_window.ex#L60)

```elixir
@spec from_api(map() | nil) :: t() | nil
```

Parses from API response.

# `new`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.13.0/lib/gemini/types/live/sliding_window.ex#L29)

```elixir
@spec new(keyword()) :: t()
```

Creates a new SlidingWindow configuration.

# `to_api`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.13.0/lib/gemini/types/live/sliding_window.ex#L42)

```elixir
@spec to_api(t() | map() | nil) :: map() | nil
```

Converts to API format (camelCase).

Accepts structs, maps with atom keys, or maps with string keys.
Uses fetch_value to properly preserve falsey values like 0 or false.

---

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