# `HuggingfaceClient.SSE`
[🔗](https://github.com/huggingface/huggingface_client/blob/v0.1.0/lib/huggingface_client/sse.ex#L1)

Server-Sent Events (SSE) stream parser following the W3C EventSource specification.

Handles arbitrary chunk boundaries, LF / CR / CRLF line endings, multi-line `data:`
fields, the `[DONE]` sentinel used by OpenAI-compatible APIs, and JSON decoding.

# `event`

```elixir
@type event() :: %{
  :data =&gt; String.t(),
  :id =&gt; String.t(),
  :event =&gt; String.t(),
  optional(:retry) =&gt; integer() | nil
}
```

# `parse_stream`

```elixir
@spec parse_stream(Enumerable.t()) :: Enumerable.t()
```

Parses a stream (enumerable) of binary chunks into a lazy stream of SSE event maps.

Filters out `[DONE]` sentinels and events with empty `data` fields.

# `parse_stream_json`

```elixir
@spec parse_stream_json(Enumerable.t()) :: Enumerable.t()
```

Like `parse_stream/1` but JSON-decodes each event's `data` field.

* Raises `ProviderApiError` if the decoded map contains a top-level `"error"` key.
* Logs a warning and skips events whose `data` cannot be decoded as JSON.

---

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