Class OpenAiFileApi
java.lang.Object
org.springframework.ai.openai.api.OpenAiFileApi
OpenAI File API.
- Author:
- Sun Yuhan
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final recordstatic final recordstatic final recordstatic final recordstatic enumThe intended purpose of the uploaded filestatic final record -
Constructor Summary
ConstructorsConstructorDescriptionOpenAiFileApi(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.OpenAiFileApi(org.springframework.web.client.RestClient restClient) Create a new OpenAI file api. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiFileApi.Builderbuilder()org.springframework.http.ResponseEntity<OpenAiFileApi.DeleteFileResponse> deleteFile(String fileId) Delete a fileorg.springframework.http.ResponseEntity<OpenAiFileApi.FileObjectResponse> listFiles(OpenAiFileApi.ListFileRequest listFileRequest) Returns a list of filesorg.springframework.http.ResponseEntity<OpenAiFileApi.FileObject> retrieveFile(String fileId) Returns information about a specific fileorg.springframework.http.ResponseEntity<String> retrieveFileContent(String fileId) Returns the contents of the specified fileorg.springframework.http.ResponseEntity<OpenAiFileApi.FileObject> uploadFile(OpenAiFileApi.UploadFileRequest uploadFileRequest) Upload a file that can be used across various endpoints
-
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
-
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
Returns the contents of the specified file- Parameters:
fileId- The file id- Returns:
- Response entity containing the file content
-