Build an AI feature with clear failure handling
Model output needs the same care as any external service: validation, evaluation, and an honest response when a request cannot be completed.
Define a contract
Describe the exact data the interface needs. Request structured output where supported and validate every field before using it.
Handle service failures
Expect quota limits, invalid credentials, timeouts, and incomplete output. Return actionable messages and avoid replacing an error with invented content.
Evaluate the useful behavior
Collect realistic examples including missing evidence and ambiguous input. Measure whether the output fulfills the task and records its uncertainty.