Comparison
Constrained decodingvsJSON mode
Constrained decoding
at each step, delete every next-token option that would break the format, then sample from what remains.
Enforcing structure during generation by masking invalid tokens at every step, so the model literally cannot produce output that violates the schema or grammar. This is how strict structured output modes achieve near-100 percent conformance.
Full entry →JSON mode
the response parsed cleanly and still had the wrong keys in it, because the flag only ever promised valid JSON.
A request flag guaranteeing the output is syntactically valid JSON. It does not guarantee the right keys, types or values; it only guarantees the string will parse. Weaker than schema-enforced structured output, and the distinction matters.
Full entry →