In recent studies, emphasis has been placed on optimal power flow (OPF) problems in traditional thermal, wind, and solar energy sources-based hybrid power systems. Various metaheuristic algorithms have been proposed to find optimal solutions to the OPF problems in the hybrid power system. The OPF, due to the quadratic nature of its primary objective function, is a nonlinear, nonconvex, and quadratic optimization problem. In this study, we have proposed a bio-inspired bird swarm algorithm (BSA) to find an optimal solution to the OPF problem in the hybrid power system because it performs well in the case of optimizing the well-known Rastrigin quadratic benchmark function. In this study, uncertainty of utility load demand and stochastic electricity output from renewable energy resources (RESs) including wind and solar are incorporated into the hybrid power system for achieving accuracy in operations and planning of the system. We have used a modified IEEE-30 bus test system to verify and measure the performance of BSA and a comparison is made with well-known evolutionary metaheuristic algorithms. The proposed BSA consistently achieves more accurate and stable results than other metaheuristic algorithms. Simulation-based optimization results have shown the superiority of BSA approach to solve the OPF problems by satisfying all constraints and minimum power generation cost 863.121 $/h is achieved in case study 1. Simulation-based experiment results have indicated that by imposing the carbon tax (ton/h) the power generation from RESs was increased. In case study 2, the proposed BSA approach has also outperformed and minimum electricity cost 890.728 $/h is achieved as compared to other algorithms.INDEX TERMS Deterministic optimal power flow, Uncertainty of utility load demand, Bio-inspired bird swarm algorithm, Stochastic solar and wind power.