blob: b1decc9f3cde22f96ba58135a5cebc37c93c7e99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
package domain
import "time"
type Protocol string
const (
ProtocolOpenAI Protocol = "openai"
ProtocolAnthropic Protocol = "anthropic"
)
type Principal struct {
KeyID string
TenantID string
ProjectID string
Scopes []string
}
type Provider struct {
ID string
Protocol Protocol
BaseURL string
APIKey string
}
type Route struct {
Provider Provider
UpstreamModel string
Priority int
Weight int
}
type Model struct {
ID string
OwnedBy string
InputPriceMicrosPerMillion int64
OutputPriceMicrosPerMillion int64
CacheReadPriceMicrosPerMillion int64
CacheWritePriceMicrosPerMillion int64
Routes []Route
}
type Usage struct {
InputTokens int64 `json:"input_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
TotalTokens int64 `json:"total_tokens,omitempty"`
CacheCreationInputTokens int64 `json:"cache_creation_input_tokens,omitempty"`
CacheReadInputTokens int64 `json:"cache_read_input_tokens,omitempty"`
}
type UsageEvent struct {
RequestID string `json:"request_id"`
KeyID string `json:"key_id"`
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
PublicModel string `json:"public_model"`
ProviderID string `json:"provider_id,omitempty"`
UpstreamModel string `json:"upstream_model,omitempty"`
Protocol Protocol `json:"protocol"`
Stream bool `json:"stream"`
StatusCode int `json:"status_code"`
Success bool `json:"success"`
ErrorType string `json:"error_type,omitempty"`
Attempts int `json:"attempts"`
StartedAt time.Time `json:"started_at"`
DurationMS int64 `json:"duration_ms"`
Usage Usage `json:"usage"`
}
// LimitPolicy is the immutable runtime view of a project's commercial limits.
// Zero values disable the corresponding limit.
type LimitPolicy struct {
TenantID string `json:"tenant_id"`
ProjectID string `json:"project_id"`
RequestsPerMinute int64 `json:"requests_per_minute"`
TokensPerMinute int64 `json:"tokens_per_minute"`
Concurrent int64 `json:"concurrent_requests"`
MonthlySpendMicros int64 `json:"monthly_spend_micros"`
}
|