nemoguardrails.llm.openai_reasoning
nemoguardrails.llm.openai_reasoning
Module Contents
Functions
Data
API
Drop unsupported params and remap max_tokens for OpenAI reasoning models.
OpenAI reasoning models (o-series, gpt-5+) require max_completion_tokens
instead of max_tokens and reject temperature / stop on most
members of the family. This helper applies the rename and the drop list
in one place so the DefaultFramework OpenAI client and the LangChain
adapter cannot drift on what they strip.
The drop list is deliberately limited to the params OpenAI’s API itself is documented to reject (verified by the live probe in tests/integrations/langchain/test_openai_param_filter.py); other sometimes-rejected params (top_p, presence_penalty, etc.) are accepted by some reasoning models in the family and are left to the caller.
Returns a new dict; does not mutate the input.
Drops: temperature, stop.
Renames: max_tokens -> max_completion_tokens (only if
max_tokens carries a non-None value and max_completion_tokens
is not already present, so an explicit max_completion_tokens
always wins and an unset max_tokens is not promoted to a null
wire field).
True for OpenAI reasoning models (o1/o3/o4 series, gpt-5+).
Used to decide whether to strip parameters that OpenAI rejects on these models (temperature, stop, etc.) and how to remap others (max_tokens -> max_completion_tokens). Shared by the DefaultFramework OpenAI client and the LangChain adapter so the two paths cannot drift.