modelusage

package
v0.11.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package modelusage propagates actual model-call accounting across optional middleware without depending on the agent or changing provider contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Before

func Before(ctx context.Context) error

func CheckAccounting

func CheckAccounting(ctx context.Context) error

func Record

func Record(ctx context.Context, usage providers.Usage) error

Record accepts only a provider-reported usage value; estimates of prompt or output size are not billable usage and must never be supplied here.

func RecordAccounting

func RecordAccounting(ctx context.Context, usage providers.Usage) error

func RecordSample

func RecordSample(ctx context.Context, model string, usage providers.Usage, reported bool) error

func WithAccounting

func WithAccounting(ctx context.Context, accounting Accounting) context.Context

func WithCallbacks

func WithCallbacks(ctx context.Context, before func(context.Context) error, record func(context.Context, providers.Usage) error) context.Context

func WithSample

func WithSample(ctx context.Context, model string, reported bool) context.Context

Types

type Accounting

type Accounting struct {
	Before func(context.Context) error
	Record func(context.Context, string, providers.Usage, bool) error
}

Accounting is independent of a session's goal. A parent task can therefore charge several agents, including agents without a standing session goal.

Jump to

Keyboard shortcuts

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