Skip to main content

openai_types/batch/
_gen.rs

1// AUTO-GENERATED by py2rust — do not edit.
2// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
3// Domain: batch
4#![allow(unused_imports)]
5
6use serde::{Deserialize, Serialize};
7use super::*;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
11pub struct BatchErrors {
12    #[serde(skip_serializing_if = "Option::is_none", default)]
13    pub data: Option<Vec<BatchError>>,
14    /// The object type, which is always `list`.
15    #[serde(skip_serializing_if = "Option::is_none", default)]
16    pub object: Option<String>,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
21#[non_exhaustive]
22pub enum BatchCreateParamsEndpoint {
23    #[serde(rename = "/v1/responses")]
24    V1Responses,
25    #[serde(rename = "/v1/chat/completions")]
26    V1ChatCompletions,
27    #[serde(rename = "/v1/embeddings")]
28    V1Embeddings,
29    #[serde(rename = "/v1/completions")]
30    V1Completions,
31    #[serde(rename = "/v1/moderations")]
32    V1Moderations,
33    #[serde(rename = "/v1/images/generations")]
34    V1ImagesGenerations,
35    #[serde(rename = "/v1/images/edits")]
36    V1ImagesEdits,
37    #[serde(rename = "/v1/videos")]
38    V1Videos,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
43pub struct BatchCreateParams {
44    /// The time frame within which the batch should be processed.
45    pub completion_window: String,
46    /// The endpoint to be used for all requests in the batch.
47    pub endpoint: BatchCreateParamsEndpoint,
48    /// The ID of an uploaded file that contains requests for the new batch.
49    pub input_file_id: String,
50    /// Set of 16 key-value pairs that can be attached to an object.
51    #[serde(skip_serializing_if = "Option::is_none", default)]
52    pub metadata: Option<serde_json::Value>,
53    /// The expiration policy for the output and/or error file that are generated for a
54    #[serde(skip_serializing_if = "Option::is_none", default)]
55    pub output_expires_after: Option<OutputExpiresAfter>,
56}
57
58/// The expiration policy for the output and/or error file that are generated for a batch.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
61pub struct OutputExpiresAfter {
62    /// Anchor timestamp after which the expiration policy applies.
63    pub anchor: String,
64    /// The number of seconds after the anchor time that the file will expire.
65    pub seconds: i64,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
70pub struct BatchError {
71    /// An error code identifying the error type.
72    #[serde(skip_serializing_if = "Option::is_none", default)]
73    pub code: Option<String>,
74    /// The line number of the input file where the error occurred, if applicable.
75    #[serde(skip_serializing_if = "Option::is_none", default)]
76    pub line: Option<i64>,
77    /// A human-readable message providing more details about the error.
78    #[serde(skip_serializing_if = "Option::is_none", default)]
79    pub message: Option<String>,
80    /// The name of the parameter that caused the error, if applicable.
81    #[serde(skip_serializing_if = "Option::is_none", default)]
82    pub param: Option<String>,
83}
84
85/// A detailed breakdown of the input tokens.
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
88pub struct InputTokensDetails {
89    /// The number of tokens that were retrieved from the cache.
90    pub cached_tokens: i64,
91}
92
93/// A detailed breakdown of the output tokens.
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
96pub struct OutputTokensDetails {
97    /// The number of reasoning tokens.
98    pub reasoning_tokens: i64,
99}
100
101/// Represents token usage details including input tokens, output tokens, a
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
104pub struct BatchUsage {
105    /// The number of input tokens.
106    pub input_tokens: i64,
107    /// A detailed breakdown of the input tokens.
108    pub input_tokens_details: InputTokensDetails,
109    /// The number of output tokens.
110    pub output_tokens: i64,
111    /// A detailed breakdown of the output tokens.
112    pub output_tokens_details: OutputTokensDetails,
113    /// The total number of tokens used.
114    pub total_tokens: i64,
115}