openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

demo code return with error 400

Open CrocoRyan opened this issue 2 years ago • 2 comments

I strictly followed the demo code, but still got http 400 error when i call it image image

CrocoRyan avatar Feb 14 '23 17:02 CrocoRyan

Try upgrading to 0.10.0 and switching to the OpenAiService in the service library. It will give more detailed info when a request fails.

Does running the example work for you?

TheoKanning avatar Feb 14 '23 17:02 TheoKanning

OpenAiService service = new OpenAiService("xxxx",Duration.ofSeconds(300)); CompletionRequest completionRequest = CompletionRequest.builder() .prompt("说出你的问题") .model("text-davinci-003").maxTokens(2048) .build(); System.out.println(service.createCompletion(completionRequest).getChoices().get(0).getText());

zengwp avatar Feb 16 '23 08:02 zengwp

Try upgrading to 0.10.0 and switching to the OpenAiService in the service library. It will give more detailed info when a request fails.

Does running the example work for you?

I've already done those in my project. I managed to invalidate cache & restart my ide, and now it works. Thanks

CrocoRyan avatar Feb 16 '23 22:02 CrocoRyan