With the rapid development of social economy, energy consumption has continued to grow, and the problem of pollutant emissions in various energy sources has gradually become the focus of social attention. Cities account for two-thirds of global primary energy demand that make urban energy systems a center of sustainable transitions. This paper builds a bi-level planning model for steady-state optimal configuration to realize the reasonable planning of the urban energy structure. The first level mainly analyzes the steady-state relationship between energy systems, the second level is based on the steady-state relationship of multiple energy sources to minimize the construction and operating costs of urban energy systems and pollutant emissions. Nonlinear system dynamics and the Improved Moth Flame Optimization Algorithm (IMFO) algorithm are implemented to solve the model. In addition, this paper uses instances to verify the application of a planning model in a certain city energy system in China. Under the premise of ensuring the stability of the urban energy system, two energy planning programs are proposed: mainly coal or mainly high-quality energy. The coal planning volumes are used as the basis for sub-scenario planning and discussion. Lastly, this paper proposes a series of development suggestions for different planning schemes.