summaryrefslogtreecommitdiff
path: root/internal/domain
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-05 22:01:29 +1200
committerChia <Chia@93.nz>2026-08-05 22:07:50 +1200
commiteadb2ffe85c43cf6fc741c9823cd28eedb4a844c (patch)
tree1aba2536d57360da403aa35c9ced58b615c7064e /internal/domain
parentcd0dd91ab93653631904f2ea0e574ccde6d60339 (diff)
feat: harden prepaid billing and commercial operations
Diffstat (limited to '')
-rw-r--r--internal/domain/types.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/domain/types.go b/internal/domain/types.go
index b1decc9..94e56c1 100644
--- a/internal/domain/types.go
+++ b/internal/domain/types.go
@@ -32,7 +32,27 @@ type Route struct {
type Model struct {
ID string
+ DisplayName string
+ Description string
OwnedBy string
+ InputModalities []string
+ OutputModalities []string
+ ContextWindow int64
+ MaxOutputTokens int64
+ Capabilities []string
+ Regions []string
+ Lifecycle string
+ ReleasedAt *time.Time
+ DeprecatedAt *time.Time
+ RetiredAt *time.Time
+ ReplacementModel string
+ Aliases []string
+ AllowedTenantIDs map[string]struct{}
+ AllowedKeyIDs map[string]struct{}
+ PriceVersionID string
+ PriceVersion int
+ PriceCurrency string
+ PriceEffectiveFrom time.Time
InputPriceMicrosPerMillion int64
OutputPriceMicrosPerMillion int64
CacheReadPriceMicrosPerMillion int64
@@ -40,6 +60,20 @@ type Model struct {
Routes []Route
}
+func (m Model) Allows(principal Principal) bool {
+ if len(m.AllowedTenantIDs) > 0 {
+ if _, ok := m.AllowedTenantIDs[principal.TenantID]; !ok {
+ return false
+ }
+ }
+ if len(m.AllowedKeyIDs) > 0 {
+ if _, ok := m.AllowedKeyIDs[principal.KeyID]; !ok {
+ return false
+ }
+ }
+ return true
+}
+
type Usage struct {
InputTokens int64 `json:"input_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
@@ -65,6 +99,7 @@ type UsageEvent struct {
StartedAt time.Time `json:"started_at"`
DurationMS int64 `json:"duration_ms"`
Usage Usage `json:"usage"`
+ UsageReported bool `json:"usage_reported"`
}
// LimitPolicy is the immutable runtime view of a project's commercial limits.