Flashcard: what is JSON mode (response_format) in LLM APIs and what does it guarantee?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
JSON mode is a provider flag that constrains the model's output to valid JSON at the token-sampling layer; schema-aware variants also enforce your declared field names and types.
Imagine the model is filling in a form, and the form has rules: this field must be a number, that field must be a list, the whole form must end with a closing brace. Without JSON mode, the model tries to follow the rules but might accidentally leave a comma in the wrong place or wrap the form in friendly chitchat. With JSON mode on, the form has rails. At every step the form-filler is only allowed to write characters that keep the form valid; invalid characters are not even on the menu. The form always comes back parseable. The model might still get a value wrong (writing the wrong number for a field), but you do not need to wrestle with broken JSON anymore.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define JSON mode as provider-enforced valid JSON via constrained decoding, name the major implementations, separate validity from correctness, and call out the reasoning + structured-output composition pattern.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming JSON mode also guarantees the values are correct. It guarantees the output parses and conforms to the schema; whether the model wrote the right number for revenue is a separate, prompt-level concern.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.