cayu.budgets.pricing
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
CausalBudgetCostSummary
Section titled “CausalBudgetCostSummary”from cayu.budgets import CausalBudgetCostSummaryEstimated cost for all sessions sharing one causal budget id.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
causal_budget_id |
str |
required |
session_ids |
list[str] |
Field(default_factory=list) |
session_count |
StrictInt |
Field(default=0, ge=0) |
currency |
str |
required |
model_steps |
StrictInt |
Field(ge=0) |
priced_model_steps |
StrictInt |
Field(ge=0) |
unpriced_model_steps |
StrictInt |
Field(ge=0) |
auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
unpriced_auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
missing_usage_model_steps |
StrictInt |
Field(default=0, ge=0) |
missing_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
unsupported_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
total_cost |
Decimal |
Field(ge=0) |
line_items |
tuple[CostLineItem, ...] |
Field(default_factory=tuple) |
session_costs |
tuple[SessionCostSummary, ...] |
Field(default_factory=tuple) |
copy_nested_contracts (method)
Section titled “copy_nested_contracts (method)”CausalBudgetCostSummary.copy_nested_contracts(value: object) -> objectvalidate_identity (method)
Section titled “validate_identity (method)”CausalBudgetCostSummary.validate_identity(value: str, info) -> strcopy_session_ids (method)
Section titled “copy_session_ids (method)”CausalBudgetCostSummary.copy_session_ids(value: list[str], info) -> list[str]Release source · Runtime guarantees · Capability guides
ContextualPricingRequirement
Section titled “ContextualPricingRequirement”from cayu.budgets import ContextualPricingRequirementCommercial constraints every contextual price for one provider must declare.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
provider_name |
str |
required |
dimensions |
tuple[str, ...] |
required |
requires_cache_write_ttls |
StrictBool |
False |
validate_provider_name (method)
Section titled “validate_provider_name (method)”ContextualPricingRequirement.validate_provider_name(value: str, info) -> strvalidate_requirement_dimensions (method)
Section titled “validate_requirement_dimensions (method)”ContextualPricingRequirement.validate_requirement_dimensions(value: tuple[str, ...], info) -> tuple[str, ...]Release source · Runtime guarantees · Capability guides
copy_price_book
Section titled “copy_price_book”from cayu.budgets import copy_price_bookcopy_price_book(price_book: PriceBook) -> PriceBookRelease source · Runtime guarantees · Capability guides
CostLineItem
Section titled “CostLineItem”from cayu.budgets import CostLineItemEstimated cost for one model attempt or standalone hosted resource evidence.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
model_step |
StrictInt |
Field(ge=0) |
auxiliary_attempt |
StrictBool |
False |
execution_profile_fingerprint |
str | None |
Field(default=None, max_length=64, exclude_if=lambda value: value is None) |
provider_name |
str | None |
None |
requested_model |
str | None |
None |
model |
str | None |
None |
billing_identity |
BillingIdentity | None |
Field(default=None, exclude_if=lambda value: value is None) |
pricing_provider_name |
str | None |
None |
pricing_model |
str | None |
None |
pricing_match |
Literal['exact', 'prefix', 'resource_mapping'] | None |
None |
pricing_provenance |
Provenance | None |
None |
pricing_effective_from |
date | None |
None |
pricing_effective_through |
date | None |
None |
pricing_tier_max_input_tokens |
StrictInt | None |
None |
priced |
StrictBool |
required |
currency |
str |
required |
input_tokens |
StrictInt |
Field(ge=0) |
output_tokens |
StrictInt |
Field(ge=0) |
cache_read_input_tokens |
StrictInt |
Field(ge=0) |
cache_write_input_tokens |
StrictInt |
Field(ge=0) |
cache_write_5m_input_tokens |
StrictInt |
Field(default=0, ge=0, exclude_if=lambda value: value == 0) |
cache_write_1h_input_tokens |
StrictInt |
Field(default=0, ge=0, exclude_if=lambda value: value == 0) |
cache_write_unknown_ttl_input_tokens |
StrictInt |
Field(default=0, ge=0, exclude_if=lambda value: value == 0) |
web_search_calls |
StrictInt |
Field(default=0, ge=0) |
web_search_outcome_unknown |
StrictInt |
Field(default=0, ge=0) |
uncached_input_tokens |
StrictInt |
Field(ge=0) |
input_cost |
Decimal |
Field(ge=0) |
output_cost |
Decimal |
Field(ge=0) |
cache_read_input_cost |
Decimal |
Field(ge=0) |
cache_write_input_cost |
Decimal |
Field(ge=0) |
web_search_cost |
Decimal |
Field(default=Decimal('0'), ge=0) |
total_cost |
Decimal |
Field(ge=0) |
unpriced_reason |
UnpricedReason | None |
None |
missing_pricing_reason |
str | None |
None |
copy_nested_contracts (method)
Section titled “copy_nested_contracts (method)”CostLineItem.copy_nested_contracts(value: object) -> objectvalidate_optional_strings (method)
Section titled “validate_optional_strings (method)”CostLineItem.validate_optional_strings(value: str | None, info) -> str | NoneRelease source · Runtime guarantees · Capability guides
default_model_catalog
Section titled “default_model_catalog”from cayu.budgets import default_model_catalogLoad Cayu’s bundled, dated model-catalog snapshot.
The resource is parsed and validated on every call so callers never share mutable
ModelCatalog state. Loading is deterministic and performs no network access.
default_model_catalog() -> ModelCatalogRelease source · Runtime guarantees · Capability guides
default_price_book
Section titled “default_price_book”from cayu.budgets import default_price_bookLoad Cayu’s bundled, dated price book without network access.
default_price_book() -> PriceBookRelease source · Runtime guarantees · Capability guides
dump_model_catalog
Section titled “dump_model_catalog”from cayu.budgets import dump_model_catalogDeterministic JSON: models sorted by (provider_name, model), sorted keys, trailing newline — stable enough to commit and diff.
dump_model_catalog(catalog: ModelCatalog) -> strRelease source · Runtime guarantees · Capability guides
dump_price_book
Section titled “dump_price_book”from cayu.budgets import dump_price_bookSerialize a price book deterministically for review and packaging.
dump_price_book(price_book: PriceBook) -> strRelease source · Runtime guarantees · Capability guides
estimate_causal_budget_cost
Section titled “estimate_causal_budget_cost”from cayu.budgets import estimate_causal_budget_costestimate_causal_budget_cost(*, causal_budget_id: str, session_ids: list[str], events: list[Event], pricing: PriceBook, currency: str='USD') -> CausalBudgetCostSummaryRelease source · Runtime guarantees · Capability guides
estimate_model_step_cost
Section titled “estimate_model_step_cost”from cayu.budgets import estimate_model_step_costEstimate one normalized model step in its price-book-native currency.
estimate_model_step_cost(*, metrics: UsageMetrics, pricing: PriceBook, effective_on: date) -> ModelStepCostEstimateRelease source · Runtime guarantees · Capability guides
estimate_session_cost
Section titled “estimate_session_cost”from cayu.budgets import estimate_session_costestimate_session_cost(*, session_id: str, events: list[Event], pricing: PriceBook, currency: str='USD') -> SessionCostSummaryRelease source · Runtime guarantees · Capability guides
load_model_catalog
Section titled “load_model_catalog”from cayu.budgets import load_model_catalogLoad a catalog from a JSON file written by dump_model_catalog.
load_model_catalog(path: str | Path) -> ModelCatalogRelease source · Runtime guarantees · Capability guides
load_price_book
Section titled “load_price_book”from cayu.budgets import load_price_bookLoad a price book from a JSON file written by dump_price_book.
load_price_book(path: str | Path) -> PriceBookRelease source · Runtime guarantees · Capability guides
ModelCatalog
Section titled “ModelCatalog”from cayu.budgets import ModelCatalogA versioned metadata registry used for model discovery and routing.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
catalog_version |
str |
required |
generated_at |
str |
required |
models |
tuple[ModelInfo, ...] |
Field(min_length=1) |
validate_identity (method)
Section titled “validate_identity (method)”ModelCatalog.validate_identity(value: str, info) -> strvalidate_unique_models (method)
Section titled “validate_unique_models (method)”ModelCatalog.validate_unique_models() -> ModelCatalogresolve (method)
Section titled “resolve (method)”ModelCatalog.resolve(*, provider_name: str | None, model: str | None) -> ModelInfo | NoneThe most-specific metadata record whose declared identity matches the model.
match (method)
Section titled “match (method)”ModelCatalog.match(*, provider_name: str, model: str) -> ModelInfo | NoneExact (provider_name, model) record lookup (see resolve for declared
prefix matching).
route (method)
Section titled “route (method)”ModelCatalog.route(*, provider_name: str | None=None, min_context: int=0, needs_vision: bool=False, needs_tools: bool=False, include_deprecated: bool=False) -> list[ModelInfo]Non-deprecated models (by default) matching the capability filters.
Release source · Runtime guarantees · Capability guides
ModelInfo
Section titled “ModelInfo”from cayu.budgets import ModelInfoA model’s identity, objective capabilities, lifecycle, and provenance.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
provider_name |
str |
required |
model |
str |
required |
family |
str | None |
None |
aliases |
tuple[str, ...] |
() |
context_window |
StrictInt | None |
Field(default=None, gt=0) |
max_output_tokens |
StrictInt | None |
Field(default=None, gt=0) |
modalities_in |
tuple[str, ...] |
('text',) |
modalities_out |
tuple[str, ...] |
('text',) |
tool_calling |
StrictBool |
False |
reasoning |
StrictBool |
False |
structured_output |
StrictBool |
False |
prompt_caching |
StrictBool |
False |
hosted_web_search |
StrictBool |
False |
release_date |
date | None |
None |
knowledge_cutoff |
date | None |
None |
deprecated |
StrictBool |
False |
retirement_date |
date | None |
None |
match |
Literal['exact', 'prefix'] |
'prefix' |
match_prefixes |
tuple[str, ...] |
() |
provenance |
Provenance |
required |
validate_identity (method)
Section titled “validate_identity (method)”ModelInfo.validate_identity(value: str, info) -> strvalidate_optional_family (method)
Section titled “validate_optional_family (method)”ModelInfo.validate_optional_family(value: str | None, info) -> str | Nonevalidate_string_members (method)
Section titled “validate_string_members (method)”ModelInfo.validate_string_members(value: tuple[str, ...], info) -> tuple[str, ...]Release source · Runtime guarantees · Capability guides
ModelPrice
Section titled “ModelPrice”from cayu.budgets import ModelPricePricing identity and its non-overlapping effective schedules.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
provider_name |
str |
required |
model |
str |
required |
aliases |
tuple[str, ...] |
() |
match |
Literal['exact', 'prefix'] |
'prefix' |
match_prefixes |
tuple[str, ...] |
() |
pricing_context |
PricingContextSelector | None |
None |
cache_write_ttls |
tuple[Literal['5m', '1h'], ...] |
() |
schedules |
tuple[PriceSchedule, ...] |
Field(min_length=1) |
fixed (method)
Section titled “fixed (method)”ModelPrice.fixed(*, provider_name: str, model: str, input_per_million: Decimal, output_per_million: Decimal, cache_read_input_per_million: Decimal | None=None, cache_write_input_per_million: Decimal | None=None, web_search_per_thousand: Decimal | None=None, currency: str='USD', aliases: tuple[str, ...]=(), match: Literal['exact', 'prefix']='prefix', match_prefixes: tuple[str, ...]=(), pricing_context: PricingContextSelector | Mapping[str, tuple[str, ...]] | None=None, cache_write_ttls: tuple[Literal['5m', '1h'], ...]=(), provenance: Provenance | None=None) -> ModelPriceBuild one application-owned price with no validity bound.
Use explicit PriceSchedule values when a rate has a known start or end.
validate_identity (method)
Section titled “validate_identity (method)”ModelPrice.validate_identity(value: str, info) -> strvalidate_string_members (method)
Section titled “validate_string_members (method)”ModelPrice.validate_string_members(value: tuple[str, ...], info) -> tuple[str, ...]validate_schedules (method)
Section titled “validate_schedules (method)”ModelPrice.validate_schedules() -> ModelPriceschedule_on (method)
Section titled “schedule_on (method)”ModelPrice.schedule_on(effective_on: date) -> PriceSchedule | NoneRelease source · Runtime guarantees · Capability guides
ModelStepCostEstimate
Section titled “ModelStepCostEstimate”from cayu.budgets import ModelStepCostEstimateCurrency-local cost outcome for one normalized model step.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
priced |
StrictBool |
required |
currency |
str | None |
None |
total_cost |
Decimal |
Field(ge=0) |
unpriced_reason |
UnpricedReason | None |
None |
missing_pricing_reason |
str | None |
None |
pricing_provider_name |
str | None |
None |
pricing_model |
str | None |
None |
validate_optional_text (method)
Section titled “validate_optional_text (method)”ModelStepCostEstimate.validate_optional_text(value: str | None, info) -> str | Nonevalidate_outcome (method)
Section titled “validate_outcome (method)”ModelStepCostEstimate.validate_outcome() -> ModelStepCostEstimateRelease source · Runtime guarantees · Capability guides
PriceBook
Section titled “PriceBook”from cayu.budgets import PriceBookA versioned collection of application-owned commercial model prices.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
price_book_version |
str |
'application' |
generated_at |
str |
'unspecified' |
prices |
tuple[ModelPrice, ...] |
Field(min_length=1) |
contextual_pricing_requirements |
tuple[ContextualPricingRequirement, ...] |
() |
resource_mappings |
tuple[PricingResourceMapping, ...] |
() |
validate_identity (method)
Section titled “validate_identity (method)”PriceBook.validate_identity(value: str, info) -> strvalidate_unique_matches (method)
Section titled “validate_unique_matches (method)”PriceBook.validate_unique_matches() -> PriceBookRelease source · Runtime guarantees · Capability guides
PriceSchedule
Section titled “PriceSchedule”from cayu.budgets import PriceScheduleOne price schedule, effective on inclusive UTC calendar dates.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
effective_from |
date | None |
None |
effective_through |
date | None |
None |
pricing |
TieredPricing |
required |
provenance |
Provenance |
required |
validate_window (method)
Section titled “validate_window (method)”PriceSchedule.validate_window() -> PriceScheduleapplies_on (method)
Section titled “applies_on (method)”PriceSchedule.applies_on(effective_on: date) -> boolRelease source · Runtime guarantees · Capability guides
PriceTier
Section titled “PriceTier”from cayu.budgets import PriceTierOne context band of tiered pricing.
Tiers are ordered ascending by max_input_tokens; the final tier may use
None to mean “and above”.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
max_input_tokens |
StrictInt | None |
Field(default=None, gt=0) |
input_per_million |
Decimal |
Field(ge=0) |
output_per_million |
Decimal |
Field(ge=0) |
cache_read_input_per_million |
Decimal | None |
Field(default=None, ge=0) |
cache_write_input_per_million |
Decimal | None |
Field(default=None, ge=0, exclude_if=lambda value: value is None) |
validate_decimal (method)
Section titled “validate_decimal (method)”PriceTier.validate_decimal(value: Decimal | None, info) -> Decimal | NoneRelease source · Runtime guarantees · Capability guides
PricingContextSelector
Section titled “PricingContextSelector”from cayu.budgets import PricingContextSelectorExact pricing dimensions accepted by one contextual price row.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
dimensions |
Mapping[str, tuple[str, ...]] |
required |
validate_dimensions (method)
Section titled “validate_dimensions (method)”PricingContextSelector.validate_dimensions(value: Any) -> dict[str, tuple[str, ...]]freeze_dimensions (method)
Section titled “freeze_dimensions (method)”PricingContextSelector.freeze_dimensions(value: Mapping[str, tuple[str, ...]]) -> Mapping[str, tuple[str, ...]]serialize_dimensions (method)
Section titled “serialize_dimensions (method)”PricingContextSelector.serialize_dimensions(value: Mapping[str, tuple[str, ...]]) -> dict[str, list[str]]storage_key (method)
Section titled “storage_key (method)”PricingContextSelector.storage_key() -> tuple[tuple[str, tuple[str, ...]], ...]matches (method)
Section titled “matches (method)”PricingContextSelector.matches(context: PricingContext) -> boolRelease source · Runtime guarantees · Capability guides
PricingResourceMapping
Section titled “PricingResourceMapping”from cayu.budgets import PricingResourceMappingMap one opaque provider resource to an explicit pricing model.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
provider_name |
str |
required |
resource_id |
str |
required |
pricing_model |
str |
required |
validate_mapping_identity (method)
Section titled “validate_mapping_identity (method)”PricingResourceMapping.validate_mapping_identity(value: str, info) -> strRelease source · Runtime guarantees · Capability guides
Provenance
Section titled “Provenance”from cayu.budgets import ProvenanceWhere model or pricing facts came from and when they were checked.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
source |
str |
required |
url |
str |
required |
as_of |
str |
required |
validate_identity (method)
Section titled “validate_identity (method)”Provenance.validate_identity(value: str, info) -> strRelease source · Runtime guarantees · Capability guides
SessionCostSummary
Section titled “SessionCostSummary”from cayu.budgets import SessionCostSummaryDetailed cost inspection, retaining one line item per completed step.
Bases: SessionCostTotals.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
session_id |
str |
required |
currency |
str |
required |
model_steps |
StrictInt |
Field(ge=0) |
priced_model_steps |
StrictInt |
Field(ge=0) |
unpriced_model_steps |
StrictInt |
Field(ge=0) |
auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
unpriced_auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
missing_usage_model_steps |
StrictInt |
Field(default=0, ge=0) |
missing_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
unsupported_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
total_cost |
Decimal |
Field(ge=0) |
line_items |
tuple[CostLineItem, ...] |
Field(default_factory=tuple) |
validate_identity (method)
Section titled “validate_identity (method)”SessionCostSummary.validate_identity(value: str, info) -> strvalidate_step_totals (method)
Section titled “validate_step_totals (method)”SessionCostSummary.validate_step_totals() -> SessionCostTotalscopy_line_items (method)
Section titled “copy_line_items (method)”SessionCostSummary.copy_line_items(value: object) -> objectvalidate_step_accounting (method)
Section titled “validate_step_accounting (method)”SessionCostSummary.validate_step_accounting() -> SessionCostSummaryRelease source · Runtime guarantees · Capability guides
SessionCostTotals
Section titled “SessionCostTotals”from cayu.budgets import SessionCostTotalsExact cost counters for routine enforcement, without historical line items.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
session_id |
str |
required |
currency |
str |
required |
model_steps |
StrictInt |
Field(ge=0) |
priced_model_steps |
StrictInt |
Field(ge=0) |
unpriced_model_steps |
StrictInt |
Field(ge=0) |
auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
unpriced_auxiliary_attempts |
StrictInt |
Field(default=0, ge=0) |
missing_usage_model_steps |
StrictInt |
Field(default=0, ge=0) |
missing_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
unsupported_pricing_model_steps |
StrictInt |
Field(default=0, ge=0) |
total_cost |
Decimal |
Field(ge=0) |
validate_identity (method)
Section titled “validate_identity (method)”SessionCostTotals.validate_identity(value: str, info) -> strvalidate_step_totals (method)
Section titled “validate_step_totals (method)”SessionCostTotals.validate_step_totals() -> SessionCostTotalsRelease source · Runtime guarantees · Capability guides
TieredPricing
Section titled “TieredPricing”from cayu.budgets import TieredPricingFull pricing for one model: context-band tiers plus optional batch and cache-write-duration rates.
Only the context-band standard tiers feed the cost engine today. A tier-local
cache-write rate takes precedence over the model-wide
cache_write_5m_per_million fallback.
batch is carried for completeness and future use. Contextual pricing
applies cache_write_1h_per_million only to usage explicitly attributed
to a one-hour cache write.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
currency |
str |
'USD' |
standard |
tuple[PriceTier, ...] |
Field(min_length=1) |
batch |
PriceTier | None |
None |
cache_write_5m_per_million |
Decimal | None |
Field(default=None, ge=0) |
cache_write_1h_per_million |
Decimal | None |
Field(default=None, ge=0) |
web_search_per_thousand |
Decimal | None |
Field(default=None, ge=0, exclude_if=lambda value: value is None) |
validate_currency (method)
Section titled “validate_currency (method)”TieredPricing.validate_currency(value: str, info) -> strvalidate_decimal (method)
Section titled “validate_decimal (method)”TieredPricing.validate_decimal(value: Decimal | None, info) -> Decimal | Nonevalidate_tier_order (method)
Section titled “validate_tier_order (method)”TieredPricing.validate_tier_order() -> TieredPricingbase (method)
Section titled “base (method)”TieredPricing.base() -> PriceTierThe smallest-context (first) tier — the base price.
tier_for (method)
Section titled “tier_for (method)”TieredPricing.tier_for(input_tokens: int) -> PriceTierThe tier whose band contains input_tokens (the open-ended tier, or
the largest bounded tier if none is open-ended and the count overflows).