  Inversion codes are computer programs that fit a model atmosphere to the
observed Stokes spectra, thus retrieving the relevant atmospheric parameters.
The rising interest in the solar chromosphere, where spectral lines are formed
by scattering, requires developing, testing, and comparing new non-local
thermal equilibrium (NLTE) inversion codes.
  We present a new NLTE inversion code that is based on the analytical
computation of the response functions. We named the code SNAPI, which is short
for spectropolarimetic NLTE analytically powered inversion. SNAPI inverts full
Stokes spectrum in order to obtain a depth-dependent stratification of the
temperature, velocity, and the magnetic field vector. It is based on the
so-called node approach, where atmospheric parameters are free to vary in
several fixed points in the atmosphere, and are assumed to behave as splines in
between. We describe the inversion approach in general and the specific choices
we have made in the implementation. We test the performance on one academic
problem and on two interesting NLTE examples, the Ca\,II\,8542 and Na\,I\,D
spectral lines. The code is found to have excellent convergence properties and
outperforms a finite-difference based code in this specific implementation by
at least a factor of three. We invert synthetic observations of Na lines from a
small part of a simulated solar atmosphere and conclude that the Na lines
reliably retrieve the magnetic field and velocity in the range $-3<\log \tau <
-0.5$.
