The gradual integration of renewable solar energy sources represents a major step toward sustainability, which is why the main objective of this study is to design an optimized GRU architecture for hourly prediction of photovoltaic generation, considering both single-step and multi-step forecasting. A recurrent neural network with a four-layer GRU structure was implemented, selected after a comparative validation process in which different depths were evaluated. This configuration balanced accuracy, stability, and generalization capacity, improving the model’s ability to capture complex relationships between the endogenous variable (photovoltaic generation) and a set of eight exogenous meteorological variables. This architecture proved robust to different sets of predictors, maintaining consistent performance under different input configurations. The result is a reliable prediction and forecast error for a power generation system with meteorological factors typical of Ibarra, Ecuador. Among the evaluation metrics used, the mean square error decreased by 19.61% and 23.69% for single-step prediction and multi-step forecasting, respectively. Therefore, the GRU model has managed to reduce the error by a moderate percentage, with a significant difference, supported by the evaluation metrics and the Wilcoxon-Mann-Whitney U test, it was possible to reduce the error obtaining a p-value less than 0.05, which represents that the data groups without meteorological factors and the data groups with meteorological factors are statistically different and therefore the error reduction is significant. Through this, it is demonstrated that including eight exogenous attributes reduces prediction and forecasting errors.