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, ApiKey apiKey, org.springframework.http.HttpHeaders headers, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler)
      Create a new OpenAI file api.
      Parameters:
      baseUrl - api base URL.
      apiKey - OpenAI apiKey.
      headers - the http headers to use.
      restClientBuilder - RestClient builder.
      responseErrorHandler - Response error handler.
    • OpenAiFileApi

      public OpenAiFileApi(org.springframework.web.client.RestClient restClient)
      Create a new OpenAI file api.
      Parameters:
      restClient - RestClient instance.
  • 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