quota

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPricing = map[string]ModelPricing{

	"claude-3-7-sonnet": {PromptPer1M: 3.00, CompletionPer1M: 15.00},
	"claude-3-5-sonnet": {PromptPer1M: 3.00, CompletionPer1M: 15.00},
	"claude-sonnet-4-5": {PromptPer1M: 3.00, CompletionPer1M: 15.00},
	"claude-3-5-haiku":  {PromptPer1M: 0.80, CompletionPer1M: 4.00},
	"claude-haiku-4-5":  {PromptPer1M: 0.80, CompletionPer1M: 4.00},
	"claude-opus":       {PromptPer1M: 15.00, CompletionPer1M: 75.00},

	"gpt-4o":      {PromptPer1M: 2.50, CompletionPer1M: 10.00},
	"gpt-4o-mini": {PromptPer1M: 0.15, CompletionPer1M: 0.60},
	"o1":          {PromptPer1M: 15.00, CompletionPer1M: 60.00},
	"o3":          {PromptPer1M: 10.00, CompletionPer1M: 40.00},
	"o3-mini":     {PromptPer1M: 1.10, CompletionPer1M: 4.40},

	"gemini-2.5-pro":   {PromptPer1M: 1.25, CompletionPer1M: 5.00},
	"gemini-3.1-pro":   {PromptPer1M: 1.25, CompletionPer1M: 5.00},
	"gemini-2.5-flash": {PromptPer1M: 0.075, CompletionPer1M: 0.30},
	"gemini-3.8-flash": {PromptPer1M: 0.075, CompletionPer1M: 0.30},

	"deepseek-chat":     {PromptPer1M: 0.14, CompletionPer1M: 0.28},
	"deepseek-reasoner": {PromptPer1M: 0.55, CompletionPer1M: 2.19},
}
View Source
var GlobalLedger = NewCostLedger(5000)

Functions

This section is empty.

Types

type CostLedger added in v0.4.0

type CostLedger struct {
	// contains filtered or unexported fields
}

func NewCostLedger added in v0.4.0

func NewCostLedger(maxSize int) *CostLedger

func (*CostLedger) Record added in v0.4.0

func (l *CostLedger) Record(providerID, model string, promptToks, complToks int)

func (*CostLedger) Summary added in v0.4.0

func (l *CostLedger) Summary() LedgerSummary

type LedgerSummary added in v0.4.0

type LedgerSummary struct {
	TotalRequests     int64              `json:"total_requests"`
	TotalTokens       int64              `json:"total_tokens"`
	TotalCostUSD      float64            `json:"total_cost_usd"`
	TotalSavedUSD     float64            `json:"total_saved_usd"`
	ModelDistribution map[string]int64   `json:"model_distribution"`
	ProviderSpendUSD  map[string]float64 `json:"provider_spend_usd"`
}

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter() *Limiter

func (*Limiter) Allow

func (l *Limiter) Allow(id string) bool

func (*Limiter) Record429

func (l *Limiter) Record429(id string, duration time.Duration)

func (*Limiter) SetRPM

func (l *Limiter) SetRPM(id string, rpm int)

type ModelPricing added in v0.4.0

type ModelPricing struct {
	PromptPer1M     float64 `json:"prompt_per_1m"`
	CompletionPer1M float64 `json:"completion_per_1m"`
}

type UsageRecord added in v0.4.0

type UsageRecord struct {
	Timestamp        time.Time `json:"timestamp"`
	ProviderID       string    `json:"provider_id"`
	Model            string    `json:"model"`
	PromptTokens     int       `json:"prompt_tokens"`
	CompletionTokens int       `json:"completion_tokens"`
	TotalTokens      int       `json:"total_tokens"`
	EstimatedCostUSD float64   `json:"estimated_cost_usd"`
	IsFreeOrOAuth    bool      `json:"is_free_or_oauth"`
}

Jump to

Keyboard shortcuts

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