# `OpenrouterSdk.Streaming`
[🔗](https://github.com/zmzlois/openrouter_sdk/blob/v0.1.0/lib/openrouter_sdk/streaming.ex#L1)

shared sink semantics for `*_stream` apis.

consumers can opt into three sinks via `:into`:

  * default (no `:into`) — `{:ok, stream}`, lazy `Stream`.
  * `:into` is a `pid` — events are forwarded as
    `{:openrouter_event, ref, event}`; returns `{:ok, ref}`.
  * `:into` is a `fun/2` — runs `Enum.reduce/3` for the consumer
    with `acc: opts[:acc] || []`; returns `{:ok, acc}`.

the streaming function is passed as a thunk so we can decide
whether to invoke it inline or inside a separate task — this
matters because the underlying stream reads from the mailbox of
whichever process opened it.

# `start_fn`

```elixir
@type start_fn() :: (-&gt; {:ok, Enumerable.t()} | {:error, term()})
```

# `wrap`

```elixir
@spec wrap(
  start_fn(),
  keyword()
) :: {:ok, Enumerable.t() | reference() | term()} | {:error, term()}
```

---

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