<ul data-eligibleForWebStory="true">Large language models (LLMs) have increased the demand for machine-generated text.Current pay-per-token pricing schemes lead to a misalignment of incentives known as moral hazard.There is a strong incentive for text-generating agents to prefer a cheaper model over a cutting-edge one.This preference can be done internally, impacting the quality of generated text.To address this issue, a pay-for-performance, contract-based framework is proposed to incentivize text quality.The framework involves a principal-agent game where the agent generates text using costly inference.Contracts determine the principal's payment based on an automated quality evaluation of the text.Standard contract theory is insufficient when internal inference costs are unknown.Cost-robust contracts are introduced to deal with this uncertainty.Optimal cost-robust contracts are characterized through a connection to optimal composite hypothesis tests from statistics.Empirical evaluation of the framework involves deriving contracts for various objectives and LLM evaluation benchmarks.Cost-robust contracts show only a slight decrease in objective value compared to their cost-aware counterparts.The study offers insights into incentivizing quality text generation through contracts.Cost-robust contracts are found to be effective in maintaining text quality while addressing cost considerations.The work bridges economic principles and statistical approaches to improve text generation incentives.