We analyzed the evolution of the metallicity of the gas with the redshift for
a sample of AGNs in a very wide redshift range (0<z<4) using ultraviolet
emission-lines from the narrow-line regions (NLRs) and photoionization models.
The new index C43=log(CIV+CIII])/HeII is suggested as a metallicity indicator
for AGNs. Based on this indicator, we confirmed the no metallicity evolution of
NLRs with the redshift pointed out by previous works. We found that metallicity
of AGNs shows similar evolution than the one predicted by cosmic semi-analytic
models of galaxy formation set within the Cold Dark Matter merging hierarchy
(for z < 3). Our results predict a mean metallicity for local objects in
agreement with the solar value (12+log(O/H)=8.69). This value is about the same
that the maximum oxygen abundance value derived for the central parts of local
spiral galaxies. Very low metallicity log(Z/Z_{\odot})~ -0.8 for some objects
in the range 1.5 < z <3 is derived.Comment: 25 pages, 10 figures, accepted MNRA