usage

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, u *Usage) context.Context

NewContext returns a new Context that carries the given Usage.

Types

type Usage

type Usage struct {
	// Total requests made to the LLM API.
	Requests uint64

	// Total input tokens sent, across all requests.
	InputTokens uint64

	// Details about the input tokens, matching responses API usage details.
	InputTokensDetails responses.ResponseUsageInputTokensDetails

	// Total output tokens received, across all requests.
	OutputTokens uint64

	// Details about the output tokens, matching responses API usage details.
	OutputTokensDetails responses.ResponseUsageOutputTokensDetails

	// Total tokens sent and received, across all requests.
	TotalTokens uint64
}

func FromContext

func FromContext(ctx context.Context) (*Usage, bool)

FromContext returns the Usage value stored in ctx, if any.

func NewUsage

func NewUsage() *Usage

func (*Usage) Add

func (u *Usage) Add(other *Usage)

Jump to

Keyboard shortcuts

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