  [abridged] We use the latest release of CIGALE, a galaxy SED fitting model
relying on energy balance, to study the influence of an AGN in estimating both
the SFR and stellar mass in galaxies, as well as the contribution of the AGN to
the power output of the host. Using the galaxy formation SAM GALFORM, we create
mock galaxy SEDs using realistic star formation histories (SFH) and add an AGN
of Type 1, Type 2, or intermediate type whose contribution to the bolometric
luminosity can be variable. We perform an SED fitting of these catalogues with
CIGALE assuming three different SFHs: a single- and
double-exponentially-decreasing, and a delayed SFH. Constraining
thecontribution of an AGN to the LIR (fracAGN) is very challenging for
fracAGN<20%, with uncertainties of ~5-30% for higher fractions depending on the
AGN type, while FIR and sub-mm are essential. The AGN power has an impact on
the estimation of $M_*$ in Type 1 and intermediate type AGNs but has no effect
for galaxies hosting Type 2 AGNs. We find that in the absence of AGN emission,
the best estimates of $M_*$ are obtained using the
double-exponentially-decreasing model but at the expense of realistic ages of
the stellar population. The delayed SFH model provides good estimates of $M_*$
and SFR, with a maximum offset of 10% as well as better estimates of the age.
Our analysis shows that the underestimation of the SFR increases with fracAGN
for Type 1 systems, as well as for low contributions of an intermediate AGN
type, but it is quite insensitive to the emission of Type 2 AGNs up to
fracAGN~45%. Similarly the UV emission is critical in accurately retrieving the
$M_*$ for Type 1 and intermediate type AGN, and the SFR of all of the three AGN
types. We show that the presence of AGN emission introduces a scatter to the
SFR-$M_*$ main sequence relation derived from SED fitting, which is driven by
the uncertainties on $M_*$.
