Skip to main content
Reasoning models (OpenAI o1, o3, o4, gpt-5.x) accept a different set of parameters β€” PraisonAI detects them automatically and normalises your Agent(...) config so the same code just works.

Quick Start

1

Use a reasoning model

No extra flags. PraisonAI detects reasoning models and normalises parameters for you.
2

Cap the response length

You can keep writing max_tokens=... β€” on reasoning models it is rewritten to max_completion_tokens before the request.

How It Works

PraisonAI checks the model before every call and rewrites parameters only when the model is a reasoning model.

Recognised Models

Detection uses two paths, in order:
  1. Primary: litellm.supports_reasoning(model=model_name) when litellm is installed and exposes the helper.
  2. Fallback: strip the provider prefix (e.g. openai/, azure/) and match the lowercase prefix β€” o1, o3, o4, or gpt-5.
Results are cached with functools.lru_cache(maxsize=256).
Provider prefixes are stripped before matching: openai/o3-mini β†’ o3-mini. Both the native OpenAI client path and the LiteLLM path use the same is_reasoning_model() check, so any model LiteLLM’s supports_reasoning() recognises is normalised on either path, not only the prefix-matched families.

Parameter Behaviour

Before PraisonAI #5910 (merged 2026-10-19), Agent(llm="o3-mini" | "gpt-5" | …) could send a request body containing "max_tokens": null, which reasoning models rejected with 400 invalid_type (Invalid type for 'max_tokens': expected an unsupported value, but got null instead.) and the agent returned an empty answer. The native OpenAI client path now omits unset temperature/max_tokens and maps an explicit max_tokens to max_completion_tokens for reasoning models β€” your Agent(...) code just works.
On a reasoning model, PraisonAI rewrites and drops parameters as follows. Which rules apply depends on the path the request takes.
Reasoning models reject temperature, top_p, and penalty params. On the LiteLLM path PraisonAI drops them silently so your code keeps working β€” but the values have no effect. On the native OpenAI client path they are forwarded, so leave them unset. If you rely on deterministic sampling, use a chat model instead.

Which Parameters Should I Set?

Pick your parameters based on the model you chose.

Common Patterns

Mix reasoning and chat models in one team β€” each agent normalizes independently based on its own model.
Be explicit with max_completion_tokens when you want it to win over max_tokens.
Migrate from a chat model to a reasoning model with no code changes.

Best Practices

They have no useful effect β€” dropped on the LiteLLM path, forwarded to the provider on the native OpenAI client path. If you rely on determinism or creative sampling, prefer a chat model such as gpt-4o.
It always wins over max_tokens on reasoning models, so there is no ambiguity about which limit applies.
Swapping gpt-4o β†’ gpt-5 silently drops your sampling params. Behaviour differs even though no error is raised β€” verify output quality first.
Detection prefers litellm.supports_reasoning(). The prefix fallback only covers the o1/o3/o4/gpt-5 families, so newer models are recognised sooner with an up-to-date litellm.

Reasoning

Step-by-step reasoning as a technique.

Model Capabilities

Capability detection helpers, including is_reasoning_model().

Thinking Budgets

Budget reasoning tokens for controllable cost.

OpenAI Quickstart

First-time setup with OpenAI models.