  In circuit QED, a Rabi model can be derived by truncating the Hilbert space
of the anharmonic qubit coupled to a linear, reactive environment. This
truncation breaks the gauge invariance present in the full Hamiltonian. We
analyze the determination of an optimal gauge such that the differences between
the truncated and the full Hamiltonian are minimized. Here, we derive a simple
criterion for the optimal gauge. We find that it is determined by the ratio of
the anharmonicity of the qubit to an averaged environmental frequency. We
demonstrate that the usual choices of flux and charge gauge are not necessarily
the preferred options in the case of multiple resonator modes.
