Active galactic nuclei (AGN) are typically identified through radio, mid-infrared, or X-ray emission or through the presence of broad and/or narrow emission lines. AGN can also leave an imprint on a galaxy's spectral energy distribution (SED) through the re-processing of photons by the dusty torus. Using the SED fitting code P S with an incorporated AGN component, we fit the far ultraviolet to far-infrared SEDs of ∼494,000 galaxies in the D10-COSMOS field and ∼230,000 galaxies from the GAMA survey. By combining an AGN component with a flexible star formation and metallicity implementation, we obtain estimates for the AGN luminosities, stellar masses, star formation histories, and metallicity histories for each of our galaxies. We find that P S can identify AGN components in 91 per cent of galaxies pre-selected as containing AGN through narrow-emission line ratios and the presence of broad lines. Our P S -derived AGN luminosities show close agreement with luminosities derived for X-ray selected AGN using both the X-ray flux and previous SED fitting results. We show that incorporating the flexibility of an AGN component when fitting the SEDs of galaxies with no AGN has no significant impact on the derived galaxy properties. However, in order to obtain accurate estimates of the stellar properties of AGN host galaxies, it is crucial to include an AGN component in the SED fitting process. We use our derived AGN luminosities to map the evolution of the AGN luminosity function for 0 < 𝑧 < 2 and find good agreement with previous measurements and predictions from theoretical models.