Context. An approach towards understanding the formation of massive stars and star clusters is to study the structure of their hot core phase, an evolutionary stage where dust has been heated, but molecules have not yet been destroyed by ultraviolet radiation. These hot molecular cores are very line-rich, but the interpretation of line surveys is also hampered by poor knowledge of the physical and chemical structure. Aims. To constrain the radial structure of high-mass star-forming regions containing hot cores, we attempt to reproduce by radiative transfer modeling both the intensity and shape of a variety of molecular lines. Methods. We observed 12 hot cores with the Atacama Pathfinder EXperiment (APEX) in lines of HCN, HCO + , CO, and their isotopologues, including high-J lines and vibrationally excited HCN. We investigate how well the sources can be modeled as centrally heated spheres with a power-law density gradient, making use of the radiative transfer code RATRAN and the radial profile of the submm continuum emission, taken from the APEX Telescope Large Area Survey of the GALaxy (ATLASGAL). Results. Most of the observed lines have complicated shapes that incorporate self-absorption, asymmetries, and line wings. Vibrationally excited HCN is detected in all sources, and vibrationally excited H 13 CN in half of the sources. We are able to successfully model most features seen in the APEX data, such as the ratio of the isotopologue lines (very high optical depths), self-absorption (temperature gradient), blue asymmetries (moderate infall), vibrationally excited HCN (high inner temperatures), and H 13 CN (high HCN abundance under dense and hot conditions). Other features could not be reproduced, such as an occasional lack of self-absorption, the emission from high-J lines in the outer pixels of the CHAMP+ receiver (15 −20 from the center), the outflow wings, and the red asymmetric profiles. Conclusions. The amount of molecular gas, in particular of HCN, at very high temperatures is larger than previously thought. A complex interplay between infall and outflow motions is present. Our basic model assumptions of pure central heating and a power-law radial density distribution can serve as approximations for most sources, but are too simple to explain all observed lines. In particular, taking into account clumpiness, multiplicity of heating sources and a more complex velocity field seems to be necessary to more closely match model calculations to observations. This would require three-dimensional radiative transfer modeling of high-resolution interferometric data.