# `Alloy.Provider.SSE`
[🔗](https://github.com/alloy-ex/alloy/blob/v0.10.1/lib/alloy/provider/sse.ex#L1)

Shared SSE (Server-Sent Events) framing utilities.

Handles the transport-level concerns that are identical across all
providers using SSE streaming: byte buffering, event boundary
splitting, and field extraction.

Provider-specific event handling is NOT in this module — each provider
(or shared parser like `Alloy.Provider.OpenAIStream`) pattern-matches
on the parsed events returned here.

# `sse_event`

```elixir
@type sse_event() :: %{event: String.t() | nil, data: String.t()}
```

# `process_chunk`

```elixir
@spec process_chunk(String.t(), String.t()) :: {[sse_event()], String.t()}
```

Process a raw chunk of bytes against a buffer.

Returns `{complete_events, remaining_buffer}` where each event
is a map with `:event` (may be nil) and `:data` keys.

# `req_stream_handler`

```elixir
@spec req_stream_handler(map(), (map(), sse_event() -&gt; map())) :: ({:data, String.t()},
                                                             {term(), term()} -&gt;
                                                               {:cont,
                                                                {term(), term()}})
```

Build a Req `into:` stream handler that accumulates SSE events.

The `handle_event` function receives `(accumulator, sse_event)` and
returns the updated accumulator. The accumulator must contain a
`:buffer` key (string) for SSE framing state.

The accumulator is stored in `resp.private.sse_acc`.

---

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