usagev1

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UsageService_RecordUsageEvent_FullMethodName  = "/usage.v1.UsageService/RecordUsageEvent"
	UsageService_RecordUsageEvents_FullMethodName = "/usage.v1.UsageService/RecordUsageEvents"
	UsageService_GetUsageSummary_FullMethodName   = "/usage.v1.UsageService/GetUsageSummary"
	UsageService_GetUsageByMeta_FullMethodName    = "/usage.v1.UsageService/GetUsageByMeta"
)

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "STATUS_UNSPECIFIED",
		1: "STATUS_SUCCESS",
		2: "STATUS_ERROR",
		3: "STATUS_CANCELLED",
		4: "STATUS_TIMEOUT",
	}
	Status_value = map[string]int32{
		"STATUS_UNSPECIFIED": 0,
		"STATUS_SUCCESS":     1,
		"STATUS_ERROR":       2,
		"STATUS_CANCELLED":   3,
		"STATUS_TIMEOUT":     4,
	}
)

Enum value maps for Status.

View Source
var File_usage_v1_usage_proto protoreflect.FileDescriptor
View Source
var UsageService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "usage.v1.UsageService",
	HandlerType: (*UsageServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "RecordUsageEvent",
			Handler:    _UsageService_RecordUsageEvent_Handler,
		},
		{
			MethodName: "RecordUsageEvents",
			Handler:    _UsageService_RecordUsageEvents_Handler,
		},
		{
			MethodName: "GetUsageSummary",
			Handler:    _UsageService_GetUsageSummary_Handler,
		},
		{
			MethodName: "GetUsageByMeta",
			Handler:    _UsageService_GetUsageByMeta_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "usage/v1/usage.proto",
}

UsageService_ServiceDesc is the grpc.ServiceDesc for UsageService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterUsageServiceServer

func RegisterUsageServiceServer(s grpc.ServiceRegistrar, srv UsageServiceServer)

Types

type GetUsageByMetaRequest

type GetUsageByMetaRequest struct {

	// Meta key to filter on (required, e.g. "job_id")
	MetaKey string `protobuf:"bytes,1,opt,name=meta_key,json=metaKey,proto3" json:"meta_key,omitempty"`
	// Meta value to filter on (required, e.g. the job UUID)
	MetaValue string `protobuf:"bytes,2,opt,name=meta_value,json=metaValue,proto3" json:"meta_value,omitempty"`
	// Optional second meta key to split rows by (e.g. "task_id");
	// events without it aggregate under an empty group_value.
	GroupByMetaKey string `protobuf:"bytes,3,opt,name=group_by_meta_key,json=groupByMetaKey,proto3" json:"group_by_meta_key,omitempty"`
	// Optional project filter
	ProjectId string `protobuf:"bytes,4,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
	// contains filtered or unexported fields
}

GetUsageByMetaRequest aggregates usage over events carrying a given meta key/value (e.g. all events of one batch job, meta_key="job_id").

func (*GetUsageByMetaRequest) Descriptor deprecated

func (*GetUsageByMetaRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetUsageByMetaRequest.ProtoReflect.Descriptor instead.

func (*GetUsageByMetaRequest) GetGroupByMetaKey

func (x *GetUsageByMetaRequest) GetGroupByMetaKey() string

func (*GetUsageByMetaRequest) GetMetaKey

func (x *GetUsageByMetaRequest) GetMetaKey() string

func (*GetUsageByMetaRequest) GetMetaValue

func (x *GetUsageByMetaRequest) GetMetaValue() string

func (*GetUsageByMetaRequest) GetProjectId

func (x *GetUsageByMetaRequest) GetProjectId() string

func (*GetUsageByMetaRequest) ProtoMessage

func (*GetUsageByMetaRequest) ProtoMessage()

func (*GetUsageByMetaRequest) ProtoReflect

func (x *GetUsageByMetaRequest) ProtoReflect() protoreflect.Message

func (*GetUsageByMetaRequest) Reset

func (x *GetUsageByMetaRequest) Reset()

func (*GetUsageByMetaRequest) String

func (x *GetUsageByMetaRequest) String() string

type GetUsageByMetaResponse

type GetUsageByMetaResponse struct {
	Rows      []*UsageByMetaRow `protobuf:"bytes,1,rep,name=rows,proto3" json:"rows,omitempty"`
	Truncated bool              `protobuf:"varint,2,opt,name=truncated,proto3" json:"truncated,omitempty"`
	// contains filtered or unexported fields
}

GetUsageByMetaResponse is the response for meta-scoped aggregation

func (*GetUsageByMetaResponse) Descriptor deprecated

func (*GetUsageByMetaResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetUsageByMetaResponse.ProtoReflect.Descriptor instead.

func (*GetUsageByMetaResponse) GetRows

func (x *GetUsageByMetaResponse) GetRows() []*UsageByMetaRow

func (*GetUsageByMetaResponse) GetTruncated

func (x *GetUsageByMetaResponse) GetTruncated() bool

func (*GetUsageByMetaResponse) ProtoMessage

func (*GetUsageByMetaResponse) ProtoMessage()

func (*GetUsageByMetaResponse) ProtoReflect

func (x *GetUsageByMetaResponse) ProtoReflect() protoreflect.Message

func (*GetUsageByMetaResponse) Reset

func (x *GetUsageByMetaResponse) Reset()

func (*GetUsageByMetaResponse) String

func (x *GetUsageByMetaResponse) String() string

type GetUsageSummaryRequest

type GetUsageSummaryRequest struct {

	// Start of time range (inclusive)
	From *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
	// End of time range (exclusive)
	To *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
	// Optional filters
	ProjectId string `protobuf:"bytes,3,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
	UserId    string `protobuf:"bytes,4,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Vendor    string `protobuf:"bytes,5,opt,name=vendor,proto3" json:"vendor,omitempty"`
	Model     string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"`
	ActionId  string `protobuf:"bytes,7,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"`
	Status    Status `protobuf:"varint,8,opt,name=status,proto3,enum=usage.v1.Status" json:"status,omitempty"`
	// Group by dimensions (day is always included)
	GroupByProjectId bool `protobuf:"varint,10,opt,name=group_by_project_id,json=groupByProjectId,proto3" json:"group_by_project_id,omitempty"`
	GroupByUserId    bool `protobuf:"varint,11,opt,name=group_by_user_id,json=groupByUserId,proto3" json:"group_by_user_id,omitempty"`
	GroupByVendor    bool `protobuf:"varint,12,opt,name=group_by_vendor,json=groupByVendor,proto3" json:"group_by_vendor,omitempty"`
	GroupByModel     bool `protobuf:"varint,13,opt,name=group_by_model,json=groupByModel,proto3" json:"group_by_model,omitempty"`
	GroupByActionId  bool `protobuf:"varint,14,opt,name=group_by_action_id,json=groupByActionId,proto3" json:"group_by_action_id,omitempty"`
	GroupByStatus    bool `protobuf:"varint,15,opt,name=group_by_status,json=groupByStatus,proto3" json:"group_by_status,omitempty"`
	// contains filtered or unexported fields
}

GetUsageSummaryRequest is the request for getting usage summary

func (*GetUsageSummaryRequest) Descriptor deprecated

func (*GetUsageSummaryRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetUsageSummaryRequest.ProtoReflect.Descriptor instead.

func (*GetUsageSummaryRequest) GetActionId

func (x *GetUsageSummaryRequest) GetActionId() string

func (*GetUsageSummaryRequest) GetFrom

func (*GetUsageSummaryRequest) GetGroupByActionId

func (x *GetUsageSummaryRequest) GetGroupByActionId() bool

func (*GetUsageSummaryRequest) GetGroupByModel

func (x *GetUsageSummaryRequest) GetGroupByModel() bool

func (*GetUsageSummaryRequest) GetGroupByProjectId

func (x *GetUsageSummaryRequest) GetGroupByProjectId() bool

func (*GetUsageSummaryRequest) GetGroupByStatus

func (x *GetUsageSummaryRequest) GetGroupByStatus() bool

func (*GetUsageSummaryRequest) GetGroupByUserId

func (x *GetUsageSummaryRequest) GetGroupByUserId() bool

func (*GetUsageSummaryRequest) GetGroupByVendor

func (x *GetUsageSummaryRequest) GetGroupByVendor() bool

func (*GetUsageSummaryRequest) GetModel

func (x *GetUsageSummaryRequest) GetModel() string

func (*GetUsageSummaryRequest) GetProjectId

func (x *GetUsageSummaryRequest) GetProjectId() string

func (*GetUsageSummaryRequest) GetStatus

func (x *GetUsageSummaryRequest) GetStatus() Status

func (*GetUsageSummaryRequest) GetTo

func (*GetUsageSummaryRequest) GetUserId

func (x *GetUsageSummaryRequest) GetUserId() string

func (*GetUsageSummaryRequest) GetVendor

func (x *GetUsageSummaryRequest) GetVendor() string

func (*GetUsageSummaryRequest) ProtoMessage

func (*GetUsageSummaryRequest) ProtoMessage()

func (*GetUsageSummaryRequest) ProtoReflect

func (x *GetUsageSummaryRequest) ProtoReflect() protoreflect.Message

func (*GetUsageSummaryRequest) Reset

func (x *GetUsageSummaryRequest) Reset()

func (*GetUsageSummaryRequest) String

func (x *GetUsageSummaryRequest) String() string

type GetUsageSummaryResponse

type GetUsageSummaryResponse struct {
	Rows      []*UsageSummaryRow `protobuf:"bytes,1,rep,name=rows,proto3" json:"rows,omitempty"`
	Truncated bool               `protobuf:"varint,2,opt,name=truncated,proto3" json:"truncated,omitempty"`
	// contains filtered or unexported fields
}

GetUsageSummaryResponse is the response for getting usage summary

func (*GetUsageSummaryResponse) Descriptor deprecated

func (*GetUsageSummaryResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetUsageSummaryResponse.ProtoReflect.Descriptor instead.

func (*GetUsageSummaryResponse) GetRows

func (x *GetUsageSummaryResponse) GetRows() []*UsageSummaryRow

func (*GetUsageSummaryResponse) GetTruncated

func (x *GetUsageSummaryResponse) GetTruncated() bool

func (*GetUsageSummaryResponse) ProtoMessage

func (*GetUsageSummaryResponse) ProtoMessage()

func (*GetUsageSummaryResponse) ProtoReflect

func (x *GetUsageSummaryResponse) ProtoReflect() protoreflect.Message

func (*GetUsageSummaryResponse) Reset

func (x *GetUsageSummaryResponse) Reset()

func (*GetUsageSummaryResponse) String

func (x *GetUsageSummaryResponse) String() string

type RecordUsageEventRequest

type RecordUsageEventRequest struct {
	Event *UsageEvent `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
	// contains filtered or unexported fields
}

RecordUsageEventRequest is the request for recording a single usage event

func (*RecordUsageEventRequest) Descriptor deprecated

func (*RecordUsageEventRequest) Descriptor() ([]byte, []int)

Deprecated: Use RecordUsageEventRequest.ProtoReflect.Descriptor instead.

func (*RecordUsageEventRequest) GetEvent

func (x *RecordUsageEventRequest) GetEvent() *UsageEvent

func (*RecordUsageEventRequest) ProtoMessage

func (*RecordUsageEventRequest) ProtoMessage()

func (*RecordUsageEventRequest) ProtoReflect

func (x *RecordUsageEventRequest) ProtoReflect() protoreflect.Message

func (*RecordUsageEventRequest) Reset

func (x *RecordUsageEventRequest) Reset()

func (*RecordUsageEventRequest) String

func (x *RecordUsageEventRequest) String() string

type RecordUsageEventResponse

type RecordUsageEventResponse struct {

	// Whether the event was newly created (false if duplicate event_id)
	Created bool `protobuf:"varint,1,opt,name=created,proto3" json:"created,omitempty"`
	// contains filtered or unexported fields
}

RecordUsageEventResponse is the response for recording a single usage event

func (*RecordUsageEventResponse) Descriptor deprecated

func (*RecordUsageEventResponse) Descriptor() ([]byte, []int)

Deprecated: Use RecordUsageEventResponse.ProtoReflect.Descriptor instead.

func (*RecordUsageEventResponse) GetCreated

func (x *RecordUsageEventResponse) GetCreated() bool

func (*RecordUsageEventResponse) ProtoMessage

func (*RecordUsageEventResponse) ProtoMessage()

func (*RecordUsageEventResponse) ProtoReflect

func (x *RecordUsageEventResponse) ProtoReflect() protoreflect.Message

func (*RecordUsageEventResponse) Reset

func (x *RecordUsageEventResponse) Reset()

func (*RecordUsageEventResponse) String

func (x *RecordUsageEventResponse) String() string

type RecordUsageEventsRequest

type RecordUsageEventsRequest struct {

	// Maximum 500 events per batch
	Events []*UsageEvent `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
	// contains filtered or unexported fields
}

RecordUsageEventsRequest is the request for recording multiple usage events

func (*RecordUsageEventsRequest) Descriptor deprecated

func (*RecordUsageEventsRequest) Descriptor() ([]byte, []int)

Deprecated: Use RecordUsageEventsRequest.ProtoReflect.Descriptor instead.

func (*RecordUsageEventsRequest) GetEvents

func (x *RecordUsageEventsRequest) GetEvents() []*UsageEvent

func (*RecordUsageEventsRequest) ProtoMessage

func (*RecordUsageEventsRequest) ProtoMessage()

func (*RecordUsageEventsRequest) ProtoReflect

func (x *RecordUsageEventsRequest) ProtoReflect() protoreflect.Message

func (*RecordUsageEventsRequest) Reset

func (x *RecordUsageEventsRequest) Reset()

func (*RecordUsageEventsRequest) String

func (x *RecordUsageEventsRequest) String() string

type RecordUsageEventsResponse

type RecordUsageEventsResponse struct {

	// Number of events that were newly created
	CreatedCount int32 `protobuf:"varint,1,opt,name=created_count,json=createdCount,proto3" json:"created_count,omitempty"`
	// Number of events that were duplicates (already existed)
	DuplicateCount int32 `protobuf:"varint,2,opt,name=duplicate_count,json=duplicateCount,proto3" json:"duplicate_count,omitempty"`
	// contains filtered or unexported fields
}

RecordUsageEventsResponse is the response for recording multiple usage events

func (*RecordUsageEventsResponse) Descriptor deprecated

func (*RecordUsageEventsResponse) Descriptor() ([]byte, []int)

Deprecated: Use RecordUsageEventsResponse.ProtoReflect.Descriptor instead.

func (*RecordUsageEventsResponse) GetCreatedCount

func (x *RecordUsageEventsResponse) GetCreatedCount() int32

func (*RecordUsageEventsResponse) GetDuplicateCount

func (x *RecordUsageEventsResponse) GetDuplicateCount() int32

func (*RecordUsageEventsResponse) ProtoMessage

func (*RecordUsageEventsResponse) ProtoMessage()

func (*RecordUsageEventsResponse) ProtoReflect

func (*RecordUsageEventsResponse) Reset

func (x *RecordUsageEventsResponse) Reset()

func (*RecordUsageEventsResponse) String

func (x *RecordUsageEventsResponse) String() string

type Status

type Status int32

Status represents the outcome of an LLM request

const (
	Status_STATUS_UNSPECIFIED Status = 0
	Status_STATUS_SUCCESS     Status = 1
	Status_STATUS_ERROR       Status = 2
	Status_STATUS_CANCELLED   Status = 3
	Status_STATUS_TIMEOUT     Status = 4
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type UnimplementedUsageServiceServer

type UnimplementedUsageServiceServer struct{}

UnimplementedUsageServiceServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedUsageServiceServer) GetUsageByMeta

func (UnimplementedUsageServiceServer) GetUsageSummary

func (UnimplementedUsageServiceServer) RecordUsageEvent

func (UnimplementedUsageServiceServer) RecordUsageEvents

type UnsafeUsageServiceServer

type UnsafeUsageServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeUsageServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UsageServiceServer will result in compilation errors.

type UsageByMetaRow

type UsageByMetaRow struct {

	// Value of group_by_meta_key ("" when the key is absent or not requested)
	GroupValue   string `protobuf:"bytes,1,opt,name=group_value,json=groupValue,proto3" json:"group_value,omitempty"`
	Vendor       string `protobuf:"bytes,2,opt,name=vendor,proto3" json:"vendor,omitempty"`
	Model        string `protobuf:"bytes,3,opt,name=model,proto3" json:"model,omitempty"`
	TokensInput  int64  `protobuf:"varint,4,opt,name=tokens_input,json=tokensInput,proto3" json:"tokens_input,omitempty"`
	TokensOutput int64  `protobuf:"varint,5,opt,name=tokens_output,json=tokensOutput,proto3" json:"tokens_output,omitempty"`
	TokensTotal  int64  `protobuf:"varint,6,opt,name=tokens_total,json=tokensTotal,proto3" json:"tokens_total,omitempty"`
	RequestCount int64  `protobuf:"varint,7,opt,name=request_count,json=requestCount,proto3" json:"request_count,omitempty"`
	// Summed cost in nano-USD (1e-9 USD)
	CostNanousd int64 `protobuf:"varint,8,opt,name=cost_nanousd,json=costNanousd,proto3" json:"cost_nanousd,omitempty"`
	// Summed parts of tokens_input read from and written to the prompt cache
	CacheReadTokens  int64 `protobuf:"varint,9,opt,name=cache_read_tokens,json=cacheReadTokens,proto3" json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int64 `protobuf:"varint,10,opt,name=cache_write_tokens,json=cacheWriteTokens,proto3" json:"cache_write_tokens,omitempty"`
	// contains filtered or unexported fields
}

UsageByMetaRow is one aggregate bucket: (group_value, vendor, model).

func (*UsageByMetaRow) Descriptor deprecated

func (*UsageByMetaRow) Descriptor() ([]byte, []int)

Deprecated: Use UsageByMetaRow.ProtoReflect.Descriptor instead.

func (*UsageByMetaRow) GetCacheReadTokens

func (x *UsageByMetaRow) GetCacheReadTokens() int64

func (*UsageByMetaRow) GetCacheWriteTokens

func (x *UsageByMetaRow) GetCacheWriteTokens() int64

func (*UsageByMetaRow) GetCostNanousd

func (x *UsageByMetaRow) GetCostNanousd() int64

func (*UsageByMetaRow) GetGroupValue

func (x *UsageByMetaRow) GetGroupValue() string

func (*UsageByMetaRow) GetModel

func (x *UsageByMetaRow) GetModel() string

func (*UsageByMetaRow) GetRequestCount

func (x *UsageByMetaRow) GetRequestCount() int64

func (*UsageByMetaRow) GetTokensInput

func (x *UsageByMetaRow) GetTokensInput() int64

func (*UsageByMetaRow) GetTokensOutput

func (x *UsageByMetaRow) GetTokensOutput() int64

func (*UsageByMetaRow) GetTokensTotal

func (x *UsageByMetaRow) GetTokensTotal() int64

func (*UsageByMetaRow) GetVendor

func (x *UsageByMetaRow) GetVendor() string

func (*UsageByMetaRow) ProtoMessage

func (*UsageByMetaRow) ProtoMessage()

func (*UsageByMetaRow) ProtoReflect

func (x *UsageByMetaRow) ProtoReflect() protoreflect.Message

func (*UsageByMetaRow) Reset

func (x *UsageByMetaRow) Reset()

func (*UsageByMetaRow) String

func (x *UsageByMetaRow) String() string

type UsageEvent

type UsageEvent struct {

	// Unique identifier for this event (UUID), used for idempotency
	EventId string `protobuf:"bytes,1,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
	// Timestamp when the event occurred (optional, server uses NOW() if not provided)
	OccurredAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=occurred_at,json=occurredAt,proto3" json:"occurred_at,omitempty"`
	// User identifier (max 256 chars)
	UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// Project identifier (max 256 chars)
	ProjectId string `protobuf:"bytes,4,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
	// Action identifier for debugging correlation (max 256 chars)
	ActionId string `protobuf:"bytes,5,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"`
	// LLM vendor (e.g., openai, anthropic, google)
	Vendor string `protobuf:"bytes,6,opt,name=vendor,proto3" json:"vendor,omitempty"`
	// Model name (e.g., gpt-4o-mini, claude-3-sonnet)
	Model string `protobuf:"bytes,7,opt,name=model,proto3" json:"model,omitempty"`
	// Request status
	Status Status `protobuf:"varint,8,opt,name=status,proto3,enum=usage.v1.Status" json:"status,omitempty"`
	// Request duration in milliseconds
	DurationMs int64 `protobuf:"varint,9,opt,name=duration_ms,json=durationMs,proto3" json:"duration_ms,omitempty"`
	// Input tokens count
	TokensInput int64 `protobuf:"varint,10,opt,name=tokens_input,json=tokensInput,proto3" json:"tokens_input,omitempty"`
	// Output tokens count
	TokensOutput int64 `protobuf:"varint,11,opt,name=tokens_output,json=tokensOutput,proto3" json:"tokens_output,omitempty"`
	// Total tokens (validated: must equal tokens_input + tokens_output if provided)
	TokensTotal int64 `protobuf:"varint,12,opt,name=tokens_total,json=tokensTotal,proto3" json:"tokens_total,omitempty"`
	// Normalized error class (optional)
	ErrorClass string `protobuf:"bytes,13,opt,name=error_class,json=errorClass,proto3" json:"error_class,omitempty"`
	// Vendor HTTP status code (optional)
	VendorHttpStatus int32 `protobuf:"varint,14,opt,name=vendor_http_status,json=vendorHttpStatus,proto3" json:"vendor_http_status,omitempty"`
	// Additional metadata as key-value pairs (optional, keep small)
	Meta map[string]string `` /* 136-byte string literal not displayed */
	// Cost of the call in nano-USD (1e-9 USD), computed by the caller from its
	// price catalog at settle time; stored as an immutable fact (optional, >= 0)
	CostNanousd int64 `protobuf:"varint,16,opt,name=cost_nanousd,json=costNanousd,proto3" json:"cost_nanousd,omitempty"`
	// Input tokens served from the vendor's prompt cache (optional, >= 0). Part of
	// tokens_input, not added to it; usually billed at a fraction of the input rate.
	CacheReadTokens int64 `protobuf:"varint,17,opt,name=cache_read_tokens,json=cacheReadTokens,proto3" json:"cache_read_tokens,omitempty"`
	// Input tokens written to the vendor's prompt cache (optional, >= 0). Part of
	// tokens_input; cache_read_tokens + cache_write_tokens must not exceed it.
	CacheWriteTokens int64 `protobuf:"varint,18,opt,name=cache_write_tokens,json=cacheWriteTokens,proto3" json:"cache_write_tokens,omitempty"`
	// contains filtered or unexported fields
}

UsageEvent represents a single LLM usage event

func (*UsageEvent) Descriptor deprecated

func (*UsageEvent) Descriptor() ([]byte, []int)

Deprecated: Use UsageEvent.ProtoReflect.Descriptor instead.

func (*UsageEvent) GetActionId

func (x *UsageEvent) GetActionId() string

func (*UsageEvent) GetCacheReadTokens

func (x *UsageEvent) GetCacheReadTokens() int64

func (*UsageEvent) GetCacheWriteTokens

func (x *UsageEvent) GetCacheWriteTokens() int64

func (*UsageEvent) GetCostNanousd

func (x *UsageEvent) GetCostNanousd() int64

func (*UsageEvent) GetDurationMs

func (x *UsageEvent) GetDurationMs() int64

func (*UsageEvent) GetErrorClass

func (x *UsageEvent) GetErrorClass() string

func (*UsageEvent) GetEventId

func (x *UsageEvent) GetEventId() string

func (*UsageEvent) GetMeta

func (x *UsageEvent) GetMeta() map[string]string

func (*UsageEvent) GetModel

func (x *UsageEvent) GetModel() string

func (*UsageEvent) GetOccurredAt

func (x *UsageEvent) GetOccurredAt() *timestamppb.Timestamp

func (*UsageEvent) GetProjectId

func (x *UsageEvent) GetProjectId() string

func (*UsageEvent) GetStatus

func (x *UsageEvent) GetStatus() Status

func (*UsageEvent) GetTokensInput

func (x *UsageEvent) GetTokensInput() int64

func (*UsageEvent) GetTokensOutput

func (x *UsageEvent) GetTokensOutput() int64

func (*UsageEvent) GetTokensTotal

func (x *UsageEvent) GetTokensTotal() int64

func (*UsageEvent) GetUserId

func (x *UsageEvent) GetUserId() string

func (*UsageEvent) GetVendor

func (x *UsageEvent) GetVendor() string

func (*UsageEvent) GetVendorHttpStatus

func (x *UsageEvent) GetVendorHttpStatus() int32

func (*UsageEvent) ProtoMessage

func (*UsageEvent) ProtoMessage()

func (*UsageEvent) ProtoReflect

func (x *UsageEvent) ProtoReflect() protoreflect.Message

func (*UsageEvent) Reset

func (x *UsageEvent) Reset()

func (*UsageEvent) String

func (x *UsageEvent) String() string

type UsageServiceClient

type UsageServiceClient interface {
	// RecordUsageEvent records a single usage event
	RecordUsageEvent(ctx context.Context, in *RecordUsageEventRequest, opts ...grpc.CallOption) (*RecordUsageEventResponse, error)
	// RecordUsageEvents records multiple usage events in a batch
	RecordUsageEvents(ctx context.Context, in *RecordUsageEventsRequest, opts ...grpc.CallOption) (*RecordUsageEventsResponse, error)
	// GetUsageSummary returns aggregated usage statistics
	GetUsageSummary(ctx context.Context, in *GetUsageSummaryRequest, opts ...grpc.CallOption) (*GetUsageSummaryResponse, error)
	// GetUsageByMeta returns usage aggregated over events carrying a meta
	// key/value, optionally split by a second meta key, always split by
	// vendor and model.
	GetUsageByMeta(ctx context.Context, in *GetUsageByMetaRequest, opts ...grpc.CallOption) (*GetUsageByMetaResponse, error)
}

UsageServiceClient is the client API for UsageService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

UsageService provides APIs for recording and querying LLM usage events

type UsageServiceServer

type UsageServiceServer interface {
	// RecordUsageEvent records a single usage event
	RecordUsageEvent(context.Context, *RecordUsageEventRequest) (*RecordUsageEventResponse, error)
	// RecordUsageEvents records multiple usage events in a batch
	RecordUsageEvents(context.Context, *RecordUsageEventsRequest) (*RecordUsageEventsResponse, error)
	// GetUsageSummary returns aggregated usage statistics
	GetUsageSummary(context.Context, *GetUsageSummaryRequest) (*GetUsageSummaryResponse, error)
	// GetUsageByMeta returns usage aggregated over events carrying a meta
	// key/value, optionally split by a second meta key, always split by
	// vendor and model.
	GetUsageByMeta(context.Context, *GetUsageByMetaRequest) (*GetUsageByMetaResponse, error)
	// contains filtered or unexported methods
}

UsageServiceServer is the server API for UsageService service. All implementations must embed UnimplementedUsageServiceServer for forward compatibility.

UsageService provides APIs for recording and querying LLM usage events

type UsageSummaryRow

type UsageSummaryRow struct {

	// Time bucket (day)
	Bucket *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=bucket,proto3" json:"bucket,omitempty"`
	// Dimension values (only populated if grouped by)
	ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
	UserId    string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Vendor    string `protobuf:"bytes,4,opt,name=vendor,proto3" json:"vendor,omitempty"`
	Model     string `protobuf:"bytes,5,opt,name=model,proto3" json:"model,omitempty"`
	ActionId  string `protobuf:"bytes,6,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"`
	Status    Status `protobuf:"varint,7,opt,name=status,proto3,enum=usage.v1.Status" json:"status,omitempty"`
	// Aggregated values
	TokensInput   int64 `protobuf:"varint,10,opt,name=tokens_input,json=tokensInput,proto3" json:"tokens_input,omitempty"`
	TokensOutput  int64 `protobuf:"varint,11,opt,name=tokens_output,json=tokensOutput,proto3" json:"tokens_output,omitempty"`
	TokensTotal   int64 `protobuf:"varint,12,opt,name=tokens_total,json=tokensTotal,proto3" json:"tokens_total,omitempty"`
	RequestCount  int64 `protobuf:"varint,13,opt,name=request_count,json=requestCount,proto3" json:"request_count,omitempty"`
	SumDurationMs int64 `protobuf:"varint,14,opt,name=sum_duration_ms,json=sumDurationMs,proto3" json:"sum_duration_ms,omitempty"`
	// Summed cost in nano-USD (1e-9 USD)
	CostNanousd int64 `protobuf:"varint,15,opt,name=cost_nanousd,json=costNanousd,proto3" json:"cost_nanousd,omitempty"`
	// Summed parts of tokens_input read from and written to the prompt cache
	CacheReadTokens  int64 `protobuf:"varint,16,opt,name=cache_read_tokens,json=cacheReadTokens,proto3" json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int64 `protobuf:"varint,17,opt,name=cache_write_tokens,json=cacheWriteTokens,proto3" json:"cache_write_tokens,omitempty"`
	// contains filtered or unexported fields
}

UsageSummaryRow represents a single row in the usage summary

func (*UsageSummaryRow) Descriptor deprecated

func (*UsageSummaryRow) Descriptor() ([]byte, []int)

Deprecated: Use UsageSummaryRow.ProtoReflect.Descriptor instead.

func (*UsageSummaryRow) GetActionId

func (x *UsageSummaryRow) GetActionId() string

func (*UsageSummaryRow) GetBucket

func (x *UsageSummaryRow) GetBucket() *timestamppb.Timestamp

func (*UsageSummaryRow) GetCacheReadTokens

func (x *UsageSummaryRow) GetCacheReadTokens() int64

func (*UsageSummaryRow) GetCacheWriteTokens

func (x *UsageSummaryRow) GetCacheWriteTokens() int64

func (*UsageSummaryRow) GetCostNanousd

func (x *UsageSummaryRow) GetCostNanousd() int64

func (*UsageSummaryRow) GetModel

func (x *UsageSummaryRow) GetModel() string

func (*UsageSummaryRow) GetProjectId

func (x *UsageSummaryRow) GetProjectId() string

func (*UsageSummaryRow) GetRequestCount

func (x *UsageSummaryRow) GetRequestCount() int64

func (*UsageSummaryRow) GetStatus

func (x *UsageSummaryRow) GetStatus() Status

func (*UsageSummaryRow) GetSumDurationMs

func (x *UsageSummaryRow) GetSumDurationMs() int64

func (*UsageSummaryRow) GetTokensInput

func (x *UsageSummaryRow) GetTokensInput() int64

func (*UsageSummaryRow) GetTokensOutput

func (x *UsageSummaryRow) GetTokensOutput() int64

func (*UsageSummaryRow) GetTokensTotal

func (x *UsageSummaryRow) GetTokensTotal() int64

func (*UsageSummaryRow) GetUserId

func (x *UsageSummaryRow) GetUserId() string

func (*UsageSummaryRow) GetVendor

func (x *UsageSummaryRow) GetVendor() string

func (*UsageSummaryRow) ProtoMessage

func (*UsageSummaryRow) ProtoMessage()

func (*UsageSummaryRow) ProtoReflect

func (x *UsageSummaryRow) ProtoReflect() protoreflect.Message

func (*UsageSummaryRow) Reset

func (x *UsageSummaryRow) Reset()

func (*UsageSummaryRow) String

func (x *UsageSummaryRow) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL