Skip to content

Usage

Base classes

Name Children Inherits
Protocol
typing
Base class for protocol classes.

⋔ Inheritance diagram

graph TD
  662240892["pydanticai_cost.Usage"]
  1073422405["typing.Protocol"]
  3481597255["typing.Generic"]
  2751680898["builtins.object"]
  1073422405 --> 662240892
  3481597255 --> 1073422405
  2751680898 --> 3481597255

🛈 DocStrings

Bases: Protocol

Protocol matching pydantic-ai's Usage object structure.

Source code in src/tokonomics/pydanticai_cost.py
@runtime_checkable
class Usage(Protocol):
    """Protocol matching pydantic-ai's Usage object structure."""

    input_tokens: int
    """Number of tokens in the request/prompt"""
    output_tokens: int
    """Number of tokens in the response/completion"""

    @property
    def total_tokens(self) -> int:
        """Total number of tokens used."""
        ...

input_tokens instance-attribute

input_tokens: int

Number of tokens in the request/prompt

output_tokens instance-attribute

output_tokens: int

Number of tokens in the response/completion

total_tokens property

total_tokens: int

Total number of tokens used.

:fa-brands-github: Show source on GitHub