Class RateLimitInfo

java.lang.Object
ai.redouble.nucleo.harness.admission.RateLimitInfo
All Implemented Interfaces:
Serializable

public class RateLimitInfo extends Object implements Serializable
Captures rate limit information from API responses. Immutable data class holding rate limit headers and status.
Since:
0.1 (2025-08-11)
Author:
Andrey Santrosyan
See Also:
  • Field Details

    • requestsPerMinute

      public final int requestsPerMinute
    • tokensPerMinute

      public final int tokensPerMinute
  • Constructor Details

  • Method Details

    • rateLimited

      public static RateLimitInfo rateLimited(String model)
      The minimal record for a limit that was hit and nothing more: no limits known, nothing remaining, a sixty-second retry-after, kind unknown.
    • fromHeaders

      public static RateLimitInfo fromHeaders(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset)
      The record a successful response's token headers give: a capacity reading that was not rate limited, with no retry-after and no request limits.
    • parseIntOrNull

      public static Integer parseIntOrNull(String value)
      Header-value parsing shared by the clients: the value is trimmed, and a missing or non-numeric header is a valid absent value, null.
    • getModel

      public String getModel()
    • getTokensLimit

      public Integer getTokensLimit()
    • getTokensRemaining

      public Integer getTokensRemaining()
    • getTokensReset

      public Instant getTokensReset()
    • getRequestsLimit

      public Integer getRequestsLimit()
    • getRequestsRemaining

      public Integer getRequestsRemaining()
    • getRetryAfter

      public Duration getRetryAfter()
    • wasRateLimited

      public boolean wasRateLimited()
    • getCapturedAt

      public Instant getCapturedAt()
    • getType

      public RateLimitType getType()