ReasoningOpenAIChatClient<T>
Models & Types · AiDotNet.Agentic.Models.Connectors
An OpenAI Chat Completions connector that adapts its request body when the model is a reasoning model: it
removes the sampling settings those models reject, sends the answer cap as max_completion_tokens, and
attaches a reasoning_effort level when one is configured.
Inheritance: ChatClientBase<T> → OpenAIChatClient<T> → ReasoningOpenAIChatClient<T>
Known derived types: ReasoningAzureOpenAIChatClient<T>
For Beginners
Use this instead of OpenAIChatClient whenever the model you name
might be one of OpenAI’s reasoning models (anything starting with o1, o3, o4-, or
gpt-5). Those models are fussy about request settings, and this class quietly fixes the request for you —
and tells you what it fixed. For every other model it behaves identically to the plain connector, so it is safe
to use as your default.
How It Works
The OpenAI o-series and GPT-5 families and the GPT-OSS releases enforce three differences from an ordinary chat
model, and every one of them is a hard error rather than a warning. They reject temperature and
top_p; they refuse max_tokens and require the cap under the name max_completion_tokens; and
they accept an optional reasoning_effort. A request built for gpt-4o and pointed at o3
therefore fails with an HTTP 400 before a single token is generated. This connector is
OpenAIChatClient with those three rules applied, so switching a run from gpt-4o to
o3 is a change of model id and nothing else.
Detection is by model-id prefix through a ReasoningModelProfileRegistry, never by endpoint. The
same weights are reachable through OpenAI, Azure, OpenRouter, and local proxies, and all of them enforce the
same rules, so a check on the base URL would be wrong on most of those. When the model id matches no profile —
gpt-4o, a fine-tune, a third-party model — the request body is exactly what the base connector produces,
byte for byte.
Two behaviours go beyond the reference implementation. Every adjustment is recorded and readable through
GetDiagnosticSummary, so a run can prove that its configured temperature never applied instead of
leaving that to be inferred; and UnsupportedParameterHandling can be set to fail loudly rather than drop,
for a pipeline where losing the setting silently would invalidate the comparison being made. Upstream builds a
separate parameter dictionary and records nothing.
The system message is left under the system role by default, which is what upstream sends to these
models and what the endpoint accepts. Set RewriteSystemMessageRole and give the profile a different role
name only for a provider that insists on the newer developer role.
Constructors
| Constructor | Summary |
|---|---|
ReasoningOpenAIChatClient(string apiKey, string modelName, string endpoint, HttpClient httpClient, ReasoningModelOptions options) |
Initializes a reasoning-aware OpenAI chat client. |
Properties
| Property | Summary |
|---|---|
ReasoningModelProfile Profile { get; } |
Gets the profile matching this client’s model, or null when it is an ordinary chat model. |
bool IsReasoningModel { get; } |
Gets whether this client’s model is recognised as a reasoning model. |
Methods
| Method | Summary |
|---|---|
IReadOnlyDictionary<string, ReasoningModelDiagnosticSummary> GetDiagnosticSummary() |
Gets one entry per distinct request adjustment made so far, with how often it occurred. |
ReasoningModelOptions GetOptions() |
Gets a copy of the reasoning settings in force. |