Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves billing API endpoints.
func NewHandler ¶
NewHandler creates a new billing handler.
func (*Handler) GetSummary ¶
GetSummary handles GET /billing/summary.
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers billing endpoints.
type LineItem ¶
type LineItem struct {
Timestamp time.Time `json:"timestamp"`
ProviderID string `json:"provider_id"`
ModelID string `json:"model_id"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheReadTokens int64 `json:"cache_read_tokens"`
CacheWriteTokens int64 `json:"cache_write_tokens"`
TotalTokens int64 `json:"total_tokens"`
EstimatedCost float64 `json:"estimated_cost"`
RequestCount int64 `json:"request_count"`
Success bool `json:"success"`
LatencyMs int64 `json:"latency_ms"`
UserID string `json:"user_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
LineItem is one billing line in detailed list/export.
type LinesResponse ¶
type LinesResponse struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
Page int `json:"page"`
PageSize int `json:"page_size"`
Total int `json:"total"`
Items []LineItem `json:"items"`
}
LinesResponse is paginated billing lines.
type QueryOptions ¶
type QueryOptions struct {
Start time.Time
End time.Time
ProviderID string
ModelID string
GroupBy string
}
QueryOptions controls billing queries.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides billing query/export operations.
func NewService ¶
func NewService(storage providerpool.Storage) *Service
NewService creates a billing service.
func (*Service) ExportCSV ¶
func (s *Service) ExportCSV(opts QueryOptions) ([]byte, error)
ExportCSV exports filtered billing lines as CSV bytes.
func (*Service) GetLines ¶
func (s *Service) GetLines(opts QueryOptions, page, pageSize int) (*LinesResponse, error)
GetLines returns paginated billing line items.
func (*Service) GetSummary ¶
func (s *Service) GetSummary(opts QueryOptions) (*SummaryResponse, error)
GetSummary returns aggregate billing data for a range.
type SummaryBreakdown ¶
type SummaryBreakdown struct {
Key string `json:"key"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,omitempty"`
Day string `json:"day,omitempty"`
Totals
}
SummaryBreakdown is one grouped bucket in billing summary.
type SummaryResponse ¶
type SummaryResponse struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
Currency string `json:"currency"`
GroupBy string `json:"group_by"`
Totals Totals `json:"totals"`
Breakdown []SummaryBreakdown `json:"breakdown"`
}
SummaryResponse is the billing summary payload.
type Totals ¶
type Totals struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheReadTokens int64 `json:"cache_read_tokens"`
CacheWriteTokens int64 `json:"cache_write_tokens"`
TotalTokens int64 `json:"total_tokens"`
RequestCount int64 `json:"request_count"`
SuccessCount int64 `json:"success_count"`
FailureCount int64 `json:"failure_count"`
EstimatedCost float64 `json:"estimated_cost"`
}
Totals is an aggregate usage/cost snapshot.