You can use Spring AI for OpenAI Java integrations. Spring AI provides an OpenAI client. So you don't have to deal with configuration much. You can check an example implementation from this link. Spring AI OpenAI integration example