Open History to see the last commit
1---
2title: Moving reasoning into chat()
3description: "Move provider reasoning and thinking fields out of modelOptions and into the reasoning option on chat(), adapter by adapter."
4keywords:
5 - tanstack ai
6 - migration
7 - reasoning
8 - thinking
9 - modelOptions
10---
11
12Your `modelOptions` has a reasoning field, like `reasoning: { effort }`, `thinking`, or `thinkingConfig`, and now it does not type-check. That field moved to one option on `chat()`: `reasoning`. It takes a level (`off` to `max`) or `{ level, summary, budgetTokens }`.
13
14## Move it
15
161. Delete the reasoning field from `modelOptions`.
172. Set `reasoning` on `chat()`.
18
19```typescript ignore
20// Before
21chat({
22 adapter: openaiText("gpt-6.1-sol"),
23 messages,
24 modelOptions: { reasoning: { effort: "high", summary: "auto" } },
25});
26```
27
28```typescript
29import { chat } from "@tanstack/ai";
30import { openaiText } from "@tanstack/ai-openai";
31
32const messages = [{ role: "user" as const, content: "Hello" }];
33
34// After
35chat({
36 adapter: openaiText("gpt-6.1-sol"),
37 messages,
38 reasoning: "high",
39});
40```
41
42The thinking text streams by default. Want it hidden? Pass `reasoning: { level: "high", summary: false }`.
43
44## Adapter by adapter
45
46| Adapter | Old `modelOptions` field | Now |
47| --- | --- | --- |
48| `openaiText`, `openaiChatCompletions`, `azureOpenaiText` | `reasoning: { effort, summary }` | `reasoning: "high"` |
49| `anthropicText` | `thinking`, `effort`, `output_config.effort` | `reasoning: "high"`, or `{ level, budgetTokens }` on budget models |
50| `geminiText` | `thinkingConfig` | `reasoning: "high"`, or `{ level, budgetTokens }` on Gemini 2.5 |
51| `geminiTextInteractions` | `generation_config.thinking_level`, `thinking_summaries` | `reasoning: "high"` |
52| `grokText`, `openRouterText` | `reasoning: { effort }` | `reasoning: "high"` |
53| `vercelGatewayText`, `lovableText` | `reasoning`, `include_reasoning` | `reasoning: "high"` |
54| `bedrockText` | `reasoning_effort` (chat), `reasoning` (Responses) | `reasoning: "high"` |
55| `groqText`, `llmGatewayText`, `cloudflareText` | `reasoning_effort` | `reasoning: "high"` |
56| `byteplusText` | `thinking`, `reasoning_effort` | `reasoning: "high"`, or `"off"` |
57| `ollamaText` | `think` | `reasoning: "high"`, or `"off"` |
58| `codexText` | `modelReasoningEffort` | `reasoning: "high"` |
59
60`"high"` is an example. Use any level that your model has. The types show which ones.
61
62## Budgets
63
64An Anthropic or Gemini 2.5 budget moves to `budgetTokens`:
65
66```typescript ignore
67// Before
68modelOptions: { thinking: { type: "enabled", budget_tokens: 8000 } }
69```
70
71```typescript
72import { chat } from "@tanstack/ai";
73import { anthropicText } from "@tanstack/ai-anthropic";
74
75const messages = [{ role: "user" as const, content: "Hello" }];
76
77// After
78chat({
79 adapter: anthropicText("claude-haiku-4-5"),
80 messages,
81 reasoning: { level: "high", budgetTokens: 8000 },
82});
83```
84
85The adapter raises `max_tokens` when it is below the budget.
86
87## Azure
88
89`azureOpenaiText` and `createAzureOpenaiText` read the levels of the OpenAI model name that you pass, not of your deployment name:
90
91```typescript
92import { chat } from "@tanstack/ai";
93import { createAzureOpenaiText } from "@tanstack/ai-openai";
94
95const messages = [{ role: "user" as const, content: "Hello" }];
96
97chat({
98 adapter: createAzureOpenaiText("gpt-6.1-sol", "azure-key", {
99 resourceName: "my-resource",
100 deploymentName: "prod-chat",
101 }),
102 messages,
103 reasoning: "high",
104});
105```
106
107Pass only a deployment name as the model, and the adapter has no levels for it. Then `reasoning` is a type error. Pass the OpenAI model name and set `deploymentName`.
108
109## Codex
110
111`modelReasoningEffort` stays on the `codexText` config. It is the default for a call without `reasoning`.
112
113## Removed types
114
115- `@tanstack/ai-openai`: `OpenAIReasoningOptions`, `OpenAIReasoningOptionsWithConcise`.
116- `@tanstack/ai-anthropic`: `AnthropicThinkingOptions`, `AnthropicAdaptiveThinkingOptions`, `AnthropicAdaptiveOnlyThinkingOptions`, `AnthropicAdaptiveOrDisabledThinkingOptions`, `AnthropicEffortOptions`, `AnthropicOutputConfigOptions`.
117- `@tanstack/ai-gemini`: `GeminiThinkingOptions`.
118- `@tanstack/ai-grok`: `GrokReasoning`, `GrokReasoningEffort`, `GrokBuildProviderOptions`.
119- `@tanstack/ai-openrouter`: `ReasoningOptions`. `@tanstack/ai-byteplus`: `BytePlusThinkingOption`, `BytePlusReasoningEffort`.
120
121Done. Your reasoning now works the same on every provider. See [Reasoning](../chat/reasoning) for levels, budgets, and middleware.