@ai-sdk/openai 4.0.0-canary.73 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +193 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -0
- package/dist/internal/index.js +31 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +1 -1
- package/package.json +4 -4
- package/src/responses/convert-openai-responses-usage.ts +3 -0
- package/src/responses/openai-responses-api.ts +27 -6
- package/src/responses/openai-responses-language-model.ts +9 -3
package/docs/03-openai.mdx
CHANGED
|
@@ -298,7 +298,7 @@ The following OpenAI-specific metadata may be returned:
|
|
|
298
298
|
|
|
299
299
|
#### Reasoning Output
|
|
300
300
|
|
|
301
|
-
For reasoning models like `gpt-5`, you can enable reasoning summaries to see the model's thought process. Different models support different summarizers—for example, `o4-mini` supports detailed summaries. Set `reasoningSummary: "auto"` to automatically receive the richest level available.
|
|
301
|
+
For reasoning models like `gpt-5`, you can enable reasoning summaries to see the model's thought process. Different models support different summarizers—for example, `o4-mini` supports detailed summaries. Set `reasoningSummary: "auto"` to automatically receive the richest level available. When `reasoningEffort` is set to a value other than `'none'`, the OpenAI Responses provider defaults `reasoningSummary` to `'detailed'`; set `reasoningSummary: null` to omit reasoning summaries.
|
|
302
302
|
|
|
303
303
|
```ts highlight="8-9,16"
|
|
304
304
|
import {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "
|
|
39
|
-
"@ai-sdk/provider
|
|
38
|
+
"@ai-sdk/provider-utils": "5.0.0",
|
|
39
|
+
"@ai-sdk/provider": "4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "22.19.19",
|
|
43
43
|
"tsup": "^8.5.1",
|
|
44
44
|
"typescript": "5.8.3",
|
|
45
45
|
"zod": "3.25.76",
|
|
46
|
-
"@ai-sdk/test-server": "2.0.0
|
|
46
|
+
"@ai-sdk/test-server": "2.0.0",
|
|
47
47
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -5,9 +5,12 @@ export type OpenAIResponsesUsage = {
|
|
|
5
5
|
output_tokens: number;
|
|
6
6
|
input_tokens_details?: {
|
|
7
7
|
cached_tokens?: number | null;
|
|
8
|
+
orchestration_input_tokens?: number | null;
|
|
9
|
+
orchestration_input_cached_tokens?: number | null;
|
|
8
10
|
} | null;
|
|
9
11
|
output_tokens_details?: {
|
|
10
12
|
reasoning_tokens?: number | null;
|
|
13
|
+
orchestration_output_tokens?: number | null;
|
|
11
14
|
} | null;
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -531,11 +531,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
531
531
|
usage: z.object({
|
|
532
532
|
input_tokens: z.number(),
|
|
533
533
|
input_tokens_details: z
|
|
534
|
-
.object({
|
|
534
|
+
.object({
|
|
535
|
+
cached_tokens: z.number().nullish(),
|
|
536
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
537
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
538
|
+
})
|
|
535
539
|
.nullish(),
|
|
536
540
|
output_tokens: z.number(),
|
|
537
541
|
output_tokens_details: z
|
|
538
|
-
.object({
|
|
542
|
+
.object({
|
|
543
|
+
reasoning_tokens: z.number().nullish(),
|
|
544
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
545
|
+
})
|
|
539
546
|
.nullish(),
|
|
540
547
|
}),
|
|
541
548
|
service_tier: z.string().nullish(),
|
|
@@ -556,11 +563,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
556
563
|
.object({
|
|
557
564
|
input_tokens: z.number(),
|
|
558
565
|
input_tokens_details: z
|
|
559
|
-
.object({
|
|
566
|
+
.object({
|
|
567
|
+
cached_tokens: z.number().nullish(),
|
|
568
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
569
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
570
|
+
})
|
|
560
571
|
.nullish(),
|
|
561
572
|
output_tokens: z.number(),
|
|
562
573
|
output_tokens_details: z
|
|
563
|
-
.object({
|
|
574
|
+
.object({
|
|
575
|
+
reasoning_tokens: z.number().nullish(),
|
|
576
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
577
|
+
})
|
|
564
578
|
.nullish(),
|
|
565
579
|
})
|
|
566
580
|
.nullish(),
|
|
@@ -1416,11 +1430,18 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1416
1430
|
.object({
|
|
1417
1431
|
input_tokens: z.number(),
|
|
1418
1432
|
input_tokens_details: z
|
|
1419
|
-
.object({
|
|
1433
|
+
.object({
|
|
1434
|
+
cached_tokens: z.number().nullish(),
|
|
1435
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
1436
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
1437
|
+
})
|
|
1420
1438
|
.nullish(),
|
|
1421
1439
|
output_tokens: z.number(),
|
|
1422
1440
|
output_tokens_details: z
|
|
1423
|
-
.object({
|
|
1441
|
+
.object({
|
|
1442
|
+
reasoning_tokens: z.number().nullish(),
|
|
1443
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
1444
|
+
})
|
|
1424
1445
|
.nullish(),
|
|
1425
1446
|
})
|
|
1426
1447
|
.optional(),
|
|
@@ -198,6 +198,12 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
198
198
|
const resolvedReasoningEffort =
|
|
199
199
|
openaiOptions?.reasoningEffort ??
|
|
200
200
|
(isCustomReasoning(reasoning) ? reasoning : undefined);
|
|
201
|
+
const resolvedReasoningSummary =
|
|
202
|
+
openaiOptions?.reasoningSummary !== undefined
|
|
203
|
+
? openaiOptions.reasoningSummary
|
|
204
|
+
: resolvedReasoningEffort != null && resolvedReasoningEffort !== 'none'
|
|
205
|
+
? 'detailed'
|
|
206
|
+
: undefined;
|
|
201
207
|
|
|
202
208
|
const isReasoningModel =
|
|
203
209
|
openaiOptions?.forceReasoning ?? modelCapabilities.isReasoningModel;
|
|
@@ -377,13 +383,13 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
377
383
|
// model-specific settings:
|
|
378
384
|
...(isReasoningModel &&
|
|
379
385
|
(resolvedReasoningEffort != null ||
|
|
380
|
-
|
|
386
|
+
resolvedReasoningSummary != null) && {
|
|
381
387
|
reasoning: {
|
|
382
388
|
...(resolvedReasoningEffort != null && {
|
|
383
389
|
effort: resolvedReasoningEffort,
|
|
384
390
|
}),
|
|
385
|
-
...(
|
|
386
|
-
summary:
|
|
391
|
+
...(resolvedReasoningSummary != null && {
|
|
392
|
+
summary: resolvedReasoningSummary,
|
|
387
393
|
}),
|
|
388
394
|
},
|
|
389
395
|
}),
|