@ai-sdk/openai 3.0.72 → 3.0.74
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 +12 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +39 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +6 -0
- package/dist/internal/index.d.ts +6 -0
- package/dist/internal/index.js +38 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +38 -17
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/responses/convert-openai-responses-usage.ts +3 -0
- package/src/responses/convert-to-openai-responses-input.ts +23 -5
- package/src/responses/openai-responses-api.ts +27 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.74",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider
|
|
40
|
-
"@ai-sdk/provider": "
|
|
39
|
+
"@ai-sdk/provider": "3.0.10",
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.30"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -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
|
|
|
@@ -281,10 +281,29 @@ export async function convertToOpenAIResponsesInput({
|
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
// When chaining with a previous response id, items already part
|
|
285
|
+
// of that response chain must not be resent.
|
|
286
|
+
if (hasPreviousResponseId && store && id != null) {
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Provider-defined tool calls (local_shell, shell, apply_patch,
|
|
291
|
+
// and custom tools) are stored by the API and can be sent as an
|
|
292
|
+
// `item_reference` to reduce payload size. Plain client-executed
|
|
293
|
+
// function calls must NOT be: the matching `function_call_output`
|
|
294
|
+
// can only reference the call by `call_id` (`call_...`), which
|
|
295
|
+
// the API cannot reconcile with an item id (`fc_...`) or an
|
|
296
|
+
// `item_reference`. Sending either breaks call/output pairing and
|
|
297
|
+
// makes follow-up requests fail with "No tool call found for
|
|
298
|
+
// function call output with call_id", most visibly with parallel
|
|
299
|
+
// tool calls across multiple steps.
|
|
300
|
+
const isProviderDefinedToolCall =
|
|
301
|
+
(hasLocalShellTool && resolvedToolName === 'local_shell') ||
|
|
302
|
+
(hasShellTool && resolvedToolName === 'shell') ||
|
|
303
|
+
(hasApplyPatchTool && resolvedToolName === 'apply_patch') ||
|
|
304
|
+
(customProviderToolNames?.has(resolvedToolName) ?? false);
|
|
305
|
+
|
|
306
|
+
if (store && id != null && isProviderDefinedToolCall) {
|
|
288
307
|
input.push({ type: 'item_reference', id });
|
|
289
308
|
break;
|
|
290
309
|
}
|
|
@@ -366,7 +385,6 @@ export async function convertToOpenAIResponsesInput({
|
|
|
366
385
|
call_id: part.toolCallId,
|
|
367
386
|
name: resolvedToolName,
|
|
368
387
|
arguments: serializeToolCallArguments(part.input),
|
|
369
|
-
id,
|
|
370
388
|
...(namespace != null && { namespace }),
|
|
371
389
|
});
|
|
372
390
|
break;
|
|
@@ -500,11 +500,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
500
500
|
usage: z.object({
|
|
501
501
|
input_tokens: z.number(),
|
|
502
502
|
input_tokens_details: z
|
|
503
|
-
.object({
|
|
503
|
+
.object({
|
|
504
|
+
cached_tokens: z.number().nullish(),
|
|
505
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
506
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
507
|
+
})
|
|
504
508
|
.nullish(),
|
|
505
509
|
output_tokens: z.number(),
|
|
506
510
|
output_tokens_details: z
|
|
507
|
-
.object({
|
|
511
|
+
.object({
|
|
512
|
+
reasoning_tokens: z.number().nullish(),
|
|
513
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
514
|
+
})
|
|
508
515
|
.nullish(),
|
|
509
516
|
}),
|
|
510
517
|
service_tier: z.string().nullish(),
|
|
@@ -524,11 +531,18 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
524
531
|
.object({
|
|
525
532
|
input_tokens: z.number(),
|
|
526
533
|
input_tokens_details: z
|
|
527
|
-
.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
|
+
})
|
|
528
539
|
.nullish(),
|
|
529
540
|
output_tokens: z.number(),
|
|
530
541
|
output_tokens_details: z
|
|
531
|
-
.object({
|
|
542
|
+
.object({
|
|
543
|
+
reasoning_tokens: z.number().nullish(),
|
|
544
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
545
|
+
})
|
|
532
546
|
.nullish(),
|
|
533
547
|
})
|
|
534
548
|
.nullish(),
|
|
@@ -1377,11 +1391,18 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1377
1391
|
.object({
|
|
1378
1392
|
input_tokens: z.number(),
|
|
1379
1393
|
input_tokens_details: z
|
|
1380
|
-
.object({
|
|
1394
|
+
.object({
|
|
1395
|
+
cached_tokens: z.number().nullish(),
|
|
1396
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
1397
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
1398
|
+
})
|
|
1381
1399
|
.nullish(),
|
|
1382
1400
|
output_tokens: z.number(),
|
|
1383
1401
|
output_tokens_details: z
|
|
1384
|
-
.object({
|
|
1402
|
+
.object({
|
|
1403
|
+
reasoning_tokens: z.number().nullish(),
|
|
1404
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
1405
|
+
})
|
|
1385
1406
|
.nullish(),
|
|
1386
1407
|
})
|
|
1387
1408
|
.optional(),
|