pub struct Files<'a> { /* private fields */ }Expand description
Access file endpoints.
API reference: https://platform.openai.com/docs/api-reference/files
Implementations§
Source§impl<'a> Files<'a>
impl<'a> Files<'a>
Sourcepub async fn create_from_path(
&self,
path: impl AsRef<Path>,
purpose: FilePurpose,
) -> Result<FileObject, OpenAIError>
pub async fn create_from_path( &self, path: impl AsRef<Path>, purpose: FilePurpose, ) -> Result<FileObject, OpenAIError>
Upload a file from a filesystem path.
Reads the file asynchronously and infers the filename from the path.
ⓘ
let file = client.files().create_from_path("data.jsonl", FilePurpose::FineTune).await?;Sourcepub async fn create(
&self,
params: FileUploadParams,
) -> Result<FileObject, OpenAIError>
pub async fn create( &self, params: FileUploadParams, ) -> Result<FileObject, OpenAIError>
Upload a file.
POST /files
Sourcepub async fn list(&self) -> Result<FileList, OpenAIError>
pub async fn list(&self) -> Result<FileList, OpenAIError>
List files.
GET /files
Sourcepub async fn list_page(
&self,
params: FileListParams,
) -> Result<FileList, OpenAIError>
pub async fn list_page( &self, params: FileListParams, ) -> Result<FileList, OpenAIError>
List files with pagination parameters.
GET /files
Sourcepub fn list_auto(&self, params: FileListParams) -> Paginator<FileObject>
pub fn list_auto(&self, params: FileListParams) -> Paginator<FileObject>
Auto-paginate through all files.
Returns a Paginator stream that yields individual FileObject items,
automatically fetching subsequent pages.
Sourcepub async fn retrieve(&self, file_id: &str) -> Result<FileObject, OpenAIError>
pub async fn retrieve(&self, file_id: &str) -> Result<FileObject, OpenAIError>
Retrieve a file by ID.
GET /files/{file_id}
Sourcepub async fn delete(&self, file_id: &str) -> Result<FileDeleted, OpenAIError>
pub async fn delete(&self, file_id: &str) -> Result<FileDeleted, OpenAIError>
Delete a file.
DELETE /files/{file_id}
Auto Trait Implementations§
impl<'a> Freeze for Files<'a>
impl<'a> !RefUnwindSafe for Files<'a>
impl<'a> Send for Files<'a>
impl<'a> Sync for Files<'a>
impl<'a> Unpin for Files<'a>
impl<'a> UnsafeUnpin for Files<'a>
impl<'a> !UnwindSafe for Files<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more