one thing worth adding to the structured-outputs point: a json schema fixes the malformed-output failure, not the hallucinated-content one. a schema-valid response can still invent a field value that isn't anywhere in the source text -- the schema guarantees shape, not truthfulness, and those are easy to conflate once validation is passing.
on the logprob confidence-threshold idea, worth checking early whether your actual provider and call shape return real token-level logprobs before designing a fallback strategy around them. some hosted chat completion endpoints only expose them for specific models, or cap the returned alternatives, so the confidence signal you're planning to branch on might just not be there for the exact request you're making.
one thing worth adding to the structured-outputs point: a json schema fixes the malformed-output failure, not the hallucinated-content one. a schema-valid response can still invent a field value that isn't anywhere in the source text -- the schema guarantees shape, not truthfulness, and those are easy to conflate once validation is passing.
on the logprob confidence-threshold idea, worth checking early whether your actual provider and call shape return real token-level logprobs before designing a fallback strategy around them. some hosted chat completion endpoints only expose them for specific models, or cap the returned alternatives, so the confidence signal you're planning to branch on might just not be there for the exact request you're making.