extension hook for upstream consumers.
this package intentionally ships zero retry / backoff / rotation
policy. instead, consumers compose their own by implementing this
behaviour and registering it in :openrouter_sdk, :middleware:
config :openrouter_sdk,
middleware: [
{MyApp.Retry, max: 3, base: 200},
{MyApp.Rotate, models: ["openai/gpt-4o", "anthropic/claude-sonnet-4-6"]}
]the next callback runs the rest of the pipeline (eventually
reaching the finch call). a middleware that wants to retry simply
re-invokes next.(request); a rotator can swap fields on the
request before passing it on.
Summary
Functions
fold a list of middleware over the terminal runner function,
producing a single function that runs the whole chain.
Types
@type request() :: OpenrouterSdk.Client.Request.t()
@type response() :: {:ok, term()} | {:error, OpenrouterSdk.Error.t()}