This paper proposes and analyzes a generalized epidemic model over arbitrary directed graphs with heterogeneous nodes. The proposed model, called the generalized–susceptible exposed infected vigilant, subsumes a large number of popular epidemic models considered in the literature as special cases. Using a mean-field approximation, we derive a set of ODEs describing the spreading dynamics, provide a careful analysis of the disease-free equilibrium, and derive necessary and sufficient conditions for global exponential stability. Building on this analysis, we consider the problem of containing an initial epidemic outbreak under budget constraints. More specifically, we consider a collection of control actions (e.g., administering vaccines/antidotes, limiting the traffic between cities, or running awareness campaigns), for which we are given suitable cost functions. In this context, we develop an optimization framework to provide solutions for the following two allocation problems: 1) find the minimum cost required to eradicate the disease at a desired exponential decay rate, and 2) given a fixed budget, find the resource allocation to eradicate the disease at the fastest possible exponential decay rate. Our technical approach relies on the reformulation of these problems as geometric programs that can be solved efficiently in polynomial time using tools from graph theory and convex optimization. In contrast with previous works, our optimization framework allows us to simultaneously allocate different types of control resources over heterogeneous populations under budget constraints. We illustrate our results through numerical simulations.