tokenaccounting

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(opts Options) http.Handler

Types

type CountCallService

type CountCallService interface {
	CountCall(context.Context, app.CountCallInput) (app.CountResult, error)
}

CountCallService is the concrete app CountCall seam (*tokenaccounting/app.Service).

type CountRequest

type CountRequest struct {
	Backend string      `json:"backend"`
	Model   string      `json:"model"`
	Mode    app.Mode    `json:"mode,omitempty"`
	Call    lipapi.Call `json:"call"`
}

type CountResponse

type CountResponse struct {
	Planes []PlaneCount `json:"planes"`
}

type Options

type Options struct {
	Enabled      bool
	MaxBodyBytes int64
	Service      Service
}

type PlaneCount

type PlaneCount struct {
	Plane             lipapi.UsagePlane     `json:"plane"`
	Tokens            TokenDimensions       `json:"tokens"`
	Source            lipapi.UsageSource    `json:"source"`
	Authority         lipapi.UsageAuthority `json:"authority"`
	Tokenizer         lipapi.TokenizerRef   `json:"tokenizer"`
	UnavailableReason string                `json:"unavailable_reason,omitempty"`
	FallbackReason    app.FallbackReason    `json:"fallback_reason,omitempty"`
}

type Service

type Service interface {
	Count(context.Context, CountRequest) (CountResponse, error)
}

Service is the narrow application seam used by the admin HTTP adapter.

func AdaptCountCallService

func AdaptCountCallService(svc CountCallService) Service

AdaptCountCallService projects CountCall onto Service. Typed-nil *app.Service → nil.

type TokenDimensions

type TokenDimensions struct {
	Input      int `json:"input,omitempty"`
	Output     int `json:"output,omitempty"`
	CacheRead  int `json:"cache_read,omitempty"`
	CacheWrite int `json:"cache_write,omitempty"`
	Reasoning  int `json:"reasoning,omitempty"`
	Total      int `json:"total,omitempty"`
}

Jump to

Keyboard shortcuts

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