In this article, modeling and optimization of power consumption of two-stage compressed air system have been investigated. To do so, the two-stage compressed air cycle with intercooler of Fajr Petrochemical Company was considered. This cycle includes two centrifugal compressors, a shell, and a tube intercooler. For modeling of power consumption, isentropic efficiencies of actual compressors and thermal effectiveness of intercooler are calculated from experimental data. In these equations, isentropic efficiency of compressors is a function of the inlet temperature, and thermal effectiveness of the intercooler is a function of the inlet air temperature, inlet water temperature of the intercooler, and inlet volumetric flow rate of the cycle. For optimization of power consumption, the Lagrangian method is used. Power consumption and isentropic efficiency of the first-and second-stage compressors, thermal effectiveness of the intercooler, and entropy generation of compressors are considered as the objective function and optimization conditions, respectively. In comparison with the experimental data, the modeling provided suitable accuracy. The optimization effectively reduced the power consumption of the cycle, especially in summer, in a way that the minimum and maximum reductions were 2.9% and 9.6%, respectively.