Recent detections of GeV photons in a few gamma-ray bursts (GRBs) by Fermi Large Area Telescope (LAT) imply huge bulk Lorentz factors to avoid a large γγ optical depth at high energy. Estimates can be as high as Γ≃ 103 in the most extreme cases. This puts severe constraints on models of the central engine and the jet acceleration in GRBs. These estimates are, however, obtained from a simplified single-zone model. We present here a more realistic calculation of the γγ opacity which takes into account the time, space and direction dependent photon field existing in an outflow with several relativistically moving emitting zones. The formalism is very general and can be applied to many models of the prompt GRB emission. We present results obtained for a numerical implementation in the framework of the internal shock model. We show the following results in this paper. (i) The minimum Lorentz factor Γmin in bright Fermi-LAT GRBs is reduced by a factor of ≃2–3 compared to previous estimates if the GeV and MeV emission are produced in the same region, and by an additional factor of ≃2–8 if the GeV emission is produced at larger radii. We provide an improved approximate formula for Γmin which is in good agreement with our numerical results and which can be directly applied to Fermi-LAT GRB data. (ii) A delayed onset of the GeV emission can be due to the time evolution of the opacity in a GRB outflow. As an illustration of these first two results, we present a synthetic GRB that reproduces most features of GRB 080916C with a mean Lorentz factor of ≃340, an optically thin regime for γγ opacity at 3 GeV in time bin ‘b’, a variability time-scale of ≃0.5 s in the MeV light curve and a delayed onset of ≃5 s of the GeV emission. (iii) The γγ opacity can smooth the short time-scale variability in the GeV light curve. This last result implies that the observed variability at high energy is not necessarily a good test to distinguish between an internal and an external origin for the GeV emission in GRBs.