Aims. The aim of this work is to understand the richness of chemical species observed in the isolated high-mass envelope of AFGL 2591, a prototypical object for studying massive star formation. Methods. Based on HIFI and JCMT data, the molecular abundances of species found in the protostellar envelope of AFGL 2591 were derived with a Monte Carlo radiative transfer code (Ratran), assuming a mixture of constant and 1D stepwise radial profiles for abundance distributions. The reconstructed 1D abundances were compared with the results of the time-dependent gas-grain chemical modeling, using the best-fit 1D power-law density structure. The chemical simulations were performed considering ages of 1−5 × 10 4 years, cosmic ray ionization rates of 5−500 × 10 −17 s −1 , uniformly-sized 0.1−1 μm dust grains, a dust/gas ratio of 1%, and several sets of initial molecular abundances with C/O < 1 and >1. The most important model parameters varied one by one in the simulations are age, cosmic ray ionization rate, external UV intensity, and grain size. Results. Constant abundance models give good fits to the data for CO, CN, CS, HCO + , H 2 CO, N 2 H + , CCH, NO, OCS, OH, H 2 CS, O, C, C + , and CH. Models with an abundance jump at 100 K give good fits to the data for NH 3 , SO, SO 2 , H 2 S, H 2 O, HCl, and CH 3 OH. For HCN and HNC, the best models have an abundance jump at 230 K. The time-dependent chemical model can accurately explain abundance profiles of 15 out of these 24 species. The jump-like radial profiles for key species like HCO + , NH 3 , and H 2 O are consistent with the outcome of the time-dependent chemical modeling. The best-fit model has a chemical age of ∼10−50 kyr, a solar C/O ratio of 0.44, and a cosmic-ray ionization rate of ∼5 × 10 −17 s −1 . The grain properties and the intensity of the external UV field do not strongly affect the chemical structure of the AFGL 2591 envelope, whereas its chemical age, the cosmic-ray ionization rate, and the initial abundances play an important role. Conclusions. We demonstrate that simple constant or jump-like abundance profiles constrained with 1D Ratran line radiative transfer simulations are in agreement with time-dependent chemical modeling for most key C-, O-, N-, and S-bearing molecules. The main exceptions are species with very few observed transitions (C, O, C + , and CH) or with a poorly established chemical network (HCl, H 2 S) or whose chemistry is strongly affected by surface processes (CH 3 OH).