SuperPi.AI.Providers.HTTP (super_pi v0.1.0)

Copy Markdown View Source

Streams one request to an SSE model API and normalizes the events (SuperPi.AI.StreamNormalizer). Shared by the Anthropic and OpenAI providers.

Returns what SuperPi.AI.Provider.generate/2 returns, plus {:retry_after, ms} for a rate limit or an overloaded server, which the conversation machine turns into a backoff.

Req's own retry is off. The machine owns retries (backoff, cap, durable state), and a second layer of retries would repeat a request the first one already counted.

Summary

Functions

stream(provider, model, url, headers, body, opts \\ [])

@spec stream(atom(), String.t(), String.t(), list(), map(), keyword()) ::
  {:ok, map()} | {:retry_after, non_neg_integer()} | {:error, term()}