Skip to main content

langfuse_client_base/models/
usage.rs

1/*
2 * langfuse
3 *
4 * ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings:  - username: Langfuse Public Key - password: Langfuse Secret Key  ## Exports  - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Usage : (Deprecated. Use usageDetails and costDetails instead.) Standard interface for usage and cost
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct Usage {
17    /// Number of input units (e.g. tokens)
18    #[serde(rename = "input")]
19    pub input: i32,
20    /// Number of output units (e.g. tokens)
21    #[serde(rename = "output")]
22    pub output: i32,
23    /// Defaults to input+output if not set
24    #[serde(rename = "total")]
25    pub total: i32,
26    /// Unit of measurement
27    #[serde(
28        rename = "unit",
29        default,
30        with = "::serde_with::rust::double_option",
31        skip_serializing_if = "Option::is_none"
32    )]
33    pub unit: Option<Option<String>>,
34    /// USD input cost
35    #[serde(
36        rename = "inputCost",
37        default,
38        with = "::serde_with::rust::double_option",
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub input_cost: Option<Option<f64>>,
42    /// USD output cost
43    #[serde(
44        rename = "outputCost",
45        default,
46        with = "::serde_with::rust::double_option",
47        skip_serializing_if = "Option::is_none"
48    )]
49    pub output_cost: Option<Option<f64>>,
50    /// USD total cost, defaults to input+output
51    #[serde(
52        rename = "totalCost",
53        default,
54        with = "::serde_with::rust::double_option",
55        skip_serializing_if = "Option::is_none"
56    )]
57    pub total_cost: Option<Option<f64>>,
58}
59
60impl Usage {
61    /// (Deprecated. Use usageDetails and costDetails instead.) Standard interface for usage and cost
62    pub fn new(input: i32, output: i32, total: i32) -> Usage {
63        Usage {
64            input,
65            output,
66            total,
67            unit: None,
68            input_cost: None,
69            output_cost: None,
70            total_cost: None,
71        }
72    }
73}