openai-types 0.1.3

Typed OpenAI API models — zero dependencies beyond serde
Documentation
// AUTO-GENERATED by py2rust — do not edit.
// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
// Domain: batch
#![allow(unused_imports)]

use serde::{Deserialize, Serialize};
use super::*;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct BatchErrors {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub data: Option<Vec<BatchError>>,
    /// The object type, which is always `list`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub object: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum BatchCreateParamsEndpoint {
    #[serde(rename = "/v1/responses")]
    V1Responses,
    #[serde(rename = "/v1/chat/completions")]
    V1ChatCompletions,
    #[serde(rename = "/v1/embeddings")]
    V1Embeddings,
    #[serde(rename = "/v1/completions")]
    V1Completions,
    #[serde(rename = "/v1/moderations")]
    V1Moderations,
    #[serde(rename = "/v1/images/generations")]
    V1ImagesGenerations,
    #[serde(rename = "/v1/images/edits")]
    V1ImagesEdits,
    #[serde(rename = "/v1/videos")]
    V1Videos,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct BatchCreateParams {
    /// The time frame within which the batch should be processed.
    pub completion_window: String,
    /// The endpoint to be used for all requests in the batch.
    pub endpoint: BatchCreateParamsEndpoint,
    /// The ID of an uploaded file that contains requests for the new batch.
    pub input_file_id: String,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// The expiration policy for the output and/or error file that are generated for a
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub output_expires_after: Option<OutputExpiresAfter>,
}

/// The expiration policy for the output and/or error file that are generated for a batch.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct OutputExpiresAfter {
    /// Anchor timestamp after which the expiration policy applies.
    pub anchor: String,
    /// The number of seconds after the anchor time that the file will expire.
    pub seconds: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct BatchError {
    /// An error code identifying the error type.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub code: Option<String>,
    /// The line number of the input file where the error occurred, if applicable.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub line: Option<i64>,
    /// A human-readable message providing more details about the error.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub message: Option<String>,
    /// The name of the parameter that caused the error, if applicable.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub param: Option<String>,
}

/// A detailed breakdown of the input tokens.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct InputTokensDetails {
    /// The number of tokens that were retrieved from the cache.
    pub cached_tokens: i64,
}

/// A detailed breakdown of the output tokens.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct OutputTokensDetails {
    /// The number of reasoning tokens.
    pub reasoning_tokens: i64,
}

/// Represents token usage details including input tokens, output tokens, a
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct BatchUsage {
    /// The number of input tokens.
    pub input_tokens: i64,
    /// A detailed breakdown of the input tokens.
    pub input_tokens_details: InputTokensDetails,
    /// The number of output tokens.
    pub output_tokens: i64,
    /// A detailed breakdown of the output tokens.
    pub output_tokens_details: OutputTokensDetails,
    /// The total number of tokens used.
    pub total_tokens: i64,
}