How to summarize PDF file Using Java

public class PDFSummarizer {

static String apiKey = "";
static String pdfFilePath = "C:\\Users\\1.pdf";

static String url = "https://api.openai.com/v1/summarization";

public static void main(String[] args) throws IOException {

    String summary = summarizePDF(apiKey,pdfFilePath);
    System.out.println("Summary: " + summary);
}


public static String summarizePDF(String apiKey, String pdfFilePath) throws IOException {
    CloseableHttpClient httpClient = HttpClients.createDefault();

    Path path = Paths.get(pdfFilePath);
    byte[] pdfBytes = Files.readAllBytes(path);

    HttpPost httpPost = new HttpPost(url);
    String pdfContent = new String(pdfBytes, StandardCharsets.UTF_8);
    httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + apiKey);
    httpPost.setHeader("Content-Type", "application/json");

    String requestBody = "{\"file\": \"" + pdfContent + "\", \"model\": \"text-davinci-003\"}";
    httpPost.setEntity(new StringEntity(requestBody));
    CloseableHttpResponse response = httpClient.execute(httpPost);
    String jsonResponse = EntityUtils.toString(response.getEntity());

    return jsonResponse;
}

}

Here is my code. the url = “https://api.openai.com/v1/summarization” which is still working? what is the new link? Also, is the model “text-davinci-003” does anyone can give me an example? Thanks a lot.

I don’t think that end point exists or it was ever there. replace that with https://api.openai.com/v1/chat/completions