A system consisting of two slabs with different temperatures can exhibit a nonequilibrium lateral Casimir force on either one of the slabs when Lorentz reciprocity is broken in at least one of the slabs. This system constitutes a photonic heat engine that converts radiative heat into work done by the nonequilibrium lateral Casimir force. Reversely, by sliding two slabs at a sufficiently high relative velocity, heat is pumped from the slab at a lower temperature to the other one at a higher temperature. Hence the system operates as a photonic heat pump. In this paper, we study the thermodynamic performance of such a photonic heat engine and pump via the fluctuational electrodynamics formalism. The propulsion force due to the nonreciprocity and the drag force due to the Doppler effect were revealed as the physical mechanisms behind the heat engine. We also show that in the case of the heat pump, the use of nonreciprocal materials can help reduce the required velocity. We present an ideal material dispersion to reach the Carnot efficiency limit. Furthermore, we derive a relativistic version of the thermodynamic efficiency for our heat engine and prove that it is bounded by the Carnot efficiency that is independent of the frame of reference. Our paper serves as a conceptual guide for the realization of photonic heat engines based on fluctuating electromagnetic fields and relativistic thermodynamics and shows the important role of electromagnetic nonreciprocity in operating them.