Deformed explicitly correlated Gaussian (DECG) basis functions are introduced, and their matrix elements are calculated. All matrix elements can be calculated analytically in a closed form, except the Coulomb one, which has to be approximated by a Gaussian expansion. The DECG basis functions can be used to solve problems with nonspherical potentials. One example of such potential is the dipole self-interaction term in the Pauli–Fierz Hamiltonian. Examples are presented showing the accuracy and necessity of deformed Gaussian basis functions to accurately solve light–matter coupled systems in cavity QED.