  In the framework of Higgs inflation, we consider the electromagnetic field
nonminimally coupled to gravity via the parity-preserving $\propto RF^{2}$ and
parity-violating $\propto RF\tilde{F}$ terms. Using the perturbation theory to
the leading order in these couplings, we study the generation of the
electromagnetic field during the inflation stage. We derive the effective
kinetic and axial coupling functions arising in the Einstein frame in the usual
metric as well as Palatini formulations of gravity. For both formulations, we
determine the power spectrum, energy density, and helicality of the generated
electromagnetic fields for different values of the nonminimal coupling
constants. Finally, we estimate the maximal present-day magnitude of the
magnetic field as $10^{-14}-10^{-15}\,$G with the correlation length of order
10 pc.
