Parsed rate-limit metadata from Anthropic API response headers.
Every response from the Anthropic API includes rate-limit headers. This struct captures the ones most useful for client-side throttling:
requests_remaining— requests left in the current windowtokens_remaining— tokens left in the current windowretry_after— seconds to wait before retrying (present on 429s)
Extracting from a response
The plugin automatically parses these headers and stashes the struct
in Req.Response private data. Use ReqAnthropic.rate_limit/1 to
retrieve it:
{:ok, resp} = ReqAnthropic.Client.build(opts) |> Req.post(...)
rate_limit = ReqAnthropic.rate_limit(resp)
rate_limit.requests_remaining #=> 42
Summary
Functions
Build a %RateLimit{} from a %Req.Response{} by extracting and
parsing the relevant headers.
Types
@type t() :: %ReqAnthropic.RateLimit{ requests_remaining: non_neg_integer() | nil, retry_after: non_neg_integer() | nil, tokens_remaining: non_neg_integer() | nil }
Functions
@spec from_response(Req.Response.t()) :: t()
Build a %RateLimit{} from a %Req.Response{} by extracting and
parsing the relevant headers.