This research focuses on evaluating the importance of the use of renewable sources through distributed generation and its implication in the operation of electrical systems given that its incorporation has a direct impact on the expansion of the capacity of the networks, the minimization losses, and the impact on end users, all supported by the growth of demand. Under this context, the study focuses on incorporating distributed generation (DG), taking scenarios of base, medium, and peak demand and the modeling of the network, and subsequently evaluating the service quality indices and operating costs in addition to the electrical variables of the system. For this purpose, the present work proposes an optimization model to be solved using the Matlab (2021b) computational program together with GAMS (37.1.0 Major release (11 November 2021)) and mixed-integer nonlinear programming, determining the optimal insertion and determination of the maximum capacity of distributed generators while complying with the technical restrictions of the system and applying optimal AC power flows. Localizing and determining maximum capacity for distributed generation (DG) in electrical systems are critical aspects of modern grid planning and operation. With the increasing penetration of renewable energy sources and the growing complexity of energy demand patterns, efficient integration of DG has become paramount for ensuring grid reliability and sustainability. In this context, the analysis of DG localization and capacity determination considering demand scenarios emerges as a critical area of research in electrical engineering. By employing advanced optimization techniques such as mixed-integer nonlinear programming (MINP), this research addresses the multidimensional challenges associated with DG deployment, including technical constraints, economic considerations, and environmental impacts. Understanding the contribution of this optimization approach to electrical engineering is fundamental for optimizing grid performance, enhancing renewable energy integration, and supporting the transition towards more resilient and sustainable energy systems. Consequently, investigating this optimization model represents a crucial step towards advancing the state-of-the-art in grid planning and facilitating the transition to a cleaner and more efficient energy future.