A service calling a model through a gateway sees one HTTP response. It does not see which provider answered, which prompt was applied, or whether the reply was forced into a schema by constrained decoding. That reply might be a JSON object, a token stream of a JSON object, a markdown fence wrapping an object, or plain prose when a safety layer intervened.
Structured outputs make this better but do not make it free. OpenAI's documentation describes Structured Outputs as guaranteeing the model adheres to the supplied JSON Schema, and it notes that safety-based refusals become programmatically detectable in the OpenAI structured outputs guide. The same guide is explicit that responses can carry refusals, which means a reply is not always the object you asked for.
Partial parsing libraries exist precisely because the first bytes of a streaming reply are not valid JSON. best-effort-json-parser returns partial data rather than throwing on truncated input, and it strips markdown fences around JSON it finds in its npm documentation. A library like that shows the problem: every consumer has to decide what to do with {"name": "Ali before it knows whether the reply is destined to be a person, an error, or a refusal.
Push that decision to every consumer and you get the drift you get with hand-written validation in each request handler. One team checks the first key, another checks the second, a third checks nothing because the prototype worked. API Gateway documentation makes the cost of that pattern plain: without validation at the gateway, every malformed request reaches the backend and validation code is written in every handler in this OneUptime guide. Responses deserve the same treatment.



