  We present chemical models of the envelope of a young stellar object (YSO)
exposed to a central X-ray source. The models are applied to the massive
star-forming region AFGL 2591 for different X-ray fluxes. The total X-ray
ionization rate is dominated by the `secondary' ionization rate of H2 resulting
from fast electrons. The carbon, sulphur and nitrogen chemistries are
discussed. It is found that He+ and H3+ are enhanced and trigger a peculiar
chemistry. Several molecular X-ray tracers are found and compared to tracers of
the far ultraviolet (FUV) field. Like ultraviolet radiation fields, X-rays
enhance simple hydrides, ions and radicals. In contrast to ultraviolet photons,
X-rays can penetrate deep into the envelope and affect the chemistry even at
large distances from the source. Whereas the FUV enhanced species cover a
region of 200-300 AU, the region enhanced by X-rays is >1000 AU. Best-fit
models for AFGL 2591 predict an X-ray luminosity LX > 1e+31 ergs/s with a hard
X-ray spectrum TX > 3e+07 K. Furthermore, we find LX/Lbol ~ 1e-6. The chemistry
of the bulk of the envelope mass is dominated by cosmic-ray induced reactions
rather than by X-ray induced ionization for X-ray luminosities LX < 1e+33
ergs/s. The calculated line intensities of HCO+ and HCS+ show that high-J lines
are more affected than lower J lines by the presence of X-rays due to their
higher critical densities, and that such differences are detectable even with
large aperture single-dish telescopes. Future instruments such as Herschel-HIFI
or SOFIA will be able to observe X-ray enhanced hydrides whereas the
sensitivity and spatial resolution of ALMA is well-suited to measure the size
and geometry of the region affected by X-rays.
