$ch = curl_init('https://api.aitunnel.ru/v1/chat/completions'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Authorization: Bearer sk-aitunnel-CIRKSmWziXHAVDFyimBVTSIeES2JY7eY' ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); if ($response === false) { error_log('CURL Error: ' . curl_error($ch)); curl_close($ch); echo json_encode(['error' => true, 'message' => 'Ошибка связи с внешним API']); return; } echo $response; curl_close($ch);