portkey_sdk/model/
files.rs

1//! Files API models.
2//!
3//! This module contains models for file upload and management.
4
5use serde::{Deserialize, Serialize};
6
7/// Request body for uploading a file.
8#[derive(Debug, Clone)]
9pub struct UploadFileRequest {
10    /// File to upload (bytes).
11    pub file: Vec<u8>,
12
13    /// The filename.
14    pub filename: String,
15
16    /// The intended purpose of the uploaded file.
17    /// Use "assistants" for Assistants and Message files,
18    /// "vision" for Assistants image file inputs,
19    /// "batch" for Batch API, and "fine-tune" for Fine-tuning.
20    pub purpose: String,
21}
22
23/// Response from uploading a file.
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct FileObject {
26    /// The file identifier.
27    pub id: String,
28
29    /// The object type (always "file").
30    pub object: String,
31
32    /// The size of the file in bytes.
33    pub bytes: u64,
34
35    /// The Unix timestamp (in seconds) for when the file was created.
36    pub created_at: i64,
37
38    /// The name of the file.
39    pub filename: String,
40
41    /// The intended purpose of the file.
42    pub purpose: String,
43
44    /// Deprecated. The current status of the file (always "processed").
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub status: Option<String>,
47
48    /// Deprecated. For details on why a fine-tuning training file failed validation.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub status_details: Option<String>,
51}
52
53/// Response from listing files.
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ListFilesResponse {
56    /// List of file objects.
57    pub data: Vec<FileObject>,
58
59    /// The object type (always "list").
60    pub object: String,
61}
62
63/// Response from deleting a file.
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct DeleteFileResponse {
66    /// The ID of the deleted file.
67    pub id: String,
68
69    /// The object type (always "file").
70    pub object: String,
71
72    /// Whether the file was successfully deleted.
73    pub deleted: bool,
74}