pricing

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pricing validates versioned token pricing rules and calculates integer micros.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(rule Rule, usage Usage, occurredAt time.Time) (int64, error)

Types

type Prices

type Prices struct {
	InputMicros       int64 `json:"inputMicros"`
	CachedInputMicros int64 `json:"cachedInputMicros"`
	CacheWriteMicros  int64 `json:"cacheWriteMicros"`
	OutputMicros      int64 `json:"outputMicros"`
	ReasoningMicros   int64 `json:"reasoningMicros"`
}

type Rule

type Rule struct {
	SchemaVersion int        `json:"schemaVersion"`
	Provider      string     `json:"provider"`
	ModelPattern  string     `json:"modelPattern"`
	ValidFrom     time.Time  `json:"validFrom"`
	ValidUntil    *time.Time `json:"validUntil"`
	BillingMode   string     `json:"billingMode"`
	Currency      string     `json:"currency"`
	UnitTokens    int64      `json:"unitTokens"`
	Prices        Prices     `json:"prices"`
	Version       string     `json:"version"`
}

func Load

func Load(reader io.Reader) (Rule, error)

type Usage

type Usage struct {
	InputTokens       int64
	CachedInputTokens int64
	CacheWriteTokens  int64
	OutputTokens      int64
	ReasoningTokens   int64
}

Jump to

Keyboard shortcuts

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