rskit_ai/usage.rs
1//! Usage and cost vocabulary.
2
3use serde::{Deserialize, Serialize};
4
5/// Token usage counters.
6#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
7pub struct Usage {
8 /// Prompt/input tokens consumed.
9 pub input_tokens: u64,
10 /// Completion/output tokens produced.
11 pub output_tokens: u64,
12 /// Tokens served from provider cache.
13 #[serde(default)]
14 pub cached_tokens: u64,
15 /// Reasoning tokens reported by providers that expose them.
16 #[serde(default)]
17 pub reasoning_tokens: u64,
18}
19
20/// Decimal money amount represented in millionths of the currency unit.
21#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
22pub struct Money {
23 /// Amount in millionths of the currency unit.
24 pub micros: i128,
25}
26
27/// Cost breakdown for an AI operation.
28#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
29pub struct Cost {
30 /// Input token cost.
31 pub input: Money,
32 /// Output token cost.
33 pub output: Money,
34 /// Cached token cost.
35 pub cached: Money,
36 /// Reasoning token cost.
37 pub reasoning: Money,
38 /// ISO 4217 currency code.
39 pub currency: String,
40}