We introduce a general framework to describe the stationary state of two driven systems exchanging particles or mass through a contact, in a slow exchange limit. The definition of chemical potentials for the systems in contact requires that the large-deviations function describing the repartition of mass between the two systems is additive, in the sense of being a sum of contributions from each system. We show that this additivity property does not hold for an arbitrary contact dynamics, but is satisfied on condition that a macroscopic detailed balance condition holds at contact, and that the coarse-grained contact dynamics satisfies a factorization property. However, the nonequilibrium chemical potentials of the systems in contact keep track of the contact dynamics, and thus do not obey an equation of state. These nonequilibrium chemical potentials can be related either to the equilibrium chemical potential, or to the nonequilibrium chemical potential of the isolated systems. Results are applied both to an exactly solvable driven lattice gas model, and to the Katz-Lebowitz-Spohn model using a numerical procedure to evaluate the chemical potential. The breaking of the additivity property is also illustrated on the exactly solvable model. arXiv:1909.00432v2 [cond-mat.stat-mech] 2 Dec 2019with (∆N A ) c referring to the sum over configurations C A , C B that, respectively, contain N (C A ) = ρ A V A + ∆N A and N (C B ) = ρ B V B − ∆N A particles (the second sum being exactly the same with ∆N A = 0).