ratelimit

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ratelimit parses Anthropic rate-limit response headers and surfaces warnings when quota is running low. Mirrors src/services/claudeAiLimits.ts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// Request quota
	RequestsRemaining int
	RequestsLimit     int

	// Token quota (combined input+output)
	TokensRemaining int
	TokensLimit     int

	// Input-token quota (separate bucket)
	InputTokensRemaining int
	InputTokensLimit     int
}

Info holds parsed rate-limit state from a single response.

func Parse

func Parse(h http.Header) Info

Parse reads the standard Anthropic rate-limit response headers. Missing or malformed headers are silently ignored.

func (Info) HasData

func (i Info) HasData() bool

HasData reports whether any rate-limit header was present.

func (Info) WarningMessage

func (i Info) WarningMessage() string

WarningMessage returns a non-empty string when any quota bucket is below 20% capacity. The caller should surface this in the status bar.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL