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: content/providers/01-ai-sdk-providers/02-openai.mdx
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -563,6 +563,9 @@ The following provider options are available:
563
563
-**reasoningEffort**_'low' | 'medium' | 'high'_
564
564
Reasoning effort for reasoning models. Defaults to `medium`. If you use `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
565
565
566
+
-**reasoningSummary**_'auto' | 'detailed'_
567
+
Controls whether the model returns its reasoning process. Set to `'auto'` for a condensed summary, `'detailed'` for more comprehensive reasoning. Defaults to `undefined` (no reasoning summaries). When enabled, reasoning summaries appear in the stream as events with type `'reasoning'` and in non-streaming responses within the `reasoning` field.
568
+
566
569
-**strictSchemas**_boolean_
567
570
Whether to use strict JSON schemas in tools and when generating JSON outputs. Defaults to `true`.
568
571
@@ -616,6 +619,53 @@ const result = await generateText({
616
619
const sources =result.sources;
617
620
```
618
621
622
+
#### Reasoning Summaries
623
+
624
+
For reasoning models like `o3-mini`, `o3`, and `o4-mini`, you can enable reasoning summaries to see the model's thought process:
625
+
626
+
```ts highlight="8-9,16"
627
+
import { openai } from'@ai-sdk/openai';
628
+
import { streamText } from'ai';
629
+
630
+
const result =streamText({
631
+
model: openai.responses('o3-mini'),
632
+
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
633
+
providerOptions: {
634
+
openai: {
635
+
reasoningSummary: 'detailed', // 'auto' for condensed or 'detailed' for comprehensive
636
+
},
637
+
},
638
+
});
639
+
640
+
forawait (const part ofresult.fullStream) {
641
+
if (part.type==='reasoning') {
642
+
console.log(`Reasoning: ${part.textDelta}`);
643
+
} elseif (part.type==='text-delta') {
644
+
process.stdout.write(part.textDelta);
645
+
}
646
+
}
647
+
```
648
+
649
+
For non-streaming calls with `generateText`, the reasoning summaries are available in the `reasoning` field of the response:
650
+
651
+
```ts highlight="8-9,13"
652
+
import { openai } from'@ai-sdk/openai';
653
+
import { generateText } from'ai';
654
+
655
+
const result =awaitgenerateText({
656
+
model: openai.responses('o3-mini'),
657
+
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
658
+
providerOptions: {
659
+
openai: {
660
+
reasoningSummary: 'detailed',
661
+
},
662
+
},
663
+
});
664
+
console.log('Reasoning:', result.reasoning);
665
+
```
666
+
667
+
Learn more about reasoning summaries in the [OpenAI documentation](https://platform.openai.com/docs/guides/reasoning?api-mode=responses#reasoning-summaries).
668
+
619
669
#### PDF support
620
670
621
671
The OpenAI Responses API supports reading PDF files.
`data:{"type":"response.reasoning_summary_text.delta","item_id":"rs_68082c0556348191af675cee0453109b","output_index":0,"summary_index":0,"delta":"**Exploring burrito origins**\\n\\nThe user is"}\n\n`,
1515
+
`data:{"type":"response.reasoning_summary_text.delta","item_id":"rs_68082c0556348191af675cee0453109b","output_index":0,"summary_index":0,"delta":" curious about the debate regarding Taqueria La Cumbre and El Farolito."}\n\n`,
1516
+
`data:{"type":"response.reasoning_summary_text.done","item_id":"rs_68082c0556348191af675cee0453109b","output_index":0,"summary_index":0,"text":"**Exploring burrito origins**\\n\\nThe user is curious about the debate regarding Taqueria La Cumbre and El Farolito."}\n\n`,
1517
+
`data:{"type":"response.reasoning_summary_text.delta","item_id":"rs_68082c0556348191af675cee0453109b","output_index":0,"summary_index":1,"delta":"**Investigating burrito origins**\\n\\nThere's a fascinating debate about who created the Mission burrito."}\n\n`,
1518
+
`data:{"type":"response.reasoning_summary_part.done","item_id":"rs_68082c0556348191af675cee0453109b","output_index":0,"summary_index":1,"part":{"type":"summary_text","text":"**Investigating burrito origins**\\n\\nThere's a fascinating debate about who created the Mission burrito."}}\n\n`,
`data:{"type":"response.output_text.delta","item_id":"msg_67c9a81dea8c8190b79651a2b3adf91e","output_index":1,"content_index":0,"delta":"Taqueria La Cumbre"}\n\n`,
1522
+
`data:{"type":"response.completed","response":{"id":"resp_67c9a81b6a048190a9ee441c5755a4e8","object":"response","created_at":1741269019,"status":"completed","error":null,"incomplete_details":null,"input":[],"instructions":null,"max_output_tokens":null,"model":"o3-mini-2025-01-31","output":[{"id":"rs_68082c0556348191af675cee0453109b","type":"reasoning","summary":[{"type":"summary_text","text":"**Exploring burrito origins**\\n\\nThe user is curious about the debate regarding Taqueria La Cumbre and El Farolito."},{"type":"summary_text","text":"**Investigating burrito origins**\\n\\nThere's a fascinating debate about who created the Mission burrito."}]},{"id":"msg_67c9a81dea8c8190b79651a2b3adf91e","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Taqueria La Cumbre","annotations":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":"low","summary":"auto"},"store":true,"temperature":null,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":null,"truncation":"disabled","usage":{"input_tokens":543,"input_tokens_details":{"cached_tokens":234},"output_tokens":478,"output_tokens_details":{"reasoning_tokens":350},"total_tokens":1021},"user":null,"metadata":{}}}\n\n`,
0 commit comments