OpenAi Api Pdf reader for Java

I’m currently working on a Java web application using Spring Boot, where I need to upload a PDF and extract specific information from it. I’m trying to use OpenAI for this task, but I’m struggling to find enough documentation for Java, particularly on how to upload files. I found that OpenAI supports Vector Store and Assistant APIs for file uploads and information retrieval, but I’m not entirely sure how to implement this, especially with Java.

Does anyone know how I can achieve this or have any documentation/resources that could help me complete this request?

Hi @shitamelark and welcome to the community!

I did a quick search and found this Java package, but looks like it’s been archived.

However, all OpenAI API examples, including Assistants API work with standard curl (HTTP) requests. So any Java library that is able to behave like curl equivalent (sending HTTP requests to some URI), should work fine.

For example, on this page, you can see how to do everything by selecting “curl” option. To upload a file for example, you would do this:

curl https://api.openai.com/v1/files \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F purpose="assistants" \
  -F file="@revenue-forecast.csv"

I am not up to speed with all the Java web features but any Java lib/module that can execute that should be good to go.

3 Likes

@shitamelark Welcome to this community!

If you need to work with the Assistant API in Java, you could try this library:

2 Likes