In situations where quality is fixed, the widely used RPI-X regulatory mechanism has a number of desirable properties, such as convergence to a second best optimum. Theoretical analysis of this mechanism in the case of endogenous quality is limited and therefore regulators have typically imposed constraints on the firm’s quality choice in ad hoc manners, either by mandating quality levels, or by including quality adjustment factors in the RPI-X mechanism. In this paper, we construct the rigorous theoretical counterpart of these manners of including quality measures in the constraints faced by a regulated firm. This mechanism converges to second best optimum. It works by offering the firm trade-offs between prices and qualities based on the choice it made in the previous period; however, reflecting the practical problem valuing quality, the informational requirement to select these trade-offs appropriately is qualitatively stronger than in the fixed quality case. Moreover, even when the informational problem can be overcome, we identify a further potential pitfall in the approach taken in practice by regulators, and show that, in order to avoid it, the regulated firm should be subject to an additional constraint, which we label the distance constraint, and which can be interpreted as requiring the firms to choose prices and qualities within a band in every period.