Documentation
¶
Index ¶
- type AccountConfig
- type Engine
- func (e *Engine) OnUpdate(fn func(map[string]QuotaSnapshot))
- func (e *Engine) RefreshAll(ctx context.Context)
- func (e *Engine) RegisterProvider(p QuotaProvider)
- func (e *Engine) Run(ctx context.Context)
- func (e *Engine) SetAccounts(accounts []AccountConfig)
- func (e *Engine) Snapshots() map[string]QuotaSnapshot
- type Metric
- type ProviderInfo
- type QuotaProvider
- type QuotaSnapshot
- type Status
- type TimePoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountConfig ¶
type AccountConfig struct {
ID string `json:"id"`
Provider string `json:"provider"`
Auth string `json:"auth,omitempty"` // "api_key", "oauth", "cli", "local", "token"
APIKeyEnv string `json:"api_key_env,omitempty"` // env var name holding the API key
ProbeModel string `json:"probe_model,omitempty"` // model to use for probe requests
Binary string `json:"binary,omitempty"` // path to CLI binary
BaseURL string `json:"base_url,omitempty"` // custom API base URL (e.g. for OpenRouter)
Token string `json:"-"` // runtime-only: access token (never persisted)
ExtraData map[string]string `json:"-"` // runtime-only: extra detection data
}
func (AccountConfig) ResolveAPIKey ¶
func (c AccountConfig) ResolveAPIKey() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) OnUpdate ¶
func (e *Engine) OnUpdate(fn func(map[string]QuotaSnapshot))
func (*Engine) RefreshAll ¶
func (*Engine) RegisterProvider ¶
func (e *Engine) RegisterProvider(p QuotaProvider)
func (*Engine) SetAccounts ¶
func (e *Engine) SetAccounts(accounts []AccountConfig)
func (*Engine) Snapshots ¶
func (e *Engine) Snapshots() map[string]QuotaSnapshot
type Metric ¶
type ProviderInfo ¶
type QuotaProvider ¶
type QuotaProvider interface {
ID() string
Describe() ProviderInfo
Fetch(ctx context.Context, acct AccountConfig) (QuotaSnapshot, error)
}
type QuotaSnapshot ¶
type QuotaSnapshot struct {
ProviderID string `json:"provider_id"`
AccountID string `json:"account_id"`
Timestamp time.Time `json:"timestamp"`
Status Status `json:"status"`
Metrics map[string]Metric `json:"metrics"` // keys like "rpm", "tpm", "rpd"
Resets map[string]time.Time `json:"resets,omitempty"` // e.g. "rpm_reset"
Raw map[string]string `json:"raw,omitempty"` // redacted header dump / CLI lines
DailySeries map[string][]TimePoint `json:"daily_series,omitempty"` // time-indexed data (e.g. "messages", "cost", "tokens_<model>")
Message string `json:"message,omitempty"` // human-readable summary
}
func (QuotaSnapshot) WorstPercent ¶
func (s QuotaSnapshot) WorstPercent() float64
Click to show internal directories.
Click to hide internal directories.