codetether_agent/telemetry/tokens/counts.rs
1//! Input/output token counts with field names that match most provider APIs.
2
3use serde::{Deserialize, Serialize};
4
5/// Token counts using the `input_tokens` / `output_tokens` naming convention
6/// favoured by most provider wire formats (Anthropic, Bedrock, OpenAI v2).
7///
8/// Prefer [`super::TokenTotals`] for internal aggregation; use this type when
9/// you're crossing a serialization boundary that expects those field names.
10///
11/// # Examples
12///
13/// ```rust
14/// use codetether_agent::telemetry::TokenCounts;
15///
16/// let c = TokenCounts::new(2_048, 512);
17/// assert_eq!(c.input_tokens, 2_048);
18/// assert_eq!(c.output_tokens, 512);
19/// ```
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct TokenCounts {
22 /// Prompt / input tokens billed at the input rate.
23 pub input_tokens: u64,
24 /// Completion / output tokens billed at the output rate.
25 pub output_tokens: u64,
26}
27
28impl TokenCounts {
29 /// Construct a new pair.
30 pub fn new(input_tokens: u64, output_tokens: u64) -> Self {
31 Self {
32 input_tokens,
33 output_tokens,
34 }
35 }
36}