alchemy_llm/types/
usage.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4pub struct Usage {
5 pub input: u32,
6 pub output: u32,
7 pub cache_read: u32,
8 pub cache_write: u32,
9 pub total_tokens: u32,
10 pub cost: Cost,
11}
12
13#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
14pub struct Cost {
15 pub input: f64,
16 pub output: f64,
17 pub cache_read: f64,
18 pub cache_write: f64,
19 pub total: f64,
20}
21
22impl Default for Cost {
23 fn default() -> Self {
24 Self {
25 input: 0.0,
26 output: 0.0,
27 cache_read: 0.0,
28 cache_write: 0.0,
29 total: 0.0,
30 }
31 }
32}
33
34#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
35pub struct ModelCost {
36 pub input: f64,
37 pub output: f64,
38 pub cache_read: f64,
39 pub cache_write: f64,
40}
41
42#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
43#[serde(rename_all = "lowercase")]
44pub enum StopReason {
45 Stop,
46 Length,
47 ToolUse,
48 Error,
49 Aborted,
50}