OpenAI: "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'"
@devsingh05▲ 10 net votes
JSON mode requires the prompt itself to mention JSON, so add an instruction like 'Reply with a JSON object with keys name and score.' to the system or user message. Prefer structured outputs (response_format with a json_schema, or the SDK's parse helper with a Pydantic model), which validate the shape instead of only guaranteeing valid JSON. Either way, still handle a refusal or truncated reply before json.loads.