Skip to content
BENIBIX Learn

JSON Mode

AI🛠️ Working with AIOutput Control

Also known as JSON Output Mode, JSON Response Format

A switch so the model only replies with JSON that will load.

Think of it like

Think of it like a rule that all answers go in boxes. It does not say which boxes.

Example

Jack turns on JSON mode and asks for three cities. He gets valid JSON each time, but once the key is 'cities' and the next time it is 'city_list'.

Why it matters

It stops one common failure, a reply a program cannot parse. It does not stop the rest.

Definition

JSON mode is a setting that makes a model reply only with valid JSON. The reply will parse, so a program will not crash on stray words. But JSON mode does not check the shape, so fields can be missing or named in other ways. Structured output with a schema is the stricter, newer option. JSON mode still helps where no schema is set or the API offers nothing else.

Example code

json
{"cities": ["Lisbon", "Oslo", "Kyoto"]}
Valid JSON every time, but nothing makes the key stay the same between calls.
All three replies are valid JSON. But the key changes from one call to the next.

Common mistake

Using JSON mode and assuming the fields will match. Use a schema when the shape matters.

Key takeaways

  1. 1
    Always valid JSON. It will parse.
  2. 2
    No set shape. Fields can change.
  3. 3
    Schema is stricter. Use it when it matters.

Compare

Learn it properly