A software company's internal automation pipeline calls a Foundry-hosted chat model to extract invoice fields (vendor name, invoice number, total amount) from emailed PDFs and passes the result straight into an accounting API that requires a fixed set of named fields with no extra text. In several test runs the model wrapped its answer in a sentence like 'Here is the extracted data:' before the values, which broke the automated parser. Which approach should the team use so the model reliably returns only the required fields in a parseable form?
Select an answer to reveal the explanation.
Short Explanation
The real problem here isn't that the model is being chatty for no reason, it's that nothing is actually forcing it to stick to a fixed format. Telling it in the prompt to 'format nicely' is just a polite request, and the model can drift from that request any time its wording changes slightly. The fix that actually works is to give the model a strict template for its output, a schema listing exactly which fields must appear and nothing else, so the model has no room to add a friendly opening line. That's fundamentally different from making the model less random, since a very predictable model can still choose to add a sentence before the data. It's also different from teaching the model more about invoices through additional training, because that changes what it knows, not how rigidly it packages its answer. When a downstream system needs guaranteed structure, the fix is constraining the output shape itself, not hoping the model behaves or cleaning up its mess after the fact.
Full Explanation
The correct answer is B. Structured outputs let the team supply a JSON schema that names the exact fields the accounting API expects; Foundry constrains the model's generation to that schema, so every response is machine-parseable with no stray sentences to strip. Option A is incorrect because prompt wording is only a suggestion the model can ignore, and building post-processing code to catch every possible phrasing is fragile and will keep breaking as the model varies its wording. Option C is incorrect because fine-tuning on invoice examples might teach the model the domain vocabulary, but it does not guarantee a fixed output structure; the model can still add conversational framing unless the response format itself is constrained. Option D is incorrect because temperature controls how varied or creative the wording is, not whether the model wraps its answer in extra text; a low-temperature response can still include an introductory sentence. Structured outputs address the actual problem directly: enforcing a schema at generation time rather than hoping for compliant phrasing or cleaning up the output afterward.