Token usage from a single run.
| 37 | |
| 38 | @dataclass |
| 39 | class TokenUsage: |
| 40 | """Token usage from a single run.""" |
| 41 | input_tokens: int |
| 42 | output_tokens: int |
| 43 | cache_read_tokens: int |
| 44 | cache_creation_tokens: int |
| 45 | total_cost_usd: Optional[float] = None |
| 46 | duration_ms: Optional[int] = None |
| 47 | |
| 48 | @property |
| 49 | def total_input(self) -> int: |
| 50 | """Total input tokens including cache.""" |
| 51 | return self.input_tokens + self.cache_read_tokens + self.cache_creation_tokens |
| 52 | |
| 53 | @property |
| 54 | def total(self) -> int: |
| 55 | """Total tokens (input + output).""" |
| 56 | return self.total_input + self.output_tokens |
| 57 | |
| 58 | |
| 59 | @dataclass |
no outgoing calls
no test coverage detected