We study the conditions under which a generic supergravity model involving chiral and vector multiplets can admit viable metastable vacua with spontaneously broken supersymmetry and realistic cosmological constant. To do so, we impose that on the vacuum the scalar potential and all its first derivatives vanish, and derive a necessary condition for the matrix of its second derivatives to be positive definite. We study then the constraints set by the combination of the flatness condition needed for the tuning of the cosmological constant and the stability condition that is necessary to avoid unstable modes. We find that the existence of such a viable vacuum implies a condition involving the curvature tensor for the scalar geometry and the charge and mass matrices for the vector fields. Moreover, for given curvature, charges and masses satisfying this constraint, the vector of F and D auxiliary fields defining the Goldstino direction is constrained to lie within a certain domain. The effect of vector multiplets relative to chiral multiplets is maximal when the masses of the vector fields are comparable to the gravitino mass. When the masses are instead much larger or much smaller than the gravitino mass, the effect becomes small and translates into a correction to the effective curvature. We finally apply our results to some simple classes of examples, to illustrate their relevance.