The NIRSpec instrument of JWST can be operated in multi-object (MOS), long-slit, and integral field mode with spectral resolutions from 100 to 2700. Its MOS mode uses about a quarter of a million individually addressable mini-slits for object selection, covering a field of view of 9 square-arcminute. We have developed a procedure to optimize a parametric model of the instrument that provides the basis for the extraction of wavelength calibrated spectra from NIRSpec data, from any of the apertures and for all the modes. Here, we summarize the steps undertaken to optimize the instrument model parameters using the data acquired during the latest cryo-vacuum campaign of the JWST Integrated Science Instrument Module, recently carried out at NASA Goddard Space Flight Center. The calibrated parametric model is able to reproduce the spatial and spectral position of the input spectra with an intrinsic accuracy (1-sigma, RMS) ~ 1/10 of a pixel in spatial and spectral direction for all the modes. The overall wavelength calibration accuracy (RMS) of the model as measured on the extracted spectra is better than 1/20 of a resolution element for all of the grating-based spectral modes and at the level of 1/14 of a resolution element for the prism. These results are well within the allocations for the model in the overall spatial and spectral calibration budget of NIRSpec.