502 Bad Gateway in R when running chat completion model

502 Bad Gateway issue when running create chat completion model in R.
I am looking for solutions to handle this.

Do you have a code snippet to look at? Also are you using the OpenAI library or a JSON handler and directly connecting?