Graph neural networks (GNN) recently have been successfully applied in wind power prediction by employing geo-information to construct the graphs that serve as the GNN-based prediction model. However, these graphs cannot maintain the latent correlation and attribute of the wind turbines, leading to inferior performance. This research proposes an optimizing wind power prediction model through attention mechanism and spatiotemporal graph neural networks. Initially, the spectral clustering and a self-adjacency matrix to construct the graph nodes and edges. Subsequently, the proposed ASTGNN combined from graph convolutional networks and a gated recurrent unit with an attention mechanism is designed to act as the prediction model. A comprehensive set of experiments has been carried out and the proposed method not only improved prediction accuracy but also enhanced computational efficiency. According to the results obtained, the developed model demonstrated an improvement that is up to 13 % in terms of RMSE and 6.7 % in terms of computation time compared to the latest models.