true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => ["Content-Type: application/json", "Host: weval-consulting.com"], CURLOPT_POSTFIELDS => json_encode([ "message" => $msg, "language" => "fr", "action" => $action, "history" => $input["history"] ?? [], "mode" => $input["mode"] ?? "fast" ]) ]); $resp = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code === 200 && $resp) { $data = json_decode($resp, true); // Translate to hamid-api format echo json_encode([ "response" => $data["response"] ?? "", "provider" => $data["provider"] ?? "WEVIA", "duration" => $data["latency_ms"] ?? 0, "kb_count" => 0, "model" => $data["provider"] ?? "Cerebras", "error" => null ]); } else { echo json_encode(["response" => "", "error" => "API error: HTTP $code", "provider" => "none", "duration" => 0, "kb_count" => 0]); }