JSON mode forces the model to emit valid JSON; the parser stops failing. Structured outputs (response_format with a schema) force specific keys and types. Skip regex post-processing: just enforce the schema. Use dataclass or Pydantic models to receive.
response_format={”type”: “json_object”} -> the model emits JSON.
OpenAI structured outputs: response_format with json_schema -> keys + types enforced.
Anthropic tool_use: define a tool schema; the model calls it (= structured reply).
Pydantic BaseModel + .model_validate(json.loads(out)) for downstream.
no json_mode -> free text -> regex fix-up -> fragile
json_mode + schema -> Pydantic validate -> reliable
Use json_mode or structured outputs whenever downstream code parses the response.