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};

/// CompletionUsageCompletionTokensDetails : Breakdown of tokens used in a completion.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CompletionUsageCompletionTokensDetails {
    /// When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
    #[serde(
        rename = "accepted_prediction_tokens",
        skip_serializing_if = "Option::is_none"
    )]
    pub accepted_prediction_tokens: Option<i32>,
    /// Audio input tokens generated by the model.
    #[serde(rename = "audio_tokens", skip_serializing_if = "Option::is_none")]
    pub audio_tokens: Option<i32>,
    /// Tokens generated by the model for reasoning.
    #[serde(rename = "reasoning_tokens", skip_serializing_if = "Option::is_none")]
    pub reasoning_tokens: Option<i32>,
    /// When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
    #[serde(
        rename = "rejected_prediction_tokens",
        skip_serializing_if = "Option::is_none"
    )]
    pub rejected_prediction_tokens: Option<i32>,
}

impl CompletionUsageCompletionTokensDetails {
    /// Breakdown of tokens used in a completion.
    pub fn new() -> CompletionUsageCompletionTokensDetails {
        CompletionUsageCompletionTokensDetails {
            accepted_prediction_tokens: None,
            audio_tokens: None,
            reasoning_tokens: None,
            rejected_prediction_tokens: None,
        }
    }
}

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