Biotic and abiotic stresses cause special defense reactions in plant organs, which after a series of reactions, these stresses produce secondary metabolites. The effect of ultraviolet radiation on the expression of key genes involved in the biosynthesis of secondary metabolites (Phenylalanine ammonia lyase (PAL), Hydroxymethylglutaryl-CoA reductase (HMG-CoA reductase), GPP synthases, Deoxyribonino heptulosinate 7-phosphate synthase (DAHP), and Deoxy Xylose Phosphate Synthase (DXS)), and the association of these genes with different amounts of secondary metabolites (phenol, terpene, flavonoids, anthocyanins, alkaloids, lycopene, and beta-carotene) was investigated in this study. The results of this study showed that the application of UV-B stress significantly increased the expression of GPPs, HMG-CoA reductase, DXS, DAHPs, and PAL genes compared to the control plants. The expression of two key genes involved in the biosynthesis of phenylpropanoids, including DAHPs and PAL, increased with UV-B stress, and the highest expression was related to the PAL gene. The results revealed that UV-B stress caused a significant increase in total levels of terpenoids, phenols, flavonoids, anthocyanins, alkaloids, beta-carotene, and lycopene. The highest relative expression of all genes was obtained in treatment A (UV-B radiation for 1h), while in treatment B (UV-B radiation for 2h), no significant changes were observed in the expression of the genes.