Different non-equilibrium situations have recently been considered when studying the thermal Casimir--Polder interaction with a body. We show that the Keldysh Green function method provides a very general common framework for such studies where non-equilibrium of either the atom or the body with the environment can be accounted for. We apply the results to the case of ground state polar molecules out of equilibrium with their environment, observing several striking effects. We consider thermal Casimir--Polder potentials in planar configurations, and new results for a molecule in a cylindrical cavity are reported, showing similar characteristic behaviour as found in planar geometry.