A theoretical model that can efficiently calculate the refractive index response of semiconductors under ultrafast X-ray radiation is established based on the photorefractive effect of semiconductors. The proposed model is used to interpret X-ray diagnostics experiments, and the results are in good agreement with experiments. In the proposed model, a rate equation model of free carrier density calculation is adopted with the X-ray absorption cross-sections calculated by atomic codes. The two-temperature model is used to describe the electron-lattice equilibration and the extended Drude model is applied to calculate the transient refractive index change. It is found that faster time response can be achieved for semiconductors with shorter carrier lifetime and sub-picosecond resolution can be obtained for InP and [Formula: see text]. The material response time is not sensitive to X-ray energy and the diagnostics can be used in the 1-10 keV energy range. This article is part of the theme issue 'Dynamic and transient processes in warm dense matter'.