finch wrapper. two paths:
request/2— buffered. body collected, json decoded.stream/2— sse. returns a lazyStreamthat yields parsed events; consumers can also opt into pid / fun delivery via the:intooption (seeOpenrouterSdk.Api.*for usage).
middleware wraps both paths so retry / rotation policies see every
request including streams. for streams the middleware sees the
initial :ok | :error decision (i.e. whether the stream started)
but does not see the per-chunk events — those flow directly to the
consumer's stream.
Summary
Functions
@spec request(OpenrouterSdk.Client.Request.t(), OpenrouterSdk.Config.t()) :: {:ok, term()} | {:error, OpenrouterSdk.Error.t()}
execute a buffered request. returns {:ok, decoded} | {:error, error}
@spec stream(OpenrouterSdk.Client.Request.t(), OpenrouterSdk.Config.t()) :: {:ok, Enumerable.t()} | {:error, OpenrouterSdk.Error.t()}
execute a streaming request. returns {:ok, stream} where stream
is a lazy Stream of :done | %SSE.Event{} | {:raw, bytes} (the
shape depends on opts the api module passes via req.opts).
the stream is only safe to consume from the process that calls this
function (it reads from that process mailbox). use Stream.run/1,
Enum.to_list/1, or pipe through Stream.map/2 etc.