1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// RealtimeResponseUsage : Usage statistics for the Response, this will correspond to billing. A Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeResponseUsage {
/// The total number of tokens in the Response including input and output text and audio tokens.
#[serde(rename = "total_tokens", skip_serializing_if = "Option::is_none")]
pub total_tokens: Option<i32>,
/// The number of input tokens used in the Response, including text and audio tokens.
#[serde(rename = "input_tokens", skip_serializing_if = "Option::is_none")]
pub input_tokens: Option<i32>,
/// The number of output tokens sent in the Response, including text and audio tokens.
#[serde(rename = "output_tokens", skip_serializing_if = "Option::is_none")]
pub output_tokens: Option<i32>,
#[serde(
rename = "input_token_details",
skip_serializing_if = "Option::is_none"
)]
pub input_token_details: Option<Box<models::RealtimeResponseUsageInputTokenDetails>>,
#[serde(
rename = "output_token_details",
skip_serializing_if = "Option::is_none"
)]
pub output_token_details: Option<Box<models::RealtimeBetaResponseUsageOutputTokenDetails>>,
}
impl RealtimeResponseUsage {
/// Usage statistics for the Response, this will correspond to billing. A Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns.
pub fn new() -> RealtimeResponseUsage {
RealtimeResponseUsage {
total_tokens: None,
input_tokens: None,
output_tokens: None,
input_token_details: None,
output_token_details: None,
}
}
}
impl std::fmt::Display for RealtimeResponseUsage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}