LangChain

ChatOpenAI JSON mode via model_kwargs; the prompt must contain the word json, and passing response_format directly warns but still works.

Simple Icons contributors / Simple IconsCC0 1.0

ChatOpenAI JSON mode via model_kwargs; the prompt must contain the word json, and passing response_format directly warns but still works.

chat = ChatOpenAI(model=ai_model_id, temperature=ai_model_params['temperature'], model_kwargs={"response_format": {"type": "json_object"}})

JSON mode — the prompt must also contain the term json.

If passed directly

UserWarning: WARNING! response_format is not default parameter.
                response_format was transferred to model_kwargs.
                Please confirm that response_format is what you intended.

But will work.

Updated: 2026 Aug 19