Skip to main content

openai_tools/files/
response.rs

1//! OpenAI Files API Response Types
2//!
3//! This module defines the response structures for the OpenAI Files API.
4
5use serde::{Deserialize, Serialize};
6
7/// Represents an uploaded file in the OpenAI platform.
8///
9/// Files can be used for various purposes including fine-tuning, batch processing,
10/// assistants, and vision tasks.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct File {
13    /// The file identifier, which can be referenced in the API endpoints
14    pub id: String,
15    /// Object type, always "file"
16    pub object: String,
17    /// The size of the file, in bytes
18    pub bytes: i64,
19    /// Unix timestamp (in seconds) when the file was created
20    pub created_at: i64,
21    /// The name of the file
22    pub filename: String,
23    /// The intended purpose of the file
24    /// (e.g., "assistants", "batch", "fine-tune", "vision")
25    pub purpose: String,
26    /// The current status of the file (deprecated for some file types)
27    /// Can be "uploaded", "processed", or "error"
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub status: Option<String>,
30    /// Additional details about the file status (deprecated for some file types)
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub status_details: Option<String>,
33}
34
35/// Response structure for listing files.
36///
37/// Contains a list of file objects.
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct FileListResponse {
40    /// Object type, always "list"
41    pub object: String,
42    /// Array of file objects
43    pub data: Vec<File>,
44    /// Whether there are more files to retrieve
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub has_more: Option<bool>,
47}
48
49/// Response structure for file deletion.
50///
51/// Returned when a file is successfully deleted.
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct DeleteResponse {
54    /// The file identifier that was deleted
55    pub id: String,
56    /// Object type, always "file"
57    pub object: String,
58    /// Whether the file was successfully deleted
59    pub deleted: bool,
60}