fi.evolver.ai.spring.provider.anthropic.response.ARateLimitHeaders Maven / Gradle / Ivy
package fi.evolver.ai.spring.provider.anthropic.response;
import fi.evolver.ai.spring.util.RateLimitHeaders;
import java.net.http.HttpHeaders;
import java.time.OffsetDateTime;
import java.util.Optional;
public record ARateLimitHeaders(
Optional requestsLimit,
Optional requestsRemaining,
Optional requestsReset,
Optional tokensLimit,
Optional tokensRemaining,
Optional tokensReset
) implements RateLimitHeaders {
public static ARateLimitHeaders fromHttpHeaders(HttpHeaders headers) {
try {
return new ARateLimitHeaders(
headers.firstValue("anthropic-ratelimit-requests-limit").map(Integer::parseInt),
headers.firstValue("anthropic-ratelimit-requests-remaining").map(Integer::parseInt),
headers.firstValue("anthropic-ratelimit-requests-reset").map(OffsetDateTime::parse),
headers.firstValue("anthropic-ratelimit-tokens-limit").map(Integer::parseInt),
headers.firstValue("anthropic-ratelimit-tokens-remaining").map(Integer::parseInt),
headers.firstValue("anthropic-ratelimit-tokens-reset").map(OffsetDateTime::parse)
);
}
catch (Exception e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy