The work is devoted to the development of an integrated approach to the analysis of the presence of harmful impurities in the atmospheric air. This approach involves: 1) using the measurement results of terahertz absorption spectra of air containing harmful impurities; 2) creating and using a neural network to analyze the data obtained. Sets of model absorption spectra of a gas mixture with different qualitative and quantitative compositions are generated to train the neural network. The application of a neural network to model sets of spectra demonstrated the identification of six gas components with concentrations up to 0.01 ppm. The neural network has achieved 90-95% accuracy in gas detection. A series of experiments were conducted for real gases, showing the sensitivity of the THz spectroscopy method to low concentrations of gases in atmosphere.