502 Bad Gateway Error - pls help

I’ve been having this problem for the last 10 days. I get this error on most of my requests with more than 5000 tokens and I end up looping the request and trying and I get 10 bad requests in a row. For requests with less than 400 tokens, I get 1 error in 5-10 requests. I have tried all the ways I can think of and I am about to give up, please someone show me the way out

The api endpoint I use is: https://api.openai.com/v1/chat/completions

Coding language I use: pure php and curl. no libraries

Below are all the responses. I have saved in my database

same error with GPT4. Sorry I can’t help!

The problem is still ongoing The topic is active…
I am open to all suggestions.

Have you tried using the OpenAI playground?

Same error here. It’s really frustrating