"no message"])); // Try Groq directly (simplest provider) $secrets = file_get_contents("/etc/weval/secrets.env"); preg_match("/GROQ[_A-Z]*=(.+)/i", $secrets, $m); $key = trim($m[1] ?? ""); $ch = curl_init("https://api.groq.com/openai/v1/chat/completions"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ["Authorization: Bearer $key","Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode(["model"=>"llama-3.3-70b-versatile","messages"=>[["role"=>"user","content"=>$msg]],"max_tokens"=>200]), CURLOPT_TIMEOUT => 10, ]); $r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // curl_close deprecated in PHP 8.5 if ($code == 200) { $d = json_decode($r, true); $text = $d["choices"][0]["message"]["content"] ?? "no response"; echo json_encode(["response"=>$text,"provider"=>"groq","status"=>"ok"]); } else { echo json_encode(["error"=>"provider failed","http"=>$code,"raw"=>substr($r,0,100)]); }