  We assess the ODE/IM correspondence for the quantum $\mathfrak{g}$-KdV model,
for a non-simply laced Lie algebra $\mathfrak{g}$. This is done by studying a
meromorphic connection with values in the Langlands dual algebra of the affine
Lie algebra ${\mathfrak{g}}^{(1)}$, and constructing the relevant $\Psi$-system
among subdominant solutions. We then use the $\Psi$-system to prove that the
generalized spectral determinants satisfy the Bethe Ansatz equations of the
quantum $\mathfrak{g}$-KdV model. We also consider generalized Airy functions
for twisted Kac--Moody algebras and we construct new explicit solutions to the
Bethe Ansatz equations. The paper is a continuation of our previous work on the
ODE/IM correspondence for simply-laced Lie algebras.
