Context. Gas cooling and other thermal processes in the interstellar medium are intimately related to its chemical evolution. To accurately model chemical processes in large-scale gas-dynamical simulations the usage of existing sophisticated astrochemical networks is presently impossible due to prohibitive computational costs. A viable way to deal with the problem is by the design of reduced chemical networks that satisfactorily reproduce the most important features of the more elaborate networks. Aims. A chemistry and cooling module for the interstellar medium is developed that is realistic for temperatures T ≳ 50 K and for densities up to n ≈ 1010 m−3 at the limit of non-ionizing and non-dissociating background radiation. The module is incorporated into the multiphysics, adaptive-grid code NIRVANA and aims at improving gas-dynamical simulations by explicitly following non-equilibrium chemistry and gas cooling. Methods. The presented chemical network covers 121 species and 426 reactions. It includes a fully-fledged ionization subnetwork for the ten elements H, D, He, C, N, O, Mg, Ne, Si, and Fe, chemical schemes for the formation and destruction of the important molecular coolants H2, H2O, CO, and OH, a model for dust-catalytic reactions and cosmic ray effects. Metal line cooling was computed from first principles by solving for the energy level population for each ion. Atomic data was adopted from the latest version of the Chianti database. The treatment of rotovibrational line cooling from molecules was based on various up-to-date literature sources. Results. The implementation has been validated by performing both equilibrium and non-equilibrium (time-dependent) computations. The equilibrium results overall confirm the temperature dependence of chemical abundances and the gas cooling rate that has been found in similar studies. In particular, the ionization structure in the high-temperature regime, at T ≳ 2 × 104 K, excellently agrees with literature results. In the non-equilibrium calculations, the occurrence of ionization lags are prominent and distinguishes the resulting non-equilibrium cooling from equilibrium cooling. In the low-temperature regime, at T ≲ 2 × 104 K, the non-equilibrium cooling rate can be enhanced by up to two orders of magnitude compared to the equilibrium value. Conclusions. The NIRVANA chemistry and cooling module has been successfully tested against literature results. The underlying chemical network is best compared to recently developed networks in the limit of no radiation with differences appearing in the treatment of dust, cosmic ray heating, and in the choice of reaction coefficients. The gas cooling experiments indicate that a reduction of the present network size seems possible under certain conditions by skipping the elements N and Mg, which turn out to be less important coolants compared to the conglomerate of C, O, Si, and Fe coolants.