summaryrefslogtreecommitdiff
path: root/internal/domain
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-04 19:58:52 +1200
committerChia <Chia@93.nz>2026-08-04 20:43:23 +1200
commit5b651488b081b65fda8a323f228e139adb79a35d (patch)
tree08baf40efb8fe103b32721cd991ff712323e3173 /internal/domain
Build AI gateway control plane and admin UI
Diffstat (limited to '')
-rw-r--r--internal/domain/types.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/internal/domain/types.go b/internal/domain/types.go
new file mode 100644
index 0000000..e2586ea
--- /dev/null
+++ b/internal/domain/types.go
@@ -0,0 +1,64 @@
+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
+ 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"`
+}