Help us shape the future of Go! Take the 2026 Go Developer Survey

pricing

package
v1.154.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pricing calculates per-call costs without mutating catalog entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyConfigCost

func ApplyConfigCost(m *modelsdev.Model, id modelsdev.ID, cost *latest.CostConfig) *modelsdev.Model

ApplyConfigCost overlays a config-declared price table (USD per 1M tokens) onto the catalogue entry, returning m untouched when there is no override. It never mutates m: the store caches entries shared across sessions. When the model is uncatalogued (m == nil) a minimal entry is synthesized so the call is still priced — this is the escape hatch for custom endpoints that models.dev cannot describe.

func ApplyModelCost

func ApplyModelCost(m *modelsdev.Model, id modelsdev.ID, usage *chat.Usage, config base.Config) *modelsdev.Model

ApplyModelCost resolves configured and serving-tier rates for a call.

func ComputeMessageCost

func ComputeMessageCost(usage *chat.Usage, m *modelsdev.Model) *float64

ComputeMessageCost prices the whole call at the tier selected by its prompt size. Nil means unpriced; a non-nil zero means free. Messages and hooks share this value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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