pricebook

package
v2.37.14 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pricebook defines the serialized AI Gateway model price book.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, rows []Row) error

Write encodes a price book in the on-disk form of the generated artifact.

Types

type Key

type Key struct {
	Provider string
	Model    string
}

Key identifies a model within a provider.

func (Key) String

func (k Key) String() string

type Row

type Row struct {
	Provider        string `json:"provider"`
	Model           string `json:"model"`
	InputPrice      *int64 `json:"input_price"`
	OutputPrice     *int64 `json:"output_price"`
	CacheReadPrice  *int64 `json:"cache_read_price"`
	CacheWritePrice *int64 `json:"cache_write_price"`
}

Row is one provider and model entry in the generated price book. Pointer fields preserve the distinction between a missing price and an explicit zero.

NOTE: the batch SQL upsert extracts these fields from the raw JSON by name, so the tags here and that query must stay in sync. TestSeedFromBytes/ RowTagsMatchSQLColumns in the parent package guards that.

func Parse

func Parse(data []byte) ([]Row, error)

Parse decodes a generated price book.

func (Row) Key

func (r Row) Key() Key

Key returns the provider and model identity of the row.

func (Row) SamePrices

func (r Row) SamePrices(other Row) bool

SamePrices reports whether two rows carry identical prices. Provider and model are ignored, so it is only meaningful for rows with the same Key. A price moving to or from null counts as a difference, matching the null handling in the batch SQL upsert.

Jump to

Keyboard shortcuts

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