Energy internet (EI) is a very complex system with various applications that not only require a high-level of cyber-security but also need low-latency communication. Thus, cyberinfrastructure with latency-optimal network intelligence services (NIS), in which application data flows are deeply examined in real-time, is inevitable. In the future internet system, a set of NIS can flexibly be implemented in network function virtualization (NFV)-based middleboxes that overlay on software-defined networking (SDN) architecture, becoming an SDN/NFV-based cyberinfrastructure. However, how to deploy these middleboxes is a non-deterministic optimization problem, which is complicated and time-consuming. Hence, by focusing on latency minimization, we develop an artificial intelligence (AI)-powered solution consisted of two phases. First, middleboxes placement based on the graph cluster analysis, and second, NIS resource allocation based on the prediction of service usage-ratio in each corresponding cluster. The simulation-based experimental evaluation shows that our proposed strategy using an optimized K-means algorithm outperforms the recent state-of-the-art middleboxes placement approaches. The average end-to-end flow latencies are around 23.81%, 18.44%, and 11.49% lower compared with the simulated annealing method, the basic sequential algorithmic scheme, and the minimum spanning tree procedure, respectively. Besides, the proposed resource allocation scheme optimizes further the latency minimization around 4.24%. We believe that the work presented in this paper will aid the communication service providers (CSP) in providing a secure and low-latency SDN/NFV-based cyberinfrastructure for the EI ecosystem.