In this contribution we report our recent investigation of the gas metallicity in active galactic nuclei and its dependence on luminosity and redshift. We compile large spectroscopic datasets of broad-line and narrow-line AGNs, and compare them with the results of our photoionization models. Through the analysis of both the broad and the narrow emission-line regions, we find that: (1) for a given luminosity, there is no redshift dependence of the gas metallicity; (2) for a given redshift, there is a significant correlation between gas metallicity and luminosity; (3) the luminosity-metallicity relation does no show any evolution in the redshift range 2 < z < 4.