  We consider the generation of large-scale magnetic fields in slow-roll
inflation. The inflaton field is described in a supergravity framework where
the conformal invariance of the electromagnetic field is generically and
naturally broken. For each class of inflationary scenarios, we determine the
functional dependence of the gauge coupling that is consistent with the
observations on the magnetic field strength at various astrophysical scales
and, at the same time, avoid a back-reaction problem. Then, we study whether
the required coupling functions can naturally emerge in well-motivated,
possibly string-inspired, models. We argue that this is non trivial and can be
realized only for a restricted class of scenarios. This includes power-law
inflation where the inflaton field is interpreted as a modulus. However, this
scenario seems to be consistent only if the energy scale of inflation is low
and the reheating stage prolonged. Another reasonable possibility appears to be
small field models since no back-reaction problem is present in this case but,
unfortunately, the corresponding scenario cannot be justified in a stringy
framework. Finally, large field models do not lead to sensible model building.
