  The full third Gaia data release will provide the calibrated spectra obtained
with the blue and red Gaia slit-less spectrophotometers. The main challenge
when facing Gaia spectral calibration is that no lamp spectra or flat fields
are available during the mission. Also, the significant size of the line spread
function with respect to the dispersion of the prisms produces alien photons
contaminating neighbouring positions of the spectra. This makes the calibration
special and different from standard approaches.
  This work gives a detailed description of the internal calibration model to
obtain the spectrophotometric data in the Gaia catalogue. The main purpose of
the internal calibration is to bring all the epoch spectra onto a common flux
and pixel (pseudo-wavelength) scale, taking into account variations over the
focal plane and with time, producing a mean spectrum from all the observations
of the same source.
  In order to describe all observations in a common mean flux and
pseudo-wavelength scale, we construct a suitable representation of the
internally calibrated mean spectra via basis functions and we describe the
transformation between non calibrated epoch spectra and calibrated mean spectra
via a discrete convolution, parametrising the convolution kernel to recover the
relevant coefficients.
  The model proposed here is able to combine all observations into a mean
instrument to allow the comparison of different sources and observations
obtained with different instrumental conditions along the mission and the
generation of mean spectra from a number of observations of the same source.
The output of this model provides the internal mean spectra, not as a sampled
function (flux and wavelength), but as a linear combination of basis functions,
although sampled spectra can easily be derived from them.
