true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer " . CHAT_KEY ], CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE), CURLOPT_TIMEOUT => 1000, CURLOPT_FAILONERROR => true ]); $response = curl_exec($ch); curl_close($ch); $decoded = json_decode($response, true); $content = $decoded['choices'][0]['message']['content']; echo $content; } catch (Throwable $e) { // This guarantees something shows up instead of silent 500 error_log($e->getMessage()); echo $e->getMessage(); }