Power flow optimization in the electrical grid is critical to improve the stability and performance of power systems. The main challenge lies in finding an optimal distribution of power generation that meets the constraints imposed by the grid, such as voltage limits and power system stability conditions. The objective of this research was to evaluate the performance of Gekko in power flow optimization in electrical grids. To do so, a comparison was made with SciPy, a widely used benchmark framework in numerical optimization in order to assess their relative efficiency in problems with complex constraints. The comparison is based on metrics such as solution accuracy, convergence speed, and number of objective function evaluations. The results showed that both methods achieved the same objective value: SciPy (19.7) and Gekko (19.7). However, SciPy was slightly faster (0.01496 seconds vs. 0.0191 seconds), but required 60 objective function evaluations. In contrast, Gekko demonstrated greater computational efficiency, reducing the number of evaluations required for convergence. While SciPy is more efficient on small problems with explicit constraints, Gekko offers greater flexibility on problems with more complex constraints, making it more suitable for larger power systems.