Class OpenAiFileApi

java.lang.Object
org.springframework.ai.openai.api.OpenAiFileApi

public class OpenAiFileApi extends Object
OpenAI File API.
Author:
Sun Yuhan
See Also:
  • Constructor Details

    • OpenAiFileApi

      public OpenAiFileApi(String baseUrl, org.springframework.ai.model.ApiKey apiKey, org.springframework.util.MultiValueMap<String,String> headers, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler)
  • Method Details

    • builder

      public static OpenAiFileApi.Builder builder()
    • uploadFile

      public org.springframework.http.ResponseEntity<OpenAiFileApi.FileObject> uploadFile(OpenAiFileApi.UploadFileRequest uploadFileRequest)
      Upload a file that can be used across various endpoints
      Parameters:
      uploadFileRequest - The request body
      Returns:
      Response entity containing the file object
    • listFiles

      public org.springframework.http.ResponseEntity<OpenAiFileApi.FileObjectResponse> listFiles(OpenAiFileApi.ListFileRequest listFileRequest)
      Returns a list of files
      Parameters:
      listFileRequest - The request body
      Returns:
      Response entity containing the files
    • retrieveFile

      public org.springframework.http.ResponseEntity<OpenAiFileApi.FileObject> retrieveFile(String fileId)
      Returns information about a specific file
      Parameters:
      fileId - The file id
      Returns:
      Response entity containing the file object
    • deleteFile

      public org.springframework.http.ResponseEntity<OpenAiFileApi.DeleteFileResponse> deleteFile(String fileId)
      Delete a file
      Parameters:
      fileId - The file id
      Returns:
      Response entity containing the deletion status
    • retrieveFileContent

      public org.springframework.http.ResponseEntity<String> retrieveFileContent(String fileId)
      Returns the contents of the specified file
      Parameters:
      fileId - The file id
      Returns:
      Response entity containing the file content