Incorporating renewable energy sources (RESs) introduces a notable amount of uncertainty in the optimal planning and operation of electrical power grids. Under these circumstances, this paper proposes the application of a recently introduced metaheuristic optimization technique to solve the stochastic optimal power flow (OPF) problem involving wind and solar power sources. The self-adaptive bonobo optimizer (SaBO) is used to minimize three distinct objective functions: (i) Total generation cost (TGC) minimization, including both thermal and wind/solar generation costs, (ii) Power loss minimization, (iii) Combined generation cost and emissions effect minimization. The costs associated with the stochastic generation of wind and solar power included direct costs, reserves and penalty costs from the overestimation and underestimation of available wind and solar power, respectively. The performance of the proposed algorithm is evaluated on two power systems: the modified IEEE 30-bus and the Algerian DZA 114-bus test systems. To demonstrate the efficacy of the SaBO, the obtained results have been compared with those obtained from the Kepler optimization algorithm (KOA) and other recently published optimizers under the same case studies and constraints. The comparative results clearly show the superiority of the SaBO algorithm over all other well-known optimization algorithms provided in the literature for solving the OPF problem. This is evidenced by minimizing total generation costs of 781.2363 $/h for the modified IEEE 30-bus and 16,706.1630 $/h for the Algerian DZA-114-bus system. Furthermore, the integration of RES led to a notable 2.33% and 11.67% reduction in total generation cost for the IEEE 30-bus and Algerian DZA 114-bus systems, respectively, compared to their initial configurations without RESs. The promising findings highlight the powerful of the optimizer to solve non-linear and complex optimization problems in power systems.