The response of a silicon photomultiplier (SiPM) to optical signals is inherently nonproportional due to saturation, afterpulsing, and crosstalk. Existing models of the SiPM response do not account for all of these effects, and therefore, these models are not sufficiently accurate for many applications. In this work, a comprehensive model of the SiPM response is developed that is generally applicable to exponentially decaying light pulses and that can be simplified in the case of very short (e.g., laser) light pulses. The model accounts for the total number and the temporal distribution of the incident photons as well as for the relevant SiPM parameters, viz. the recovery time, afterpulsing, crosstalk, and their cross correlations. The model is shown to correspond well with measurements on a SiPM-based scintillation detector. Furthermore, it is shown to be in agreement with several cases for which the SiPM response is known a priori. Having thus validated the model, its use is demonstrated by predicting the response of the Hamamatsu multipixel photon counter (MPPC) S10362-33-050C SiPM to several different scintillators.