Semi-rigid steel frames are considered as more cost-effective than conventional fully rigid steel frames by using the economical partially restrained (PR) connections, which means more design flexibility and optimization potential. Advanced or direct analysis accounting the nonlinearity of material, geometrical and joints should be used to accurately capture the collapse process and bearing performance of semi-rigid steel frames under various load conditions. In this paper, an effective procedure for optimizing steel frames with semi-rigid joints using direct analysis is proposed and verified. The NIDA software with PEP element is used to capture the second-order effects and the inelastic behaviors of beam and column members, and the zero-length spring model is employed for estimating nonlinear behaviors of semi-rigid joints. Two optimization algorithm named Pointer and MIGA provided by professional optimization software ISIGHT is used and also the file filter module of OpenMDAO which is an open-source high-performance computing platform for systems analysis and multidisciplinary optimization written in Python. The cross-section of structural members are treated as discrete variables selected from prescribed groups and the semi-rigid connection types are optimized as continuous variables or discrete variables. The optimization result shows that the method is efficient and applicable to the optimization of practical engineering steel frames.