A physics-based approach to gamma-ray response-function generation is presented in which the response of CdZnTe detectors is modeled from first principles. Numerical modeling is used to generate response functions needed for spectrum analysis for general detector configurations (e.g., electrode design, detector materials and geometry, and operating conditions). With numerical modeling, requirements for calibration and characterization are significantly reduced. Elements of the physics-based model, including gamma-ray transport, charge carrier drift and diffusion, and circuit response, are presented. Calculated and experimental gamma-ray spectra are compared for a coplanar-grid CdZnTe detector.