Skip to content

cayu.context.counting

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.

from cayu.context import ContextCountingConfig

Runtime controls for pre-call input token counting.

observe records provider counts and reconciles them against completed model usage when available. It does not enforce budgets or mutate context. Provider-backed counters may make an extra provider request, so this is observability/debugging infrastructure rather than a default overflow guard.

Bases: BaseModel.

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
mode ContextCountingMode ContextCountingMode.OFF
ContextCountingConfig.validate_mode(value: object) -> ContextCountingMode

Release source · Runtime guarantees · Capability guides

from cayu.context import ContextCountingMode

Bases: StrEnum.

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
OFF class attribute 'off'
OBSERVE class attribute 'observe'

Release source · Runtime guarantees · Capability guides

from cayu.context import copy_context_counting_config
copy_context_counting_config(config: ContextCountingConfig | None) -> ContextCountingConfig

Release source · Runtime guarantees · Capability guides