openai-client-base 0.12.0

Auto-generated Rust client for the OpenAI API
/*
 * 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};

/// RealtimeBetaResponseUsage : 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 RealtimeBetaResponseUsage {
    /// 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::RealtimeBetaResponseUsageInputTokenDetails>>,
    #[serde(
        rename = "output_token_details",
        skip_serializing_if = "Option::is_none"
    )]
    pub output_token_details: Option<Box<models::RealtimeBetaResponseUsageOutputTokenDetails>>,
}

impl RealtimeBetaResponseUsage {
    /// 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() -> RealtimeBetaResponseUsage {
        RealtimeBetaResponseUsage {
            total_tokens: None,
            input_tokens: None,
            output_tokens: None,
            input_token_details: None,
            output_token_details: None,
        }
    }
}

impl std::fmt::Display for RealtimeBetaResponseUsage {
    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),
        }
    }
}