Open
Description
Description
When doing the request, i sometimes get a error thrown "fopen(https://172.66.0.243/v1/chat/completions): Failed to open stream: HTTP request failed!"
Steps To Reproduce
public static function chat(string $systemChat, string $userChat, string $responseType = 'text')
{
$parameters = [
'model' => 'gpt-4o-mini',
'messages' => [
['role' => 'system', 'content' => $systemChat],
['role' => 'user', 'content' => $userChat],
],
'temperature' => 0.002,
];
if ($responseType == 'json') {
// Tell OpenAI to return the response as a JSON object
$parameters['response_format'] = ['type' => 'json_object'];
}
$client = self::getClient();
$result = $client->chat()->create($parameters);
if ($responseType == 'json') {
return json_decode($result->choices[0]->message->content, true);
}
return $result->choices[0]->message->content;
}
OpenAI PHP Client Version
V0.10.3
PHP Version
8.3.1
Notes
No response