pricing

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cost

type Cost struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	CacheRead  float64 `json:"cache_read,omitempty"`
	CacheWrite float64 `json:"cache_write,omitempty"`
	Total      float64 `json:"total"`
	Currency   string  `json:"currency"`
}

func Calculate

func Calculate(model string, usage litellm.Usage, table map[string]ModelPricing) (Cost, error)

type ModelCapabilities

type ModelCapabilities struct {
	Provider          string `json:"litellm_provider"`
	MaxInputTokens    int    `json:"max_input_tokens"`
	MaxOutputTokens   int    `json:"max_output_tokens"`
	SupportsTools     bool   `json:"supports_function_calling"`
	SupportsVision    bool   `json:"supports_vision"`
	SupportsReasoning bool   `json:"supports_reasoning"`
}

type ModelPricing

type ModelPricing struct {
	InputCostPerToken      float64 `json:"input_cost_per_token"`
	OutputCostPerToken     float64 `json:"output_cost_per_token"`
	CacheReadCostPerToken  float64 `json:"cache_read_input_token_cost,omitempty"`
	CacheWriteCostPerToken float64 `json:"cache_creation_input_token_cost,omitempty"`
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Calculate

func (r *Registry) Calculate(model string, usage litellm.Usage) (Cost, error)

func (*Registry) Capabilities

func (r *Registry) Capabilities(model string) (ModelCapabilities, bool)

func (*Registry) Get

func (r *Registry) Get(model string) (ModelPricing, bool)

func (*Registry) LoadFromReader

func (r *Registry) LoadFromReader(reader io.Reader) error

func (*Registry) LoadFromURL

func (r *Registry) LoadFromURL(ctx context.Context, url string) error

func (*Registry) Set

func (r *Registry) Set(model string, price ModelPricing) error

Jump to

Keyboard shortcuts

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