You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/thinking.md
+33-31Lines changed: 33 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,27 +6,20 @@ providing its final answer.
6
6
This capability is typically disabled by default and depends on the specific model being used.
7
7
See the sections below for how to enable thinking for each provider.
8
8
9
-
Internally, if the model doesn't provide thinking objects, Pydantic AI will convert thinking blocks
10
-
(`"<think>..."</think>"`) in provider-specific text parts to `ThinkingPart`s. We have also made
11
-
the decision not to send `ThinkingPart`s back to the provider in multi-turn conversations -
12
-
this helps save costs for users. In the future, we plan to add a setting to customize this behavior.
13
-
14
9
## OpenAI
15
10
16
-
When using the [`OpenAIChatModel`][pydantic_ai.models.openai.OpenAIChatModel], thinking objects are not created
17
-
by default. However, the text content may contain `"<think>"` tags. When this happens, Pydantic AI will
18
-
convert them to [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] objects.
11
+
When using the [`OpenAIChatModel`][pydantic_ai.models.openai.OpenAIChatModel], text output inside `<think>` tags are converted to [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] objects.
12
+
You can customize the tags using the [`thinking_tags`][pydantic_ai.profiles.ModelProfile.thinking_tags] field on the [model profile](models/openai.md#model-profile).
19
13
20
-
In contrast, the [`OpenAIResponsesModel`][pydantic_ai.models.openai.OpenAIResponsesModel] does
21
-
generate thinking parts. To enable this functionality, you need to set the `openai_reasoning_effort` and
22
-
`openai_reasoning_summary` fields in the
14
+
The [`OpenAIResponsesModel`][pydantic_ai.models.openai.OpenAIResponsesModel] can generate native thinking parts.
15
+
To enable this functionality, you need to set the `openai_reasoning_effort` and `openai_reasoning_summary` fields in the
Groq supports different formats to receive thinking parts:
59
67
60
-
-`"raw"`: The thinking part is included in the text content with the `"<think>"` tag.
68
+
-`"raw"`: The thinking part is included in the text content inside `<think>` tags, which are automatically converted to [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] objects.
61
69
-`"hidden"`: The thinking part is not included in the text content.
62
-
-`"parsed"`: The thinking part has its own [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] object.
70
+
-`"parsed"`: The thinking part has its own structured part in the response which is converted into a [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] object.
63
71
64
72
To enable thinking, use the `groq_reasoning_format` field in the
Thinking is supported by the `command-a-reasoning-08-2025` model. It does not need to be specifically enabled.
91
92
92
-
## Mistral / Cohere
93
+
## Hugging Face
93
94
94
-
Neither Mistral nor Cohere generate thinking parts.
95
+
Text output inside `<think>` tags is automatically converted to [`ThinkingPart`][pydantic_ai.messages.ThinkingPart] objects.
96
+
You can customize the tags using the [`thinking_tags`][pydantic_ai.profiles.ModelProfile.thinking_tags] field on the [model profile](models/openai.md#model-profile).
0 commit comments