Documentation
¶
Overview ¶
Package v39a posts cost and conversation events from govega to v39a's /api/instances/conversation-event endpoint. Govega runs inside per-tenant Fly apps; v39a is the control panel that aggregates spend across tenants for the cost UI.
The reporter is best-effort: failures are logged but never block the LLM call path. Callers always fire RecordCost in a goroutine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CostEvent ¶
type CostEvent struct {
ConversationID string `json:"conversation_id"`
Kind string `json:"kind"`
Vendor string `json:"vendor,omitempty"`
Units float64 `json:"units"`
UnitCostUSD float64 `json:"unit_cost_usd"`
StepType string `json:"step_type,omitempty"`
Model string `json:"model,omitempty"`
}
CostEvent is a single billable event. Mirrors the cost_recorded shape v39a's conversation-event endpoint accepts, plus step_type/model so the UI can slice spend by routing tier.
type Reporter ¶
type Reporter struct {
// BaseURL is the v39a origin, e.g. "https://admin.v39a.com".
BaseURL string
// Token authenticates the caller. Sent as the X-V39A-Token header.
// v39a matches it against instances.api_token.
Token string
// Client is the HTTP client to use. Nil means http.DefaultClient.
Client *http.Client
// Timeout caps each request. Zero means defaultTimeout.
Timeout time.Duration
}
Reporter posts events to v39a's conversation-event endpoint. Construct via NewReporterFromEnv (production) or directly (tests).
func NewReporterFromEnv ¶
func NewReporterFromEnv() *Reporter
NewReporterFromEnv returns a Reporter configured from V39A_REPORTER_URL and V39A_INSTANCE_TOKEN. Returns nil if either env var is unset — the caller should treat that as "telemetry disabled" and skip the call.