credits

package
v0.5.2-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: 9 Imported by: 0

Documentation

Overview

Package credits reads the default model service's account balance without sending a completion or keeping a dollar amount on disk.

Index

Constants

View Source
const LowCreditsUSD = 0.50

LowCreditsUSD covers one worst-case turn on the shipped DeepSeek default: roughly $0.04 of input and $0.30 of output at its published limits, rounded up.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reading

type Reading struct{ Known, Low bool }

Reading says only whether the balance is known and below the one threshold.

func Read

func Read(ctx context.Context, client *http.Client, baseURL, key string) (Reading, error)

Read asks for the account balance and the key's own cap. An absent number is unknown; a failed request is an error and must not change a previous reading.

type Reason

type Reason uint8

Reason names the event that asked for a balance. A launch or changed key is never debounced; repeated refusals and paid-model switches share a quiet span.

const (
	Launch Reason = iota
	KeyChanged
	Refusal
	PaidSwitch
)

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

Trigger permits one read at a time and coalesces bursts after it finishes.

func NewTrigger

func NewTrigger(now func() time.Time) *Trigger

func (*Trigger) Begin

func (t *Trigger) Begin(reason Reason) bool

func (*Trigger) End

func (t *Trigger) End()

Jump to

Keyboard shortcuts

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