  We propose a relativistically covariant model of interacting dark energy
based on the principle of least action. The cosmological term $\Lambda$ in the
gravitational Lagrangian is a function of the trace of the energy--momentum
tensor $T$. We find that the $\Lambda(T)$ gravity is more general than the
Palatini $f(R)$ gravity, and reduces to the latter if we neglect the pressure
of matter. We show that recent cosmological data favor a variable cosmological
constant and are consistent with the $\Lambda(T)$ gravity, without knowing the
specific function $\Lambda(T)$.
