I used php to request openai and kept returning 500 errors,Unable to return data,Is it because I’m using my free credit。
Can extend the request time? Currently, it returns an error after more than 1 minute
Error prompt: Idle timeout reached for “https://api.openai.com/v1/chat/completions”.
A 500 error typically indicates something went wrong on the server side of things, a 429 error would indicate a rate limit (too many requests).
Do you have a credit card assigned to your account? Also can you provide the code you use? It might help someone here detect any possible issues.
$apiKey = env('ChatGpt.API_KEY');
$client = OpenAI::client($apiKey);
$response = $client->chat()->create([
'model' => 'gpt-3.5-turbo',
'messages' => [
["role" => "user", "content" => "I'm in Los Angeles. What's a good place to go this weekend?"]
],
]);
return json($response);
Which library/SDK are you using to handle the API calls?
Ok, that seems like an actively maintained lib, a few follow up questions if I may, are you still getting the 500 errors, if so how often do they occur, i.e. out of 10 calls how many return with a 500 and have you posted this issue to the issue tracker on that git repo?
yes, always 500 errors,i’ve also seen feedback about this on git
The reason I’m asking is I get to see thousands of developers making comments about issues in real time through the forum and I’ve not seen any sudden uptick in 500 errors from users of the OpenAI maintained API libraries, and with the forum getting thousands of new users every day, the forum would literally light up with people posting about it if it were a systemic problem.
This leads me to think that it’s one of 4 things,
- A programmatic issue, your code seems ok from the small chunk I’ve seen, not knowing the library, I’m making assumptions to the fact that you have implemented it correctly.
- Your API key is not being read correctly/Some issue with your API key. Try manually putting that in as a text so avoid the possibility of an environment issue.
- Some local/intermediate infrastructure issue, some problem with your local network infra is a possible cause, ports being blocked, firewalls, VPN’s proxies etc.
- An as yet undetected server issue on OpenAI’s side that only seems to currently affect you.
Of those options I think the last one is the least plausible at this stage. I’d have a go an number 2 and look into contacting the library maintainers as to Issue 1, Issue 3 is unlikely but we can look at that if the other options don’t correct it.
How do I deal with the fact that it takes a long time to respond to a simple question
Can you give an example case, please. “long time” and “question” are insufficient to make an accurate determination of your issue.
Where are you located?
When I deploy a Llama model on Replicate in let’s say us-west and do a request from my local computer in germany to that server it takes almost 11 seconds to get an answer.
The model only takes ~0.9 seconds to create the answer.
When I create a server in us-west on hetzner cloud and connect from there to the model deployed on a us-west server I get the answer imediatly.
So it can be a problem between where your server is located.