@ai-sdk/openai 2.0.43 → 2.0.45
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 +16 -0
- package/dist/index.d.mts +38 -65
- package/dist/index.d.ts +38 -65
- package/dist/index.js +1345 -1028
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1299 -937
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +101 -182
- package/dist/internal/index.d.ts +101 -182
- package/dist/internal/index.js +1342 -1023
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1311 -948
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -11,10 +11,9 @@ import {
|
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as z3 } from "zod/v4";
|
|
15
14
|
|
|
16
15
|
// src/openai-error.ts
|
|
17
|
-
import
|
|
16
|
+
import * as z from "zod/v4";
|
|
18
17
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
19
18
|
var openaiErrorDataSchema = z.object({
|
|
20
19
|
error: z.object({
|
|
@@ -242,95 +241,244 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
242
241
|
}
|
|
243
242
|
}
|
|
244
243
|
|
|
244
|
+
// src/chat/openai-chat-api.ts
|
|
245
|
+
import {
|
|
246
|
+
lazyValidator,
|
|
247
|
+
zodSchema
|
|
248
|
+
} from "@ai-sdk/provider-utils";
|
|
249
|
+
import * as z2 from "zod/v4";
|
|
250
|
+
var openaiChatResponseSchema = lazyValidator(
|
|
251
|
+
() => zodSchema(
|
|
252
|
+
z2.object({
|
|
253
|
+
id: z2.string().nullish(),
|
|
254
|
+
created: z2.number().nullish(),
|
|
255
|
+
model: z2.string().nullish(),
|
|
256
|
+
choices: z2.array(
|
|
257
|
+
z2.object({
|
|
258
|
+
message: z2.object({
|
|
259
|
+
role: z2.literal("assistant").nullish(),
|
|
260
|
+
content: z2.string().nullish(),
|
|
261
|
+
tool_calls: z2.array(
|
|
262
|
+
z2.object({
|
|
263
|
+
id: z2.string().nullish(),
|
|
264
|
+
type: z2.literal("function"),
|
|
265
|
+
function: z2.object({
|
|
266
|
+
name: z2.string(),
|
|
267
|
+
arguments: z2.string()
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
).nullish(),
|
|
271
|
+
annotations: z2.array(
|
|
272
|
+
z2.object({
|
|
273
|
+
type: z2.literal("url_citation"),
|
|
274
|
+
start_index: z2.number(),
|
|
275
|
+
end_index: z2.number(),
|
|
276
|
+
url: z2.string(),
|
|
277
|
+
title: z2.string()
|
|
278
|
+
})
|
|
279
|
+
).nullish()
|
|
280
|
+
}),
|
|
281
|
+
index: z2.number(),
|
|
282
|
+
logprobs: z2.object({
|
|
283
|
+
content: z2.array(
|
|
284
|
+
z2.object({
|
|
285
|
+
token: z2.string(),
|
|
286
|
+
logprob: z2.number(),
|
|
287
|
+
top_logprobs: z2.array(
|
|
288
|
+
z2.object({
|
|
289
|
+
token: z2.string(),
|
|
290
|
+
logprob: z2.number()
|
|
291
|
+
})
|
|
292
|
+
)
|
|
293
|
+
})
|
|
294
|
+
).nullish()
|
|
295
|
+
}).nullish(),
|
|
296
|
+
finish_reason: z2.string().nullish()
|
|
297
|
+
})
|
|
298
|
+
),
|
|
299
|
+
usage: z2.object({
|
|
300
|
+
prompt_tokens: z2.number().nullish(),
|
|
301
|
+
completion_tokens: z2.number().nullish(),
|
|
302
|
+
total_tokens: z2.number().nullish(),
|
|
303
|
+
prompt_tokens_details: z2.object({
|
|
304
|
+
cached_tokens: z2.number().nullish()
|
|
305
|
+
}).nullish(),
|
|
306
|
+
completion_tokens_details: z2.object({
|
|
307
|
+
reasoning_tokens: z2.number().nullish(),
|
|
308
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
309
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
310
|
+
}).nullish()
|
|
311
|
+
}).nullish()
|
|
312
|
+
})
|
|
313
|
+
)
|
|
314
|
+
);
|
|
315
|
+
var openaiChatChunkSchema = lazyValidator(
|
|
316
|
+
() => zodSchema(
|
|
317
|
+
z2.union([
|
|
318
|
+
z2.object({
|
|
319
|
+
id: z2.string().nullish(),
|
|
320
|
+
created: z2.number().nullish(),
|
|
321
|
+
model: z2.string().nullish(),
|
|
322
|
+
choices: z2.array(
|
|
323
|
+
z2.object({
|
|
324
|
+
delta: z2.object({
|
|
325
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
326
|
+
content: z2.string().nullish(),
|
|
327
|
+
tool_calls: z2.array(
|
|
328
|
+
z2.object({
|
|
329
|
+
index: z2.number(),
|
|
330
|
+
id: z2.string().nullish(),
|
|
331
|
+
type: z2.literal("function").nullish(),
|
|
332
|
+
function: z2.object({
|
|
333
|
+
name: z2.string().nullish(),
|
|
334
|
+
arguments: z2.string().nullish()
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
).nullish(),
|
|
338
|
+
annotations: z2.array(
|
|
339
|
+
z2.object({
|
|
340
|
+
type: z2.literal("url_citation"),
|
|
341
|
+
start_index: z2.number(),
|
|
342
|
+
end_index: z2.number(),
|
|
343
|
+
url: z2.string(),
|
|
344
|
+
title: z2.string()
|
|
345
|
+
})
|
|
346
|
+
).nullish()
|
|
347
|
+
}).nullish(),
|
|
348
|
+
logprobs: z2.object({
|
|
349
|
+
content: z2.array(
|
|
350
|
+
z2.object({
|
|
351
|
+
token: z2.string(),
|
|
352
|
+
logprob: z2.number(),
|
|
353
|
+
top_logprobs: z2.array(
|
|
354
|
+
z2.object({
|
|
355
|
+
token: z2.string(),
|
|
356
|
+
logprob: z2.number()
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
})
|
|
360
|
+
).nullish()
|
|
361
|
+
}).nullish(),
|
|
362
|
+
finish_reason: z2.string().nullish(),
|
|
363
|
+
index: z2.number()
|
|
364
|
+
})
|
|
365
|
+
),
|
|
366
|
+
usage: z2.object({
|
|
367
|
+
prompt_tokens: z2.number().nullish(),
|
|
368
|
+
completion_tokens: z2.number().nullish(),
|
|
369
|
+
total_tokens: z2.number().nullish(),
|
|
370
|
+
prompt_tokens_details: z2.object({
|
|
371
|
+
cached_tokens: z2.number().nullish()
|
|
372
|
+
}).nullish(),
|
|
373
|
+
completion_tokens_details: z2.object({
|
|
374
|
+
reasoning_tokens: z2.number().nullish(),
|
|
375
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
376
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
377
|
+
}).nullish()
|
|
378
|
+
}).nullish()
|
|
379
|
+
}),
|
|
380
|
+
openaiErrorDataSchema
|
|
381
|
+
])
|
|
382
|
+
)
|
|
383
|
+
);
|
|
384
|
+
|
|
245
385
|
// src/chat/openai-chat-options.ts
|
|
246
|
-
import {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
386
|
+
import {
|
|
387
|
+
lazyValidator as lazyValidator2,
|
|
388
|
+
zodSchema as zodSchema2
|
|
389
|
+
} from "@ai-sdk/provider-utils";
|
|
390
|
+
import * as z3 from "zod/v4";
|
|
391
|
+
var openaiChatLanguageModelOptions = lazyValidator2(
|
|
392
|
+
() => zodSchema2(
|
|
393
|
+
z3.object({
|
|
394
|
+
/**
|
|
395
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
396
|
+
*
|
|
397
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
398
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
399
|
+
*/
|
|
400
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
401
|
+
/**
|
|
402
|
+
* Return the log probabilities of the tokens.
|
|
403
|
+
*
|
|
404
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
405
|
+
* were generated.
|
|
406
|
+
*
|
|
407
|
+
* Setting to a number will return the log probabilities of the top n
|
|
408
|
+
* tokens that were generated.
|
|
409
|
+
*/
|
|
410
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
411
|
+
/**
|
|
412
|
+
* Whether to enable parallel function calling during tool use. Default to true.
|
|
413
|
+
*/
|
|
414
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
415
|
+
/**
|
|
416
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
417
|
+
* monitor and detect abuse.
|
|
418
|
+
*/
|
|
419
|
+
user: z3.string().optional(),
|
|
420
|
+
/**
|
|
421
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
422
|
+
*/
|
|
423
|
+
reasoningEffort: z3.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
424
|
+
/**
|
|
425
|
+
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
426
|
+
*/
|
|
427
|
+
maxCompletionTokens: z3.number().optional(),
|
|
428
|
+
/**
|
|
429
|
+
* Whether to enable persistence in responses API.
|
|
430
|
+
*/
|
|
431
|
+
store: z3.boolean().optional(),
|
|
432
|
+
/**
|
|
433
|
+
* Metadata to associate with the request.
|
|
434
|
+
*/
|
|
435
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
436
|
+
/**
|
|
437
|
+
* Parameters for prediction mode.
|
|
438
|
+
*/
|
|
439
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
440
|
+
/**
|
|
441
|
+
* Whether to use structured outputs.
|
|
442
|
+
*
|
|
443
|
+
* @default true
|
|
444
|
+
*/
|
|
445
|
+
structuredOutputs: z3.boolean().optional(),
|
|
446
|
+
/**
|
|
447
|
+
* Service tier for the request.
|
|
448
|
+
* - 'auto': Default service tier
|
|
449
|
+
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
450
|
+
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
451
|
+
*
|
|
452
|
+
* @default 'auto'
|
|
453
|
+
*/
|
|
454
|
+
serviceTier: z3.enum(["auto", "flex", "priority"]).optional(),
|
|
455
|
+
/**
|
|
456
|
+
* Whether to use strict JSON schema validation.
|
|
457
|
+
*
|
|
458
|
+
* @default false
|
|
459
|
+
*/
|
|
460
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
461
|
+
/**
|
|
462
|
+
* Controls the verbosity of the model's responses.
|
|
463
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
464
|
+
*/
|
|
465
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
466
|
+
/**
|
|
467
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
468
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
469
|
+
*/
|
|
470
|
+
promptCacheKey: z3.string().optional(),
|
|
471
|
+
/**
|
|
472
|
+
* A stable identifier used to help detect users of your application
|
|
473
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
474
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
475
|
+
* username or email address, in order to avoid sending us any identifying
|
|
476
|
+
* information.
|
|
477
|
+
*/
|
|
478
|
+
safetyIdentifier: z3.string().optional()
|
|
479
|
+
})
|
|
480
|
+
)
|
|
481
|
+
);
|
|
334
482
|
|
|
335
483
|
// src/chat/openai-chat-prepare-tools.ts
|
|
336
484
|
import {
|
|
@@ -888,121 +1036,6 @@ var OpenAIChatLanguageModel = class {
|
|
|
888
1036
|
};
|
|
889
1037
|
}
|
|
890
1038
|
};
|
|
891
|
-
var openaiTokenUsageSchema = z3.object({
|
|
892
|
-
prompt_tokens: z3.number().nullish(),
|
|
893
|
-
completion_tokens: z3.number().nullish(),
|
|
894
|
-
total_tokens: z3.number().nullish(),
|
|
895
|
-
prompt_tokens_details: z3.object({
|
|
896
|
-
cached_tokens: z3.number().nullish()
|
|
897
|
-
}).nullish(),
|
|
898
|
-
completion_tokens_details: z3.object({
|
|
899
|
-
reasoning_tokens: z3.number().nullish(),
|
|
900
|
-
accepted_prediction_tokens: z3.number().nullish(),
|
|
901
|
-
rejected_prediction_tokens: z3.number().nullish()
|
|
902
|
-
}).nullish()
|
|
903
|
-
}).nullish();
|
|
904
|
-
var openaiChatResponseSchema = z3.object({
|
|
905
|
-
id: z3.string().nullish(),
|
|
906
|
-
created: z3.number().nullish(),
|
|
907
|
-
model: z3.string().nullish(),
|
|
908
|
-
choices: z3.array(
|
|
909
|
-
z3.object({
|
|
910
|
-
message: z3.object({
|
|
911
|
-
role: z3.literal("assistant").nullish(),
|
|
912
|
-
content: z3.string().nullish(),
|
|
913
|
-
tool_calls: z3.array(
|
|
914
|
-
z3.object({
|
|
915
|
-
id: z3.string().nullish(),
|
|
916
|
-
type: z3.literal("function"),
|
|
917
|
-
function: z3.object({
|
|
918
|
-
name: z3.string(),
|
|
919
|
-
arguments: z3.string()
|
|
920
|
-
})
|
|
921
|
-
})
|
|
922
|
-
).nullish(),
|
|
923
|
-
annotations: z3.array(
|
|
924
|
-
z3.object({
|
|
925
|
-
type: z3.literal("url_citation"),
|
|
926
|
-
start_index: z3.number(),
|
|
927
|
-
end_index: z3.number(),
|
|
928
|
-
url: z3.string(),
|
|
929
|
-
title: z3.string()
|
|
930
|
-
})
|
|
931
|
-
).nullish()
|
|
932
|
-
}),
|
|
933
|
-
index: z3.number(),
|
|
934
|
-
logprobs: z3.object({
|
|
935
|
-
content: z3.array(
|
|
936
|
-
z3.object({
|
|
937
|
-
token: z3.string(),
|
|
938
|
-
logprob: z3.number(),
|
|
939
|
-
top_logprobs: z3.array(
|
|
940
|
-
z3.object({
|
|
941
|
-
token: z3.string(),
|
|
942
|
-
logprob: z3.number()
|
|
943
|
-
})
|
|
944
|
-
)
|
|
945
|
-
})
|
|
946
|
-
).nullish()
|
|
947
|
-
}).nullish(),
|
|
948
|
-
finish_reason: z3.string().nullish()
|
|
949
|
-
})
|
|
950
|
-
),
|
|
951
|
-
usage: openaiTokenUsageSchema
|
|
952
|
-
});
|
|
953
|
-
var openaiChatChunkSchema = z3.union([
|
|
954
|
-
z3.object({
|
|
955
|
-
id: z3.string().nullish(),
|
|
956
|
-
created: z3.number().nullish(),
|
|
957
|
-
model: z3.string().nullish(),
|
|
958
|
-
choices: z3.array(
|
|
959
|
-
z3.object({
|
|
960
|
-
delta: z3.object({
|
|
961
|
-
role: z3.enum(["assistant"]).nullish(),
|
|
962
|
-
content: z3.string().nullish(),
|
|
963
|
-
tool_calls: z3.array(
|
|
964
|
-
z3.object({
|
|
965
|
-
index: z3.number(),
|
|
966
|
-
id: z3.string().nullish(),
|
|
967
|
-
type: z3.literal("function").nullish(),
|
|
968
|
-
function: z3.object({
|
|
969
|
-
name: z3.string().nullish(),
|
|
970
|
-
arguments: z3.string().nullish()
|
|
971
|
-
})
|
|
972
|
-
})
|
|
973
|
-
).nullish(),
|
|
974
|
-
annotations: z3.array(
|
|
975
|
-
z3.object({
|
|
976
|
-
type: z3.literal("url_citation"),
|
|
977
|
-
start_index: z3.number(),
|
|
978
|
-
end_index: z3.number(),
|
|
979
|
-
url: z3.string(),
|
|
980
|
-
title: z3.string()
|
|
981
|
-
})
|
|
982
|
-
).nullish()
|
|
983
|
-
}).nullish(),
|
|
984
|
-
logprobs: z3.object({
|
|
985
|
-
content: z3.array(
|
|
986
|
-
z3.object({
|
|
987
|
-
token: z3.string(),
|
|
988
|
-
logprob: z3.number(),
|
|
989
|
-
top_logprobs: z3.array(
|
|
990
|
-
z3.object({
|
|
991
|
-
token: z3.string(),
|
|
992
|
-
logprob: z3.number()
|
|
993
|
-
})
|
|
994
|
-
)
|
|
995
|
-
})
|
|
996
|
-
).nullish()
|
|
997
|
-
}).nullish(),
|
|
998
|
-
finish_reason: z3.string().nullish(),
|
|
999
|
-
index: z3.number()
|
|
1000
|
-
})
|
|
1001
|
-
),
|
|
1002
|
-
usage: openaiTokenUsageSchema
|
|
1003
|
-
}),
|
|
1004
|
-
openaiErrorDataSchema
|
|
1005
|
-
]);
|
|
1006
1039
|
function isReasoningModel(modelId) {
|
|
1007
1040
|
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
1008
1041
|
}
|
|
@@ -1060,7 +1093,6 @@ import {
|
|
|
1060
1093
|
parseProviderOptions as parseProviderOptions2,
|
|
1061
1094
|
postJsonToApi as postJsonToApi2
|
|
1062
1095
|
} from "@ai-sdk/provider-utils";
|
|
1063
|
-
import { z as z5 } from "zod/v4";
|
|
1064
1096
|
|
|
1065
1097
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1066
1098
|
import {
|
|
@@ -1170,48 +1202,117 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1170
1202
|
}
|
|
1171
1203
|
}
|
|
1172
1204
|
|
|
1205
|
+
// src/completion/openai-completion-api.ts
|
|
1206
|
+
import * as z4 from "zod/v4";
|
|
1207
|
+
import {
|
|
1208
|
+
lazyValidator as lazyValidator3,
|
|
1209
|
+
zodSchema as zodSchema3
|
|
1210
|
+
} from "@ai-sdk/provider-utils";
|
|
1211
|
+
var openaiCompletionResponseSchema = lazyValidator3(
|
|
1212
|
+
() => zodSchema3(
|
|
1213
|
+
z4.object({
|
|
1214
|
+
id: z4.string().nullish(),
|
|
1215
|
+
created: z4.number().nullish(),
|
|
1216
|
+
model: z4.string().nullish(),
|
|
1217
|
+
choices: z4.array(
|
|
1218
|
+
z4.object({
|
|
1219
|
+
text: z4.string(),
|
|
1220
|
+
finish_reason: z4.string(),
|
|
1221
|
+
logprobs: z4.object({
|
|
1222
|
+
tokens: z4.array(z4.string()),
|
|
1223
|
+
token_logprobs: z4.array(z4.number()),
|
|
1224
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1225
|
+
}).nullish()
|
|
1226
|
+
})
|
|
1227
|
+
),
|
|
1228
|
+
usage: z4.object({
|
|
1229
|
+
prompt_tokens: z4.number(),
|
|
1230
|
+
completion_tokens: z4.number(),
|
|
1231
|
+
total_tokens: z4.number()
|
|
1232
|
+
}).nullish()
|
|
1233
|
+
})
|
|
1234
|
+
)
|
|
1235
|
+
);
|
|
1236
|
+
var openaiCompletionChunkSchema = lazyValidator3(
|
|
1237
|
+
() => zodSchema3(
|
|
1238
|
+
z4.union([
|
|
1239
|
+
z4.object({
|
|
1240
|
+
id: z4.string().nullish(),
|
|
1241
|
+
created: z4.number().nullish(),
|
|
1242
|
+
model: z4.string().nullish(),
|
|
1243
|
+
choices: z4.array(
|
|
1244
|
+
z4.object({
|
|
1245
|
+
text: z4.string(),
|
|
1246
|
+
finish_reason: z4.string().nullish(),
|
|
1247
|
+
index: z4.number(),
|
|
1248
|
+
logprobs: z4.object({
|
|
1249
|
+
tokens: z4.array(z4.string()),
|
|
1250
|
+
token_logprobs: z4.array(z4.number()),
|
|
1251
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1252
|
+
}).nullish()
|
|
1253
|
+
})
|
|
1254
|
+
),
|
|
1255
|
+
usage: z4.object({
|
|
1256
|
+
prompt_tokens: z4.number(),
|
|
1257
|
+
completion_tokens: z4.number(),
|
|
1258
|
+
total_tokens: z4.number()
|
|
1259
|
+
}).nullish()
|
|
1260
|
+
}),
|
|
1261
|
+
openaiErrorDataSchema
|
|
1262
|
+
])
|
|
1263
|
+
)
|
|
1264
|
+
);
|
|
1265
|
+
|
|
1173
1266
|
// src/completion/openai-completion-options.ts
|
|
1174
|
-
import {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1267
|
+
import {
|
|
1268
|
+
lazyValidator as lazyValidator4,
|
|
1269
|
+
zodSchema as zodSchema4
|
|
1270
|
+
} from "@ai-sdk/provider-utils";
|
|
1271
|
+
import * as z5 from "zod/v4";
|
|
1272
|
+
var openaiCompletionProviderOptions = lazyValidator4(
|
|
1273
|
+
() => zodSchema4(
|
|
1274
|
+
z5.object({
|
|
1275
|
+
/**
|
|
1276
|
+
Echo back the prompt in addition to the completion.
|
|
1277
|
+
*/
|
|
1278
|
+
echo: z5.boolean().optional(),
|
|
1279
|
+
/**
|
|
1280
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
1281
|
+
|
|
1282
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1283
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1284
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1285
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
1286
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
1287
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
1288
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
1289
|
+
|
|
1290
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1291
|
+
token from being generated.
|
|
1292
|
+
*/
|
|
1293
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1294
|
+
/**
|
|
1295
|
+
The suffix that comes after a completion of inserted text.
|
|
1296
|
+
*/
|
|
1297
|
+
suffix: z5.string().optional(),
|
|
1298
|
+
/**
|
|
1299
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1300
|
+
monitor and detect abuse. Learn more.
|
|
1301
|
+
*/
|
|
1302
|
+
user: z5.string().optional(),
|
|
1303
|
+
/**
|
|
1304
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
1305
|
+
the response size and can slow down response times. However, it can
|
|
1306
|
+
be useful to better understand how the model is behaving.
|
|
1307
|
+
Setting to true will return the log probabilities of the tokens that
|
|
1308
|
+
were generated.
|
|
1309
|
+
Setting to a number will return the log probabilities of the top n
|
|
1310
|
+
tokens that were generated.
|
|
1311
|
+
*/
|
|
1312
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1313
|
+
})
|
|
1314
|
+
)
|
|
1315
|
+
);
|
|
1215
1316
|
|
|
1216
1317
|
// src/completion/openai-completion-language-model.ts
|
|
1217
1318
|
var OpenAICompletionLanguageModel = class {
|
|
@@ -1442,49 +1543,6 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1442
1543
|
};
|
|
1443
1544
|
}
|
|
1444
1545
|
};
|
|
1445
|
-
var usageSchema = z5.object({
|
|
1446
|
-
prompt_tokens: z5.number(),
|
|
1447
|
-
completion_tokens: z5.number(),
|
|
1448
|
-
total_tokens: z5.number()
|
|
1449
|
-
});
|
|
1450
|
-
var openaiCompletionResponseSchema = z5.object({
|
|
1451
|
-
id: z5.string().nullish(),
|
|
1452
|
-
created: z5.number().nullish(),
|
|
1453
|
-
model: z5.string().nullish(),
|
|
1454
|
-
choices: z5.array(
|
|
1455
|
-
z5.object({
|
|
1456
|
-
text: z5.string(),
|
|
1457
|
-
finish_reason: z5.string(),
|
|
1458
|
-
logprobs: z5.object({
|
|
1459
|
-
tokens: z5.array(z5.string()),
|
|
1460
|
-
token_logprobs: z5.array(z5.number()),
|
|
1461
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1462
|
-
}).nullish()
|
|
1463
|
-
})
|
|
1464
|
-
),
|
|
1465
|
-
usage: usageSchema.nullish()
|
|
1466
|
-
});
|
|
1467
|
-
var openaiCompletionChunkSchema = z5.union([
|
|
1468
|
-
z5.object({
|
|
1469
|
-
id: z5.string().nullish(),
|
|
1470
|
-
created: z5.number().nullish(),
|
|
1471
|
-
model: z5.string().nullish(),
|
|
1472
|
-
choices: z5.array(
|
|
1473
|
-
z5.object({
|
|
1474
|
-
text: z5.string(),
|
|
1475
|
-
finish_reason: z5.string().nullish(),
|
|
1476
|
-
index: z5.number(),
|
|
1477
|
-
logprobs: z5.object({
|
|
1478
|
-
tokens: z5.array(z5.string()),
|
|
1479
|
-
token_logprobs: z5.array(z5.number()),
|
|
1480
|
-
top_logprobs: z5.array(z5.record(z5.string(), z5.number())).nullish()
|
|
1481
|
-
}).nullish()
|
|
1482
|
-
})
|
|
1483
|
-
),
|
|
1484
|
-
usage: usageSchema.nullish()
|
|
1485
|
-
}),
|
|
1486
|
-
openaiErrorDataSchema
|
|
1487
|
-
]);
|
|
1488
1546
|
|
|
1489
1547
|
// src/embedding/openai-embedding-model.ts
|
|
1490
1548
|
import {
|
|
@@ -1496,22 +1554,41 @@ import {
|
|
|
1496
1554
|
parseProviderOptions as parseProviderOptions3,
|
|
1497
1555
|
postJsonToApi as postJsonToApi3
|
|
1498
1556
|
} from "@ai-sdk/provider-utils";
|
|
1499
|
-
import { z as z7 } from "zod/v4";
|
|
1500
1557
|
|
|
1501
1558
|
// src/embedding/openai-embedding-options.ts
|
|
1502
|
-
import {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1559
|
+
import {
|
|
1560
|
+
lazyValidator as lazyValidator5,
|
|
1561
|
+
zodSchema as zodSchema5
|
|
1562
|
+
} from "@ai-sdk/provider-utils";
|
|
1563
|
+
import * as z6 from "zod/v4";
|
|
1564
|
+
var openaiEmbeddingProviderOptions = lazyValidator5(
|
|
1565
|
+
() => zodSchema5(
|
|
1566
|
+
z6.object({
|
|
1567
|
+
/**
|
|
1568
|
+
The number of dimensions the resulting output embeddings should have.
|
|
1569
|
+
Only supported in text-embedding-3 and later models.
|
|
1570
|
+
*/
|
|
1571
|
+
dimensions: z6.number().optional(),
|
|
1572
|
+
/**
|
|
1573
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
1574
|
+
monitor and detect abuse. Learn more.
|
|
1575
|
+
*/
|
|
1576
|
+
user: z6.string().optional()
|
|
1577
|
+
})
|
|
1578
|
+
)
|
|
1579
|
+
);
|
|
1580
|
+
|
|
1581
|
+
// src/embedding/openai-embedding-api.ts
|
|
1582
|
+
import { lazyValidator as lazyValidator6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1583
|
+
import * as z7 from "zod/v4";
|
|
1584
|
+
var openaiTextEmbeddingResponseSchema = lazyValidator6(
|
|
1585
|
+
() => zodSchema6(
|
|
1586
|
+
z7.object({
|
|
1587
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1588
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1589
|
+
})
|
|
1590
|
+
)
|
|
1591
|
+
);
|
|
1515
1592
|
|
|
1516
1593
|
// src/embedding/openai-embedding-model.ts
|
|
1517
1594
|
var OpenAIEmbeddingModel = class {
|
|
@@ -1576,10 +1653,6 @@ var OpenAIEmbeddingModel = class {
|
|
|
1576
1653
|
};
|
|
1577
1654
|
}
|
|
1578
1655
|
};
|
|
1579
|
-
var openaiTextEmbeddingResponseSchema = z7.object({
|
|
1580
|
-
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1581
|
-
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1582
|
-
});
|
|
1583
1656
|
|
|
1584
1657
|
// src/image/openai-image-model.ts
|
|
1585
1658
|
import {
|
|
@@ -1587,7 +1660,22 @@ import {
|
|
|
1587
1660
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1588
1661
|
postJsonToApi as postJsonToApi4
|
|
1589
1662
|
} from "@ai-sdk/provider-utils";
|
|
1590
|
-
|
|
1663
|
+
|
|
1664
|
+
// src/image/openai-image-api.ts
|
|
1665
|
+
import { lazyValidator as lazyValidator7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1666
|
+
import * as z8 from "zod/v4";
|
|
1667
|
+
var openaiImageResponseSchema = lazyValidator7(
|
|
1668
|
+
() => zodSchema7(
|
|
1669
|
+
z8.object({
|
|
1670
|
+
data: z8.array(
|
|
1671
|
+
z8.object({
|
|
1672
|
+
b64_json: z8.string(),
|
|
1673
|
+
revised_prompt: z8.string().optional()
|
|
1674
|
+
})
|
|
1675
|
+
)
|
|
1676
|
+
})
|
|
1677
|
+
)
|
|
1678
|
+
);
|
|
1591
1679
|
|
|
1592
1680
|
// src/image/openai-image-options.ts
|
|
1593
1681
|
var modelMaxImagesPerCall = {
|
|
@@ -1679,11 +1767,6 @@ var OpenAIImageModel = class {
|
|
|
1679
1767
|
};
|
|
1680
1768
|
}
|
|
1681
1769
|
};
|
|
1682
|
-
var openaiImageResponseSchema = z8.object({
|
|
1683
|
-
data: z8.array(
|
|
1684
|
-
z8.object({ b64_json: z8.string(), revised_prompt: z8.string().optional() })
|
|
1685
|
-
)
|
|
1686
|
-
});
|
|
1687
1770
|
|
|
1688
1771
|
// src/transcription/openai-transcription-model.ts
|
|
1689
1772
|
import {
|
|
@@ -1694,34 +1777,75 @@ import {
|
|
|
1694
1777
|
parseProviderOptions as parseProviderOptions4,
|
|
1695
1778
|
postFormDataToApi
|
|
1696
1779
|
} from "@ai-sdk/provider-utils";
|
|
1697
|
-
|
|
1780
|
+
|
|
1781
|
+
// src/transcription/openai-transcription-api.ts
|
|
1782
|
+
import { lazyValidator as lazyValidator8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
|
|
1783
|
+
import * as z9 from "zod/v4";
|
|
1784
|
+
var openaiTranscriptionResponseSchema = lazyValidator8(
|
|
1785
|
+
() => zodSchema8(
|
|
1786
|
+
z9.object({
|
|
1787
|
+
text: z9.string(),
|
|
1788
|
+
language: z9.string().nullish(),
|
|
1789
|
+
duration: z9.number().nullish(),
|
|
1790
|
+
words: z9.array(
|
|
1791
|
+
z9.object({
|
|
1792
|
+
word: z9.string(),
|
|
1793
|
+
start: z9.number(),
|
|
1794
|
+
end: z9.number()
|
|
1795
|
+
})
|
|
1796
|
+
).nullish(),
|
|
1797
|
+
segments: z9.array(
|
|
1798
|
+
z9.object({
|
|
1799
|
+
id: z9.number(),
|
|
1800
|
+
seek: z9.number(),
|
|
1801
|
+
start: z9.number(),
|
|
1802
|
+
end: z9.number(),
|
|
1803
|
+
text: z9.string(),
|
|
1804
|
+
tokens: z9.array(z9.number()),
|
|
1805
|
+
temperature: z9.number(),
|
|
1806
|
+
avg_logprob: z9.number(),
|
|
1807
|
+
compression_ratio: z9.number(),
|
|
1808
|
+
no_speech_prob: z9.number()
|
|
1809
|
+
})
|
|
1810
|
+
).nullish()
|
|
1811
|
+
})
|
|
1812
|
+
)
|
|
1813
|
+
);
|
|
1698
1814
|
|
|
1699
1815
|
// src/transcription/openai-transcription-options.ts
|
|
1700
|
-
import {
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1816
|
+
import {
|
|
1817
|
+
lazyValidator as lazyValidator9,
|
|
1818
|
+
zodSchema as zodSchema9
|
|
1819
|
+
} from "@ai-sdk/provider-utils";
|
|
1820
|
+
import * as z10 from "zod/v4";
|
|
1821
|
+
var openAITranscriptionProviderOptions = lazyValidator9(
|
|
1822
|
+
() => zodSchema9(
|
|
1823
|
+
z10.object({
|
|
1824
|
+
/**
|
|
1825
|
+
* Additional information to include in the transcription response.
|
|
1826
|
+
*/
|
|
1827
|
+
include: z10.array(z10.string()).optional(),
|
|
1828
|
+
/**
|
|
1829
|
+
* The language of the input audio in ISO-639-1 format.
|
|
1830
|
+
*/
|
|
1831
|
+
language: z10.string().optional(),
|
|
1832
|
+
/**
|
|
1833
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
1834
|
+
*/
|
|
1835
|
+
prompt: z10.string().optional(),
|
|
1836
|
+
/**
|
|
1837
|
+
* The sampling temperature, between 0 and 1.
|
|
1838
|
+
* @default 0
|
|
1839
|
+
*/
|
|
1840
|
+
temperature: z10.number().min(0).max(1).default(0).optional(),
|
|
1841
|
+
/**
|
|
1842
|
+
* The timestamp granularities to populate for this transcription.
|
|
1843
|
+
* @default ['segment']
|
|
1844
|
+
*/
|
|
1845
|
+
timestampGranularities: z10.array(z10.enum(["word", "segment"])).default(["segment"]).optional()
|
|
1846
|
+
})
|
|
1847
|
+
)
|
|
1848
|
+
);
|
|
1725
1849
|
|
|
1726
1850
|
// src/transcription/openai-transcription-model.ts
|
|
1727
1851
|
var languageMap = {
|
|
@@ -1889,32 +2013,6 @@ var OpenAITranscriptionModel = class {
|
|
|
1889
2013
|
};
|
|
1890
2014
|
}
|
|
1891
2015
|
};
|
|
1892
|
-
var openaiTranscriptionResponseSchema = z10.object({
|
|
1893
|
-
text: z10.string(),
|
|
1894
|
-
language: z10.string().nullish(),
|
|
1895
|
-
duration: z10.number().nullish(),
|
|
1896
|
-
words: z10.array(
|
|
1897
|
-
z10.object({
|
|
1898
|
-
word: z10.string(),
|
|
1899
|
-
start: z10.number(),
|
|
1900
|
-
end: z10.number()
|
|
1901
|
-
})
|
|
1902
|
-
).nullish(),
|
|
1903
|
-
segments: z10.array(
|
|
1904
|
-
z10.object({
|
|
1905
|
-
id: z10.number(),
|
|
1906
|
-
seek: z10.number(),
|
|
1907
|
-
start: z10.number(),
|
|
1908
|
-
end: z10.number(),
|
|
1909
|
-
text: z10.string(),
|
|
1910
|
-
tokens: z10.array(z10.number()),
|
|
1911
|
-
temperature: z10.number(),
|
|
1912
|
-
avg_logprob: z10.number(),
|
|
1913
|
-
compression_ratio: z10.number(),
|
|
1914
|
-
no_speech_prob: z10.number()
|
|
1915
|
-
})
|
|
1916
|
-
).nullish()
|
|
1917
|
-
});
|
|
1918
2016
|
|
|
1919
2017
|
// src/speech/openai-speech-model.ts
|
|
1920
2018
|
import {
|
|
@@ -1923,11 +2021,23 @@ import {
|
|
|
1923
2021
|
parseProviderOptions as parseProviderOptions5,
|
|
1924
2022
|
postJsonToApi as postJsonToApi5
|
|
1925
2023
|
} from "@ai-sdk/provider-utils";
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2024
|
+
|
|
2025
|
+
// src/speech/openai-speech-options.ts
|
|
2026
|
+
import {
|
|
2027
|
+
lazyValidator as lazyValidator10,
|
|
2028
|
+
zodSchema as zodSchema10
|
|
2029
|
+
} from "@ai-sdk/provider-utils";
|
|
2030
|
+
import * as z11 from "zod/v4";
|
|
2031
|
+
var openaiSpeechProviderOptionsSchema = lazyValidator10(
|
|
2032
|
+
() => zodSchema10(
|
|
2033
|
+
z11.object({
|
|
2034
|
+
instructions: z11.string().nullish(),
|
|
2035
|
+
speed: z11.number().min(0.25).max(4).default(1).nullish()
|
|
2036
|
+
})
|
|
2037
|
+
)
|
|
2038
|
+
);
|
|
2039
|
+
|
|
2040
|
+
// src/speech/openai-speech-model.ts
|
|
1931
2041
|
var OpenAISpeechModel = class {
|
|
1932
2042
|
constructor(modelId, config) {
|
|
1933
2043
|
this.modelId = modelId;
|
|
@@ -1950,7 +2060,7 @@ var OpenAISpeechModel = class {
|
|
|
1950
2060
|
const openAIOptions = await parseProviderOptions5({
|
|
1951
2061
|
provider: "openai",
|
|
1952
2062
|
providerOptions,
|
|
1953
|
-
schema:
|
|
2063
|
+
schema: openaiSpeechProviderOptionsSchema
|
|
1954
2064
|
});
|
|
1955
2065
|
const requestBody = {
|
|
1956
2066
|
model: this.modelId,
|
|
@@ -2040,31 +2150,42 @@ import {
|
|
|
2040
2150
|
parseProviderOptions as parseProviderOptions7,
|
|
2041
2151
|
postJsonToApi as postJsonToApi6
|
|
2042
2152
|
} from "@ai-sdk/provider-utils";
|
|
2043
|
-
import { z as z19 } from "zod/v4";
|
|
2044
2153
|
|
|
2045
2154
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2046
2155
|
import {
|
|
2047
2156
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2048
2157
|
} from "@ai-sdk/provider";
|
|
2049
|
-
import {
|
|
2050
|
-
|
|
2158
|
+
import {
|
|
2159
|
+
convertToBase64 as convertToBase642,
|
|
2160
|
+
parseProviderOptions as parseProviderOptions6,
|
|
2161
|
+
validateTypes
|
|
2162
|
+
} from "@ai-sdk/provider-utils";
|
|
2163
|
+
import * as z13 from "zod/v4";
|
|
2051
2164
|
|
|
2052
2165
|
// src/tool/local-shell.ts
|
|
2053
|
-
import {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2166
|
+
import {
|
|
2167
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
2168
|
+
lazySchema,
|
|
2169
|
+
zodSchema as zodSchema11
|
|
2170
|
+
} from "@ai-sdk/provider-utils";
|
|
2171
|
+
import * as z12 from "zod/v4";
|
|
2172
|
+
var localShellInputSchema = lazySchema(
|
|
2173
|
+
() => zodSchema11(
|
|
2174
|
+
z12.object({
|
|
2175
|
+
action: z12.object({
|
|
2176
|
+
type: z12.literal("exec"),
|
|
2177
|
+
command: z12.array(z12.string()),
|
|
2178
|
+
timeoutMs: z12.number().optional(),
|
|
2179
|
+
user: z12.string().optional(),
|
|
2180
|
+
workingDirectory: z12.string().optional(),
|
|
2181
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
2182
|
+
})
|
|
2183
|
+
})
|
|
2184
|
+
)
|
|
2185
|
+
);
|
|
2186
|
+
var localShellOutputSchema = lazySchema(
|
|
2187
|
+
() => zodSchema11(z12.object({ output: z12.string() }))
|
|
2188
|
+
);
|
|
2068
2189
|
var localShell = createProviderDefinedToolFactoryWithOutputSchema({
|
|
2069
2190
|
id: "openai.local_shell",
|
|
2070
2191
|
name: "local_shell",
|
|
@@ -2178,7 +2299,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2178
2299
|
break;
|
|
2179
2300
|
}
|
|
2180
2301
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2181
|
-
const parsedInput =
|
|
2302
|
+
const parsedInput = await validateTypes({
|
|
2303
|
+
value: part.input,
|
|
2304
|
+
schema: localShellInputSchema
|
|
2305
|
+
});
|
|
2182
2306
|
input.push({
|
|
2183
2307
|
type: "local_shell_call",
|
|
2184
2308
|
call_id: part.toolCallId,
|
|
@@ -2274,10 +2398,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2274
2398
|
for (const part of content) {
|
|
2275
2399
|
const output = part.output;
|
|
2276
2400
|
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2401
|
+
const parsedOutput = await validateTypes({
|
|
2402
|
+
value: output.value,
|
|
2403
|
+
schema: localShellOutputSchema
|
|
2404
|
+
});
|
|
2277
2405
|
input.push({
|
|
2278
2406
|
type: "local_shell_call_output",
|
|
2279
2407
|
call_id: part.toolCallId,
|
|
2280
|
-
output:
|
|
2408
|
+
output: parsedOutput.output
|
|
2281
2409
|
});
|
|
2282
2410
|
break;
|
|
2283
2411
|
}
|
|
@@ -2332,34 +2460,585 @@ function mapOpenAIResponseFinishReason({
|
|
|
2332
2460
|
}
|
|
2333
2461
|
}
|
|
2334
2462
|
|
|
2463
|
+
// src/responses/openai-responses-api.ts
|
|
2464
|
+
import {
|
|
2465
|
+
lazyValidator as lazyValidator11,
|
|
2466
|
+
zodSchema as zodSchema12
|
|
2467
|
+
} from "@ai-sdk/provider-utils";
|
|
2468
|
+
import * as z14 from "zod/v4";
|
|
2469
|
+
var openaiResponsesChunkSchema = lazyValidator11(
|
|
2470
|
+
() => zodSchema12(
|
|
2471
|
+
z14.union([
|
|
2472
|
+
z14.object({
|
|
2473
|
+
type: z14.literal("response.output_text.delta"),
|
|
2474
|
+
item_id: z14.string(),
|
|
2475
|
+
delta: z14.string(),
|
|
2476
|
+
logprobs: z14.array(
|
|
2477
|
+
z14.object({
|
|
2478
|
+
token: z14.string(),
|
|
2479
|
+
logprob: z14.number(),
|
|
2480
|
+
top_logprobs: z14.array(
|
|
2481
|
+
z14.object({
|
|
2482
|
+
token: z14.string(),
|
|
2483
|
+
logprob: z14.number()
|
|
2484
|
+
})
|
|
2485
|
+
)
|
|
2486
|
+
})
|
|
2487
|
+
).nullish()
|
|
2488
|
+
}),
|
|
2489
|
+
z14.object({
|
|
2490
|
+
type: z14.enum(["response.completed", "response.incomplete"]),
|
|
2491
|
+
response: z14.object({
|
|
2492
|
+
incomplete_details: z14.object({ reason: z14.string() }).nullish(),
|
|
2493
|
+
usage: z14.object({
|
|
2494
|
+
input_tokens: z14.number(),
|
|
2495
|
+
input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
|
|
2496
|
+
output_tokens: z14.number(),
|
|
2497
|
+
output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
|
|
2498
|
+
}),
|
|
2499
|
+
service_tier: z14.string().nullish()
|
|
2500
|
+
})
|
|
2501
|
+
}),
|
|
2502
|
+
z14.object({
|
|
2503
|
+
type: z14.literal("response.created"),
|
|
2504
|
+
response: z14.object({
|
|
2505
|
+
id: z14.string(),
|
|
2506
|
+
created_at: z14.number(),
|
|
2507
|
+
model: z14.string(),
|
|
2508
|
+
service_tier: z14.string().nullish()
|
|
2509
|
+
})
|
|
2510
|
+
}),
|
|
2511
|
+
z14.object({
|
|
2512
|
+
type: z14.literal("response.output_item.added"),
|
|
2513
|
+
output_index: z14.number(),
|
|
2514
|
+
item: z14.discriminatedUnion("type", [
|
|
2515
|
+
z14.object({
|
|
2516
|
+
type: z14.literal("message"),
|
|
2517
|
+
id: z14.string()
|
|
2518
|
+
}),
|
|
2519
|
+
z14.object({
|
|
2520
|
+
type: z14.literal("reasoning"),
|
|
2521
|
+
id: z14.string(),
|
|
2522
|
+
encrypted_content: z14.string().nullish()
|
|
2523
|
+
}),
|
|
2524
|
+
z14.object({
|
|
2525
|
+
type: z14.literal("function_call"),
|
|
2526
|
+
id: z14.string(),
|
|
2527
|
+
call_id: z14.string(),
|
|
2528
|
+
name: z14.string(),
|
|
2529
|
+
arguments: z14.string()
|
|
2530
|
+
}),
|
|
2531
|
+
z14.object({
|
|
2532
|
+
type: z14.literal("web_search_call"),
|
|
2533
|
+
id: z14.string(),
|
|
2534
|
+
status: z14.string(),
|
|
2535
|
+
action: z14.object({
|
|
2536
|
+
type: z14.literal("search"),
|
|
2537
|
+
query: z14.string().optional()
|
|
2538
|
+
}).nullish()
|
|
2539
|
+
}),
|
|
2540
|
+
z14.object({
|
|
2541
|
+
type: z14.literal("computer_call"),
|
|
2542
|
+
id: z14.string(),
|
|
2543
|
+
status: z14.string()
|
|
2544
|
+
}),
|
|
2545
|
+
z14.object({
|
|
2546
|
+
type: z14.literal("file_search_call"),
|
|
2547
|
+
id: z14.string()
|
|
2548
|
+
}),
|
|
2549
|
+
z14.object({
|
|
2550
|
+
type: z14.literal("image_generation_call"),
|
|
2551
|
+
id: z14.string()
|
|
2552
|
+
}),
|
|
2553
|
+
z14.object({
|
|
2554
|
+
type: z14.literal("code_interpreter_call"),
|
|
2555
|
+
id: z14.string(),
|
|
2556
|
+
container_id: z14.string(),
|
|
2557
|
+
code: z14.string().nullable(),
|
|
2558
|
+
outputs: z14.array(
|
|
2559
|
+
z14.discriminatedUnion("type", [
|
|
2560
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2561
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2562
|
+
])
|
|
2563
|
+
).nullable(),
|
|
2564
|
+
status: z14.string()
|
|
2565
|
+
})
|
|
2566
|
+
])
|
|
2567
|
+
}),
|
|
2568
|
+
z14.object({
|
|
2569
|
+
type: z14.literal("response.output_item.done"),
|
|
2570
|
+
output_index: z14.number(),
|
|
2571
|
+
item: z14.discriminatedUnion("type", [
|
|
2572
|
+
z14.object({
|
|
2573
|
+
type: z14.literal("message"),
|
|
2574
|
+
id: z14.string()
|
|
2575
|
+
}),
|
|
2576
|
+
z14.object({
|
|
2577
|
+
type: z14.literal("reasoning"),
|
|
2578
|
+
id: z14.string(),
|
|
2579
|
+
encrypted_content: z14.string().nullish()
|
|
2580
|
+
}),
|
|
2581
|
+
z14.object({
|
|
2582
|
+
type: z14.literal("function_call"),
|
|
2583
|
+
id: z14.string(),
|
|
2584
|
+
call_id: z14.string(),
|
|
2585
|
+
name: z14.string(),
|
|
2586
|
+
arguments: z14.string(),
|
|
2587
|
+
status: z14.literal("completed")
|
|
2588
|
+
}),
|
|
2589
|
+
z14.object({
|
|
2590
|
+
type: z14.literal("code_interpreter_call"),
|
|
2591
|
+
id: z14.string(),
|
|
2592
|
+
code: z14.string().nullable(),
|
|
2593
|
+
container_id: z14.string(),
|
|
2594
|
+
outputs: z14.array(
|
|
2595
|
+
z14.discriminatedUnion("type", [
|
|
2596
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2597
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2598
|
+
])
|
|
2599
|
+
).nullable()
|
|
2600
|
+
}),
|
|
2601
|
+
z14.object({
|
|
2602
|
+
type: z14.literal("image_generation_call"),
|
|
2603
|
+
id: z14.string(),
|
|
2604
|
+
result: z14.string()
|
|
2605
|
+
}),
|
|
2606
|
+
z14.object({
|
|
2607
|
+
type: z14.literal("web_search_call"),
|
|
2608
|
+
id: z14.string(),
|
|
2609
|
+
status: z14.string(),
|
|
2610
|
+
action: z14.discriminatedUnion("type", [
|
|
2611
|
+
z14.object({
|
|
2612
|
+
type: z14.literal("search"),
|
|
2613
|
+
query: z14.string().nullish()
|
|
2614
|
+
}),
|
|
2615
|
+
z14.object({
|
|
2616
|
+
type: z14.literal("open_page"),
|
|
2617
|
+
url: z14.string()
|
|
2618
|
+
}),
|
|
2619
|
+
z14.object({
|
|
2620
|
+
type: z14.literal("find"),
|
|
2621
|
+
url: z14.string(),
|
|
2622
|
+
pattern: z14.string()
|
|
2623
|
+
})
|
|
2624
|
+
]).nullish()
|
|
2625
|
+
}),
|
|
2626
|
+
z14.object({
|
|
2627
|
+
type: z14.literal("file_search_call"),
|
|
2628
|
+
id: z14.string(),
|
|
2629
|
+
queries: z14.array(z14.string()),
|
|
2630
|
+
results: z14.array(
|
|
2631
|
+
z14.object({
|
|
2632
|
+
attributes: z14.record(z14.string(), z14.unknown()),
|
|
2633
|
+
file_id: z14.string(),
|
|
2634
|
+
filename: z14.string(),
|
|
2635
|
+
score: z14.number(),
|
|
2636
|
+
text: z14.string()
|
|
2637
|
+
})
|
|
2638
|
+
).nullish()
|
|
2639
|
+
}),
|
|
2640
|
+
z14.object({
|
|
2641
|
+
type: z14.literal("local_shell_call"),
|
|
2642
|
+
id: z14.string(),
|
|
2643
|
+
call_id: z14.string(),
|
|
2644
|
+
action: z14.object({
|
|
2645
|
+
type: z14.literal("exec"),
|
|
2646
|
+
command: z14.array(z14.string()),
|
|
2647
|
+
timeout_ms: z14.number().optional(),
|
|
2648
|
+
user: z14.string().optional(),
|
|
2649
|
+
working_directory: z14.string().optional(),
|
|
2650
|
+
env: z14.record(z14.string(), z14.string()).optional()
|
|
2651
|
+
})
|
|
2652
|
+
}),
|
|
2653
|
+
z14.object({
|
|
2654
|
+
type: z14.literal("computer_call"),
|
|
2655
|
+
id: z14.string(),
|
|
2656
|
+
status: z14.literal("completed")
|
|
2657
|
+
})
|
|
2658
|
+
])
|
|
2659
|
+
}),
|
|
2660
|
+
z14.object({
|
|
2661
|
+
type: z14.literal("response.function_call_arguments.delta"),
|
|
2662
|
+
item_id: z14.string(),
|
|
2663
|
+
output_index: z14.number(),
|
|
2664
|
+
delta: z14.string()
|
|
2665
|
+
}),
|
|
2666
|
+
z14.object({
|
|
2667
|
+
type: z14.literal("response.image_generation_call.partial_image"),
|
|
2668
|
+
item_id: z14.string(),
|
|
2669
|
+
output_index: z14.number(),
|
|
2670
|
+
partial_image_b64: z14.string()
|
|
2671
|
+
}),
|
|
2672
|
+
z14.object({
|
|
2673
|
+
type: z14.literal("response.code_interpreter_call_code.delta"),
|
|
2674
|
+
item_id: z14.string(),
|
|
2675
|
+
output_index: z14.number(),
|
|
2676
|
+
delta: z14.string()
|
|
2677
|
+
}),
|
|
2678
|
+
z14.object({
|
|
2679
|
+
type: z14.literal("response.code_interpreter_call_code.done"),
|
|
2680
|
+
item_id: z14.string(),
|
|
2681
|
+
output_index: z14.number(),
|
|
2682
|
+
code: z14.string()
|
|
2683
|
+
}),
|
|
2684
|
+
z14.object({
|
|
2685
|
+
type: z14.literal("response.output_text.annotation.added"),
|
|
2686
|
+
annotation: z14.discriminatedUnion("type", [
|
|
2687
|
+
z14.object({
|
|
2688
|
+
type: z14.literal("url_citation"),
|
|
2689
|
+
url: z14.string(),
|
|
2690
|
+
title: z14.string()
|
|
2691
|
+
}),
|
|
2692
|
+
z14.object({
|
|
2693
|
+
type: z14.literal("file_citation"),
|
|
2694
|
+
file_id: z14.string(),
|
|
2695
|
+
filename: z14.string().nullish(),
|
|
2696
|
+
index: z14.number().nullish(),
|
|
2697
|
+
start_index: z14.number().nullish(),
|
|
2698
|
+
end_index: z14.number().nullish(),
|
|
2699
|
+
quote: z14.string().nullish()
|
|
2700
|
+
})
|
|
2701
|
+
])
|
|
2702
|
+
}),
|
|
2703
|
+
z14.object({
|
|
2704
|
+
type: z14.literal("response.reasoning_summary_part.added"),
|
|
2705
|
+
item_id: z14.string(),
|
|
2706
|
+
summary_index: z14.number()
|
|
2707
|
+
}),
|
|
2708
|
+
z14.object({
|
|
2709
|
+
type: z14.literal("response.reasoning_summary_text.delta"),
|
|
2710
|
+
item_id: z14.string(),
|
|
2711
|
+
summary_index: z14.number(),
|
|
2712
|
+
delta: z14.string()
|
|
2713
|
+
}),
|
|
2714
|
+
z14.object({
|
|
2715
|
+
type: z14.literal("error"),
|
|
2716
|
+
code: z14.string(),
|
|
2717
|
+
message: z14.string(),
|
|
2718
|
+
param: z14.string().nullish(),
|
|
2719
|
+
sequence_number: z14.number()
|
|
2720
|
+
}),
|
|
2721
|
+
z14.object({ type: z14.string() }).loose().transform((value) => ({
|
|
2722
|
+
type: "unknown_chunk",
|
|
2723
|
+
message: value.type
|
|
2724
|
+
}))
|
|
2725
|
+
// fallback for unknown chunks
|
|
2726
|
+
])
|
|
2727
|
+
)
|
|
2728
|
+
);
|
|
2729
|
+
var openaiResponsesResponseSchema = lazyValidator11(
|
|
2730
|
+
() => zodSchema12(
|
|
2731
|
+
z14.object({
|
|
2732
|
+
id: z14.string(),
|
|
2733
|
+
created_at: z14.number(),
|
|
2734
|
+
error: z14.object({
|
|
2735
|
+
code: z14.string(),
|
|
2736
|
+
message: z14.string()
|
|
2737
|
+
}).nullish(),
|
|
2738
|
+
model: z14.string(),
|
|
2739
|
+
output: z14.array(
|
|
2740
|
+
z14.discriminatedUnion("type", [
|
|
2741
|
+
z14.object({
|
|
2742
|
+
type: z14.literal("message"),
|
|
2743
|
+
role: z14.literal("assistant"),
|
|
2744
|
+
id: z14.string(),
|
|
2745
|
+
content: z14.array(
|
|
2746
|
+
z14.object({
|
|
2747
|
+
type: z14.literal("output_text"),
|
|
2748
|
+
text: z14.string(),
|
|
2749
|
+
logprobs: z14.array(
|
|
2750
|
+
z14.object({
|
|
2751
|
+
token: z14.string(),
|
|
2752
|
+
logprob: z14.number(),
|
|
2753
|
+
top_logprobs: z14.array(
|
|
2754
|
+
z14.object({
|
|
2755
|
+
token: z14.string(),
|
|
2756
|
+
logprob: z14.number()
|
|
2757
|
+
})
|
|
2758
|
+
)
|
|
2759
|
+
})
|
|
2760
|
+
).nullish(),
|
|
2761
|
+
annotations: z14.array(
|
|
2762
|
+
z14.discriminatedUnion("type", [
|
|
2763
|
+
z14.object({
|
|
2764
|
+
type: z14.literal("url_citation"),
|
|
2765
|
+
start_index: z14.number(),
|
|
2766
|
+
end_index: z14.number(),
|
|
2767
|
+
url: z14.string(),
|
|
2768
|
+
title: z14.string()
|
|
2769
|
+
}),
|
|
2770
|
+
z14.object({
|
|
2771
|
+
type: z14.literal("file_citation"),
|
|
2772
|
+
file_id: z14.string(),
|
|
2773
|
+
filename: z14.string().nullish(),
|
|
2774
|
+
index: z14.number().nullish(),
|
|
2775
|
+
start_index: z14.number().nullish(),
|
|
2776
|
+
end_index: z14.number().nullish(),
|
|
2777
|
+
quote: z14.string().nullish()
|
|
2778
|
+
}),
|
|
2779
|
+
z14.object({
|
|
2780
|
+
type: z14.literal("container_file_citation")
|
|
2781
|
+
})
|
|
2782
|
+
])
|
|
2783
|
+
)
|
|
2784
|
+
})
|
|
2785
|
+
)
|
|
2786
|
+
}),
|
|
2787
|
+
z14.object({
|
|
2788
|
+
type: z14.literal("web_search_call"),
|
|
2789
|
+
id: z14.string(),
|
|
2790
|
+
status: z14.string(),
|
|
2791
|
+
action: z14.discriminatedUnion("type", [
|
|
2792
|
+
z14.object({
|
|
2793
|
+
type: z14.literal("search"),
|
|
2794
|
+
query: z14.string().nullish()
|
|
2795
|
+
}),
|
|
2796
|
+
z14.object({
|
|
2797
|
+
type: z14.literal("open_page"),
|
|
2798
|
+
url: z14.string()
|
|
2799
|
+
}),
|
|
2800
|
+
z14.object({
|
|
2801
|
+
type: z14.literal("find"),
|
|
2802
|
+
url: z14.string(),
|
|
2803
|
+
pattern: z14.string()
|
|
2804
|
+
})
|
|
2805
|
+
]).nullish()
|
|
2806
|
+
}),
|
|
2807
|
+
z14.object({
|
|
2808
|
+
type: z14.literal("file_search_call"),
|
|
2809
|
+
id: z14.string(),
|
|
2810
|
+
queries: z14.array(z14.string()),
|
|
2811
|
+
results: z14.array(
|
|
2812
|
+
z14.object({
|
|
2813
|
+
attributes: z14.record(z14.string(), z14.unknown()),
|
|
2814
|
+
file_id: z14.string(),
|
|
2815
|
+
filename: z14.string(),
|
|
2816
|
+
score: z14.number(),
|
|
2817
|
+
text: z14.string()
|
|
2818
|
+
})
|
|
2819
|
+
).nullish()
|
|
2820
|
+
}),
|
|
2821
|
+
z14.object({
|
|
2822
|
+
type: z14.literal("code_interpreter_call"),
|
|
2823
|
+
id: z14.string(),
|
|
2824
|
+
code: z14.string().nullable(),
|
|
2825
|
+
container_id: z14.string(),
|
|
2826
|
+
outputs: z14.array(
|
|
2827
|
+
z14.discriminatedUnion("type", [
|
|
2828
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2829
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2830
|
+
])
|
|
2831
|
+
).nullable()
|
|
2832
|
+
}),
|
|
2833
|
+
z14.object({
|
|
2834
|
+
type: z14.literal("image_generation_call"),
|
|
2835
|
+
id: z14.string(),
|
|
2836
|
+
result: z14.string()
|
|
2837
|
+
}),
|
|
2838
|
+
z14.object({
|
|
2839
|
+
type: z14.literal("local_shell_call"),
|
|
2840
|
+
id: z14.string(),
|
|
2841
|
+
call_id: z14.string(),
|
|
2842
|
+
action: z14.object({
|
|
2843
|
+
type: z14.literal("exec"),
|
|
2844
|
+
command: z14.array(z14.string()),
|
|
2845
|
+
timeout_ms: z14.number().optional(),
|
|
2846
|
+
user: z14.string().optional(),
|
|
2847
|
+
working_directory: z14.string().optional(),
|
|
2848
|
+
env: z14.record(z14.string(), z14.string()).optional()
|
|
2849
|
+
})
|
|
2850
|
+
}),
|
|
2851
|
+
z14.object({
|
|
2852
|
+
type: z14.literal("function_call"),
|
|
2853
|
+
call_id: z14.string(),
|
|
2854
|
+
name: z14.string(),
|
|
2855
|
+
arguments: z14.string(),
|
|
2856
|
+
id: z14.string()
|
|
2857
|
+
}),
|
|
2858
|
+
z14.object({
|
|
2859
|
+
type: z14.literal("computer_call"),
|
|
2860
|
+
id: z14.string(),
|
|
2861
|
+
status: z14.string().optional()
|
|
2862
|
+
}),
|
|
2863
|
+
z14.object({
|
|
2864
|
+
type: z14.literal("reasoning"),
|
|
2865
|
+
id: z14.string(),
|
|
2866
|
+
encrypted_content: z14.string().nullish(),
|
|
2867
|
+
summary: z14.array(
|
|
2868
|
+
z14.object({
|
|
2869
|
+
type: z14.literal("summary_text"),
|
|
2870
|
+
text: z14.string()
|
|
2871
|
+
})
|
|
2872
|
+
)
|
|
2873
|
+
})
|
|
2874
|
+
])
|
|
2875
|
+
),
|
|
2876
|
+
service_tier: z14.string().nullish(),
|
|
2877
|
+
incomplete_details: z14.object({ reason: z14.string() }).nullish(),
|
|
2878
|
+
usage: z14.object({
|
|
2879
|
+
input_tokens: z14.number(),
|
|
2880
|
+
input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
|
|
2881
|
+
output_tokens: z14.number(),
|
|
2882
|
+
output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
|
|
2883
|
+
})
|
|
2884
|
+
})
|
|
2885
|
+
)
|
|
2886
|
+
);
|
|
2887
|
+
|
|
2888
|
+
// src/responses/openai-responses-options.ts
|
|
2889
|
+
import {
|
|
2890
|
+
lazyValidator as lazyValidator12,
|
|
2891
|
+
zodSchema as zodSchema13
|
|
2892
|
+
} from "@ai-sdk/provider-utils";
|
|
2893
|
+
import * as z15 from "zod/v4";
|
|
2894
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
2895
|
+
var openaiResponsesReasoningModelIds = [
|
|
2896
|
+
"o1",
|
|
2897
|
+
"o1-2024-12-17",
|
|
2898
|
+
"o3-mini",
|
|
2899
|
+
"o3-mini-2025-01-31",
|
|
2900
|
+
"o3",
|
|
2901
|
+
"o3-2025-04-16",
|
|
2902
|
+
"o4-mini",
|
|
2903
|
+
"o4-mini-2025-04-16",
|
|
2904
|
+
"codex-mini-latest",
|
|
2905
|
+
"computer-use-preview",
|
|
2906
|
+
"gpt-5",
|
|
2907
|
+
"gpt-5-2025-08-07",
|
|
2908
|
+
"gpt-5-codex",
|
|
2909
|
+
"gpt-5-mini",
|
|
2910
|
+
"gpt-5-mini-2025-08-07",
|
|
2911
|
+
"gpt-5-nano",
|
|
2912
|
+
"gpt-5-nano-2025-08-07",
|
|
2913
|
+
"gpt-5-pro",
|
|
2914
|
+
"gpt-5-pro-2025-10-06"
|
|
2915
|
+
];
|
|
2916
|
+
var openaiResponsesModelIds = [
|
|
2917
|
+
"gpt-4.1",
|
|
2918
|
+
"gpt-4.1-2025-04-14",
|
|
2919
|
+
"gpt-4.1-mini",
|
|
2920
|
+
"gpt-4.1-mini-2025-04-14",
|
|
2921
|
+
"gpt-4.1-nano",
|
|
2922
|
+
"gpt-4.1-nano-2025-04-14",
|
|
2923
|
+
"gpt-4o",
|
|
2924
|
+
"gpt-4o-2024-05-13",
|
|
2925
|
+
"gpt-4o-2024-08-06",
|
|
2926
|
+
"gpt-4o-2024-11-20",
|
|
2927
|
+
"gpt-4o-audio-preview",
|
|
2928
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
2929
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
2930
|
+
"gpt-4o-search-preview",
|
|
2931
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
2932
|
+
"gpt-4o-mini-search-preview",
|
|
2933
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
2934
|
+
"gpt-4o-mini",
|
|
2935
|
+
"gpt-4o-mini-2024-07-18",
|
|
2936
|
+
"gpt-4-turbo",
|
|
2937
|
+
"gpt-4-turbo-2024-04-09",
|
|
2938
|
+
"gpt-4-turbo-preview",
|
|
2939
|
+
"gpt-4-0125-preview",
|
|
2940
|
+
"gpt-4-1106-preview",
|
|
2941
|
+
"gpt-4",
|
|
2942
|
+
"gpt-4-0613",
|
|
2943
|
+
"gpt-4.5-preview",
|
|
2944
|
+
"gpt-4.5-preview-2025-02-27",
|
|
2945
|
+
"gpt-3.5-turbo-0125",
|
|
2946
|
+
"gpt-3.5-turbo",
|
|
2947
|
+
"gpt-3.5-turbo-1106",
|
|
2948
|
+
"chatgpt-4o-latest",
|
|
2949
|
+
"gpt-5-chat-latest",
|
|
2950
|
+
...openaiResponsesReasoningModelIds
|
|
2951
|
+
];
|
|
2952
|
+
var openaiResponsesProviderOptionsSchema = lazyValidator12(
|
|
2953
|
+
() => zodSchema13(
|
|
2954
|
+
z15.object({
|
|
2955
|
+
include: z15.array(
|
|
2956
|
+
z15.enum([
|
|
2957
|
+
"reasoning.encrypted_content",
|
|
2958
|
+
"file_search_call.results",
|
|
2959
|
+
"message.output_text.logprobs"
|
|
2960
|
+
])
|
|
2961
|
+
).nullish(),
|
|
2962
|
+
instructions: z15.string().nullish(),
|
|
2963
|
+
/**
|
|
2964
|
+
* Return the log probabilities of the tokens.
|
|
2965
|
+
*
|
|
2966
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
2967
|
+
* were generated.
|
|
2968
|
+
*
|
|
2969
|
+
* Setting to a number will return the log probabilities of the top n
|
|
2970
|
+
* tokens that were generated.
|
|
2971
|
+
*
|
|
2972
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
2973
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
2974
|
+
*/
|
|
2975
|
+
logprobs: z15.union([z15.boolean(), z15.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
2976
|
+
/**
|
|
2977
|
+
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
2978
|
+
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
2979
|
+
* Any further attempts to call a tool by the model will be ignored.
|
|
2980
|
+
*/
|
|
2981
|
+
maxToolCalls: z15.number().nullish(),
|
|
2982
|
+
metadata: z15.any().nullish(),
|
|
2983
|
+
parallelToolCalls: z15.boolean().nullish(),
|
|
2984
|
+
previousResponseId: z15.string().nullish(),
|
|
2985
|
+
promptCacheKey: z15.string().nullish(),
|
|
2986
|
+
reasoningEffort: z15.string().nullish(),
|
|
2987
|
+
reasoningSummary: z15.string().nullish(),
|
|
2988
|
+
safetyIdentifier: z15.string().nullish(),
|
|
2989
|
+
serviceTier: z15.enum(["auto", "flex", "priority"]).nullish(),
|
|
2990
|
+
store: z15.boolean().nullish(),
|
|
2991
|
+
strictJsonSchema: z15.boolean().nullish(),
|
|
2992
|
+
textVerbosity: z15.enum(["low", "medium", "high"]).nullish(),
|
|
2993
|
+
user: z15.string().nullish()
|
|
2994
|
+
})
|
|
2995
|
+
)
|
|
2996
|
+
);
|
|
2997
|
+
|
|
2335
2998
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2336
2999
|
import {
|
|
2337
3000
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
2338
3001
|
} from "@ai-sdk/provider";
|
|
2339
3002
|
|
|
2340
3003
|
// src/tool/code-interpreter.ts
|
|
2341
|
-
import {
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
var
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
])
|
|
2353
|
-
).nullish()
|
|
2354
|
-
});
|
|
2355
|
-
var codeInterpreterArgsSchema = z14.object({
|
|
2356
|
-
container: z14.union([
|
|
2357
|
-
z14.string(),
|
|
2358
|
-
z14.object({
|
|
2359
|
-
fileIds: z14.array(z14.string()).optional()
|
|
3004
|
+
import {
|
|
3005
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
3006
|
+
lazySchema as lazySchema2,
|
|
3007
|
+
zodSchema as zodSchema14
|
|
3008
|
+
} from "@ai-sdk/provider-utils";
|
|
3009
|
+
import * as z16 from "zod/v4";
|
|
3010
|
+
var codeInterpreterInputSchema = lazySchema2(
|
|
3011
|
+
() => zodSchema14(
|
|
3012
|
+
z16.object({
|
|
3013
|
+
code: z16.string().nullish(),
|
|
3014
|
+
containerId: z16.string()
|
|
2360
3015
|
})
|
|
2361
|
-
|
|
2362
|
-
|
|
3016
|
+
)
|
|
3017
|
+
);
|
|
3018
|
+
var codeInterpreterOutputSchema = lazySchema2(
|
|
3019
|
+
() => zodSchema14(
|
|
3020
|
+
z16.object({
|
|
3021
|
+
outputs: z16.array(
|
|
3022
|
+
z16.discriminatedUnion("type", [
|
|
3023
|
+
z16.object({ type: z16.literal("logs"), logs: z16.string() }),
|
|
3024
|
+
z16.object({ type: z16.literal("image"), url: z16.string() })
|
|
3025
|
+
])
|
|
3026
|
+
).nullish()
|
|
3027
|
+
})
|
|
3028
|
+
)
|
|
3029
|
+
);
|
|
3030
|
+
var codeInterpreterArgsSchema = lazySchema2(
|
|
3031
|
+
() => zodSchema14(
|
|
3032
|
+
z16.object({
|
|
3033
|
+
container: z16.union([
|
|
3034
|
+
z16.string(),
|
|
3035
|
+
z16.object({
|
|
3036
|
+
fileIds: z16.array(z16.string()).optional()
|
|
3037
|
+
})
|
|
3038
|
+
]).optional()
|
|
3039
|
+
})
|
|
3040
|
+
)
|
|
3041
|
+
);
|
|
2363
3042
|
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
2364
3043
|
id: "openai.code_interpreter",
|
|
2365
3044
|
name: "code_interpreter",
|
|
@@ -2371,168 +3050,216 @@ var codeInterpreter = (args = {}) => {
|
|
|
2371
3050
|
};
|
|
2372
3051
|
|
|
2373
3052
|
// src/tool/file-search.ts
|
|
2374
|
-
import {
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
3053
|
+
import {
|
|
3054
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
|
|
3055
|
+
lazySchema as lazySchema3,
|
|
3056
|
+
zodSchema as zodSchema15
|
|
3057
|
+
} from "@ai-sdk/provider-utils";
|
|
3058
|
+
import * as z17 from "zod/v4";
|
|
3059
|
+
var comparisonFilterSchema = z17.object({
|
|
3060
|
+
key: z17.string(),
|
|
3061
|
+
type: z17.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
3062
|
+
value: z17.union([z17.string(), z17.number(), z17.boolean()])
|
|
2380
3063
|
});
|
|
2381
|
-
var compoundFilterSchema =
|
|
2382
|
-
type:
|
|
2383
|
-
filters:
|
|
2384
|
-
|
|
3064
|
+
var compoundFilterSchema = z17.object({
|
|
3065
|
+
type: z17.enum(["and", "or"]),
|
|
3066
|
+
filters: z17.array(
|
|
3067
|
+
z17.union([comparisonFilterSchema, z17.lazy(() => compoundFilterSchema)])
|
|
2385
3068
|
)
|
|
2386
3069
|
});
|
|
2387
|
-
var fileSearchArgsSchema =
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
})
|
|
2396
|
-
|
|
2397
|
-
queries: z15.array(z15.string()),
|
|
2398
|
-
results: z15.array(
|
|
2399
|
-
z15.object({
|
|
2400
|
-
attributes: z15.record(z15.string(), z15.unknown()),
|
|
2401
|
-
fileId: z15.string(),
|
|
2402
|
-
filename: z15.string(),
|
|
2403
|
-
score: z15.number(),
|
|
2404
|
-
text: z15.string()
|
|
3070
|
+
var fileSearchArgsSchema = lazySchema3(
|
|
3071
|
+
() => zodSchema15(
|
|
3072
|
+
z17.object({
|
|
3073
|
+
vectorStoreIds: z17.array(z17.string()),
|
|
3074
|
+
maxNumResults: z17.number().optional(),
|
|
3075
|
+
ranking: z17.object({
|
|
3076
|
+
ranker: z17.string().optional(),
|
|
3077
|
+
scoreThreshold: z17.number().optional()
|
|
3078
|
+
}).optional(),
|
|
3079
|
+
filters: z17.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2405
3080
|
})
|
|
2406
|
-
)
|
|
2407
|
-
|
|
3081
|
+
)
|
|
3082
|
+
);
|
|
3083
|
+
var fileSearchOutputSchema = lazySchema3(
|
|
3084
|
+
() => zodSchema15(
|
|
3085
|
+
z17.object({
|
|
3086
|
+
queries: z17.array(z17.string()),
|
|
3087
|
+
results: z17.array(
|
|
3088
|
+
z17.object({
|
|
3089
|
+
attributes: z17.record(z17.string(), z17.unknown()),
|
|
3090
|
+
fileId: z17.string(),
|
|
3091
|
+
filename: z17.string(),
|
|
3092
|
+
score: z17.number(),
|
|
3093
|
+
text: z17.string()
|
|
3094
|
+
})
|
|
3095
|
+
).nullable()
|
|
3096
|
+
})
|
|
3097
|
+
)
|
|
3098
|
+
);
|
|
2408
3099
|
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
2409
3100
|
id: "openai.file_search",
|
|
2410
3101
|
name: "file_search",
|
|
2411
|
-
inputSchema:
|
|
3102
|
+
inputSchema: z17.object({}),
|
|
2412
3103
|
outputSchema: fileSearchOutputSchema
|
|
2413
3104
|
});
|
|
2414
3105
|
|
|
2415
3106
|
// src/tool/web-search.ts
|
|
2416
|
-
import {
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
3107
|
+
import {
|
|
3108
|
+
createProviderDefinedToolFactory,
|
|
3109
|
+
lazySchema as lazySchema4,
|
|
3110
|
+
zodSchema as zodSchema16
|
|
3111
|
+
} from "@ai-sdk/provider-utils";
|
|
3112
|
+
import * as z18 from "zod/v4";
|
|
3113
|
+
var webSearchArgsSchema = lazySchema4(
|
|
3114
|
+
() => zodSchema16(
|
|
3115
|
+
z18.object({
|
|
3116
|
+
filters: z18.object({
|
|
3117
|
+
allowedDomains: z18.array(z18.string()).optional()
|
|
3118
|
+
}).optional(),
|
|
3119
|
+
searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
|
|
3120
|
+
userLocation: z18.object({
|
|
3121
|
+
type: z18.literal("approximate"),
|
|
3122
|
+
country: z18.string().optional(),
|
|
3123
|
+
city: z18.string().optional(),
|
|
3124
|
+
region: z18.string().optional(),
|
|
3125
|
+
timezone: z18.string().optional()
|
|
3126
|
+
}).optional()
|
|
3127
|
+
})
|
|
3128
|
+
)
|
|
3129
|
+
);
|
|
3130
|
+
var webSearchInputSchema = lazySchema4(
|
|
3131
|
+
() => zodSchema16(
|
|
3132
|
+
z18.object({
|
|
3133
|
+
action: z18.discriminatedUnion("type", [
|
|
3134
|
+
z18.object({
|
|
3135
|
+
type: z18.literal("search"),
|
|
3136
|
+
query: z18.string().nullish()
|
|
3137
|
+
}),
|
|
3138
|
+
z18.object({
|
|
3139
|
+
type: z18.literal("open_page"),
|
|
3140
|
+
url: z18.string()
|
|
3141
|
+
}),
|
|
3142
|
+
z18.object({
|
|
3143
|
+
type: z18.literal("find"),
|
|
3144
|
+
url: z18.string(),
|
|
3145
|
+
pattern: z18.string()
|
|
3146
|
+
})
|
|
3147
|
+
]).nullish()
|
|
3148
|
+
})
|
|
3149
|
+
)
|
|
3150
|
+
);
|
|
2431
3151
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
2432
3152
|
id: "openai.web_search",
|
|
2433
3153
|
name: "web_search",
|
|
2434
|
-
inputSchema:
|
|
2435
|
-
action: z16.discriminatedUnion("type", [
|
|
2436
|
-
z16.object({
|
|
2437
|
-
type: z16.literal("search"),
|
|
2438
|
-
query: z16.string().nullish()
|
|
2439
|
-
}),
|
|
2440
|
-
z16.object({
|
|
2441
|
-
type: z16.literal("open_page"),
|
|
2442
|
-
url: z16.string()
|
|
2443
|
-
}),
|
|
2444
|
-
z16.object({
|
|
2445
|
-
type: z16.literal("find"),
|
|
2446
|
-
url: z16.string(),
|
|
2447
|
-
pattern: z16.string()
|
|
2448
|
-
})
|
|
2449
|
-
]).nullish()
|
|
2450
|
-
})
|
|
3154
|
+
inputSchema: webSearchInputSchema
|
|
2451
3155
|
});
|
|
2452
3156
|
|
|
2453
3157
|
// src/tool/web-search-preview.ts
|
|
2454
|
-
import {
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
3158
|
+
import {
|
|
3159
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
3160
|
+
lazySchema as lazySchema5,
|
|
3161
|
+
zodSchema as zodSchema17
|
|
3162
|
+
} from "@ai-sdk/provider-utils";
|
|
3163
|
+
import * as z19 from "zod/v4";
|
|
3164
|
+
var webSearchPreviewArgsSchema = lazySchema5(
|
|
3165
|
+
() => zodSchema17(
|
|
3166
|
+
z19.object({
|
|
3167
|
+
/**
|
|
3168
|
+
* Search context size to use for the web search.
|
|
3169
|
+
* - high: Most comprehensive context, highest cost, slower response
|
|
3170
|
+
* - medium: Balanced context, cost, and latency (default)
|
|
3171
|
+
* - low: Least context, lowest cost, fastest response
|
|
3172
|
+
*/
|
|
3173
|
+
searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
|
|
3174
|
+
/**
|
|
3175
|
+
* User location information to provide geographically relevant search results.
|
|
3176
|
+
*/
|
|
3177
|
+
userLocation: z19.object({
|
|
3178
|
+
/**
|
|
3179
|
+
* Type of location (always 'approximate')
|
|
3180
|
+
*/
|
|
3181
|
+
type: z19.literal("approximate"),
|
|
3182
|
+
/**
|
|
3183
|
+
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
3184
|
+
*/
|
|
3185
|
+
country: z19.string().optional(),
|
|
3186
|
+
/**
|
|
3187
|
+
* City name (free text, e.g., 'Minneapolis')
|
|
3188
|
+
*/
|
|
3189
|
+
city: z19.string().optional(),
|
|
3190
|
+
/**
|
|
3191
|
+
* Region name (free text, e.g., 'Minnesota')
|
|
3192
|
+
*/
|
|
3193
|
+
region: z19.string().optional(),
|
|
3194
|
+
/**
|
|
3195
|
+
* IANA timezone (e.g., 'America/Chicago')
|
|
3196
|
+
*/
|
|
3197
|
+
timezone: z19.string().optional()
|
|
3198
|
+
}).optional()
|
|
3199
|
+
})
|
|
3200
|
+
)
|
|
3201
|
+
);
|
|
3202
|
+
var webSearchPreviewInputSchema = lazySchema5(
|
|
3203
|
+
() => zodSchema17(
|
|
3204
|
+
z19.object({
|
|
3205
|
+
action: z19.discriminatedUnion("type", [
|
|
3206
|
+
z19.object({
|
|
3207
|
+
type: z19.literal("search"),
|
|
3208
|
+
query: z19.string().nullish()
|
|
3209
|
+
}),
|
|
3210
|
+
z19.object({
|
|
3211
|
+
type: z19.literal("open_page"),
|
|
3212
|
+
url: z19.string()
|
|
3213
|
+
}),
|
|
3214
|
+
z19.object({
|
|
3215
|
+
type: z19.literal("find"),
|
|
3216
|
+
url: z19.string(),
|
|
3217
|
+
pattern: z19.string()
|
|
3218
|
+
})
|
|
3219
|
+
]).nullish()
|
|
3220
|
+
})
|
|
3221
|
+
)
|
|
3222
|
+
);
|
|
2490
3223
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
2491
3224
|
id: "openai.web_search_preview",
|
|
2492
3225
|
name: "web_search_preview",
|
|
2493
|
-
inputSchema:
|
|
2494
|
-
action: z17.discriminatedUnion("type", [
|
|
2495
|
-
z17.object({
|
|
2496
|
-
type: z17.literal("search"),
|
|
2497
|
-
query: z17.string().nullish()
|
|
2498
|
-
}),
|
|
2499
|
-
z17.object({
|
|
2500
|
-
type: z17.literal("open_page"),
|
|
2501
|
-
url: z17.string()
|
|
2502
|
-
}),
|
|
2503
|
-
z17.object({
|
|
2504
|
-
type: z17.literal("find"),
|
|
2505
|
-
url: z17.string(),
|
|
2506
|
-
pattern: z17.string()
|
|
2507
|
-
})
|
|
2508
|
-
]).nullish()
|
|
2509
|
-
})
|
|
3226
|
+
inputSchema: webSearchPreviewInputSchema
|
|
2510
3227
|
});
|
|
2511
3228
|
|
|
2512
3229
|
// src/tool/image-generation.ts
|
|
2513
|
-
import {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
3230
|
+
import {
|
|
3231
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
3232
|
+
lazySchema as lazySchema6,
|
|
3233
|
+
zodSchema as zodSchema18
|
|
3234
|
+
} from "@ai-sdk/provider-utils";
|
|
3235
|
+
import * as z20 from "zod/v4";
|
|
3236
|
+
var imageGenerationArgsSchema = lazySchema6(
|
|
3237
|
+
() => zodSchema18(
|
|
3238
|
+
z20.object({
|
|
3239
|
+
background: z20.enum(["auto", "opaque", "transparent"]).optional(),
|
|
3240
|
+
inputFidelity: z20.enum(["low", "high"]).optional(),
|
|
3241
|
+
inputImageMask: z20.object({
|
|
3242
|
+
fileId: z20.string().optional(),
|
|
3243
|
+
imageUrl: z20.string().optional()
|
|
3244
|
+
}).optional(),
|
|
3245
|
+
model: z20.string().optional(),
|
|
3246
|
+
moderation: z20.enum(["auto"]).optional(),
|
|
3247
|
+
outputCompression: z20.number().int().min(0).max(100).optional(),
|
|
3248
|
+
outputFormat: z20.enum(["png", "jpeg", "webp"]).optional(),
|
|
3249
|
+
partialImages: z20.number().int().min(0).max(3).optional(),
|
|
3250
|
+
quality: z20.enum(["auto", "low", "medium", "high"]).optional(),
|
|
3251
|
+
size: z20.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
3252
|
+
}).strict()
|
|
3253
|
+
)
|
|
3254
|
+
);
|
|
3255
|
+
var imageGenerationInputSchema = lazySchema6(() => zodSchema18(z20.object({})));
|
|
3256
|
+
var imageGenerationOutputSchema = lazySchema6(
|
|
3257
|
+
() => zodSchema18(z20.object({ result: z20.string() }))
|
|
3258
|
+
);
|
|
2532
3259
|
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
2533
3260
|
id: "openai.image_generation",
|
|
2534
3261
|
name: "image_generation",
|
|
2535
|
-
inputSchema:
|
|
3262
|
+
inputSchema: imageGenerationInputSchema,
|
|
2536
3263
|
outputSchema: imageGenerationOutputSchema
|
|
2537
3264
|
});
|
|
2538
3265
|
var imageGeneration = (args = {}) => {
|
|
@@ -2540,7 +3267,8 @@ var imageGeneration = (args = {}) => {
|
|
|
2540
3267
|
};
|
|
2541
3268
|
|
|
2542
3269
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2543
|
-
|
|
3270
|
+
import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
|
|
3271
|
+
async function prepareResponsesTools({
|
|
2544
3272
|
tools,
|
|
2545
3273
|
toolChoice,
|
|
2546
3274
|
strictJsonSchema
|
|
@@ -2565,7 +3293,10 @@ function prepareResponsesTools({
|
|
|
2565
3293
|
case "provider-defined": {
|
|
2566
3294
|
switch (tool.id) {
|
|
2567
3295
|
case "openai.file_search": {
|
|
2568
|
-
const args =
|
|
3296
|
+
const args = await validateTypes2({
|
|
3297
|
+
value: tool.args,
|
|
3298
|
+
schema: fileSearchArgsSchema
|
|
3299
|
+
});
|
|
2569
3300
|
openaiTools.push({
|
|
2570
3301
|
type: "file_search",
|
|
2571
3302
|
vector_store_ids: args.vectorStoreIds,
|
|
@@ -2585,7 +3316,10 @@ function prepareResponsesTools({
|
|
|
2585
3316
|
break;
|
|
2586
3317
|
}
|
|
2587
3318
|
case "openai.web_search_preview": {
|
|
2588
|
-
const args =
|
|
3319
|
+
const args = await validateTypes2({
|
|
3320
|
+
value: tool.args,
|
|
3321
|
+
schema: webSearchPreviewArgsSchema
|
|
3322
|
+
});
|
|
2589
3323
|
openaiTools.push({
|
|
2590
3324
|
type: "web_search_preview",
|
|
2591
3325
|
search_context_size: args.searchContextSize,
|
|
@@ -2594,7 +3328,10 @@ function prepareResponsesTools({
|
|
|
2594
3328
|
break;
|
|
2595
3329
|
}
|
|
2596
3330
|
case "openai.web_search": {
|
|
2597
|
-
const args =
|
|
3331
|
+
const args = await validateTypes2({
|
|
3332
|
+
value: tool.args,
|
|
3333
|
+
schema: webSearchArgsSchema
|
|
3334
|
+
});
|
|
2598
3335
|
openaiTools.push({
|
|
2599
3336
|
type: "web_search",
|
|
2600
3337
|
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
@@ -2604,7 +3341,10 @@ function prepareResponsesTools({
|
|
|
2604
3341
|
break;
|
|
2605
3342
|
}
|
|
2606
3343
|
case "openai.code_interpreter": {
|
|
2607
|
-
const args =
|
|
3344
|
+
const args = await validateTypes2({
|
|
3345
|
+
value: tool.args,
|
|
3346
|
+
schema: codeInterpreterArgsSchema
|
|
3347
|
+
});
|
|
2608
3348
|
openaiTools.push({
|
|
2609
3349
|
type: "code_interpreter",
|
|
2610
3350
|
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
@@ -2612,7 +3352,10 @@ function prepareResponsesTools({
|
|
|
2612
3352
|
break;
|
|
2613
3353
|
}
|
|
2614
3354
|
case "openai.image_generation": {
|
|
2615
|
-
const args =
|
|
3355
|
+
const args = await validateTypes2({
|
|
3356
|
+
value: tool.args,
|
|
3357
|
+
schema: imageGenerationArgsSchema
|
|
3358
|
+
});
|
|
2616
3359
|
openaiTools.push({
|
|
2617
3360
|
type: "image_generation",
|
|
2618
3361
|
background: args.background,
|
|
@@ -2663,83 +3406,6 @@ function prepareResponsesTools({
|
|
|
2663
3406
|
}
|
|
2664
3407
|
|
|
2665
3408
|
// src/responses/openai-responses-language-model.ts
|
|
2666
|
-
var webSearchCallItem = z19.object({
|
|
2667
|
-
type: z19.literal("web_search_call"),
|
|
2668
|
-
id: z19.string(),
|
|
2669
|
-
status: z19.string(),
|
|
2670
|
-
action: z19.discriminatedUnion("type", [
|
|
2671
|
-
z19.object({
|
|
2672
|
-
type: z19.literal("search"),
|
|
2673
|
-
query: z19.string().nullish()
|
|
2674
|
-
}),
|
|
2675
|
-
z19.object({
|
|
2676
|
-
type: z19.literal("open_page"),
|
|
2677
|
-
url: z19.string()
|
|
2678
|
-
}),
|
|
2679
|
-
z19.object({
|
|
2680
|
-
type: z19.literal("find"),
|
|
2681
|
-
url: z19.string(),
|
|
2682
|
-
pattern: z19.string()
|
|
2683
|
-
})
|
|
2684
|
-
]).nullish()
|
|
2685
|
-
});
|
|
2686
|
-
var fileSearchCallItem = z19.object({
|
|
2687
|
-
type: z19.literal("file_search_call"),
|
|
2688
|
-
id: z19.string(),
|
|
2689
|
-
queries: z19.array(z19.string()),
|
|
2690
|
-
results: z19.array(
|
|
2691
|
-
z19.object({
|
|
2692
|
-
attributes: z19.record(z19.string(), z19.unknown()),
|
|
2693
|
-
file_id: z19.string(),
|
|
2694
|
-
filename: z19.string(),
|
|
2695
|
-
score: z19.number(),
|
|
2696
|
-
text: z19.string()
|
|
2697
|
-
})
|
|
2698
|
-
).nullish()
|
|
2699
|
-
});
|
|
2700
|
-
var codeInterpreterCallItem = z19.object({
|
|
2701
|
-
type: z19.literal("code_interpreter_call"),
|
|
2702
|
-
id: z19.string(),
|
|
2703
|
-
code: z19.string().nullable(),
|
|
2704
|
-
container_id: z19.string(),
|
|
2705
|
-
outputs: z19.array(
|
|
2706
|
-
z19.discriminatedUnion("type", [
|
|
2707
|
-
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
2708
|
-
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
2709
|
-
])
|
|
2710
|
-
).nullable()
|
|
2711
|
-
});
|
|
2712
|
-
var localShellCallItem = z19.object({
|
|
2713
|
-
type: z19.literal("local_shell_call"),
|
|
2714
|
-
id: z19.string(),
|
|
2715
|
-
call_id: z19.string(),
|
|
2716
|
-
action: z19.object({
|
|
2717
|
-
type: z19.literal("exec"),
|
|
2718
|
-
command: z19.array(z19.string()),
|
|
2719
|
-
timeout_ms: z19.number().optional(),
|
|
2720
|
-
user: z19.string().optional(),
|
|
2721
|
-
working_directory: z19.string().optional(),
|
|
2722
|
-
env: z19.record(z19.string(), z19.string()).optional()
|
|
2723
|
-
})
|
|
2724
|
-
});
|
|
2725
|
-
var imageGenerationCallItem = z19.object({
|
|
2726
|
-
type: z19.literal("image_generation_call"),
|
|
2727
|
-
id: z19.string(),
|
|
2728
|
-
result: z19.string()
|
|
2729
|
-
});
|
|
2730
|
-
var TOP_LOGPROBS_MAX = 20;
|
|
2731
|
-
var LOGPROBS_SCHEMA = z19.array(
|
|
2732
|
-
z19.object({
|
|
2733
|
-
token: z19.string(),
|
|
2734
|
-
logprob: z19.number(),
|
|
2735
|
-
top_logprobs: z19.array(
|
|
2736
|
-
z19.object({
|
|
2737
|
-
token: z19.string(),
|
|
2738
|
-
logprob: z19.number()
|
|
2739
|
-
})
|
|
2740
|
-
)
|
|
2741
|
-
})
|
|
2742
|
-
);
|
|
2743
3409
|
var OpenAIResponsesLanguageModel = class {
|
|
2744
3410
|
constructor(modelId, config) {
|
|
2745
3411
|
this.specificationVersion = "v2";
|
|
@@ -2931,7 +3597,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2931
3597
|
tools: openaiTools,
|
|
2932
3598
|
toolChoice: openaiToolChoice,
|
|
2933
3599
|
toolWarnings
|
|
2934
|
-
} = prepareResponsesTools({
|
|
3600
|
+
} = await prepareResponsesTools({
|
|
2935
3601
|
tools,
|
|
2936
3602
|
toolChoice,
|
|
2937
3603
|
strictJsonSchema
|
|
@@ -2967,85 +3633,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2967
3633
|
body,
|
|
2968
3634
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2969
3635
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
2970
|
-
|
|
2971
|
-
id: z19.string(),
|
|
2972
|
-
created_at: z19.number(),
|
|
2973
|
-
error: z19.object({
|
|
2974
|
-
code: z19.string(),
|
|
2975
|
-
message: z19.string()
|
|
2976
|
-
}).nullish(),
|
|
2977
|
-
model: z19.string(),
|
|
2978
|
-
output: z19.array(
|
|
2979
|
-
z19.discriminatedUnion("type", [
|
|
2980
|
-
z19.object({
|
|
2981
|
-
type: z19.literal("message"),
|
|
2982
|
-
role: z19.literal("assistant"),
|
|
2983
|
-
id: z19.string(),
|
|
2984
|
-
content: z19.array(
|
|
2985
|
-
z19.object({
|
|
2986
|
-
type: z19.literal("output_text"),
|
|
2987
|
-
text: z19.string(),
|
|
2988
|
-
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2989
|
-
annotations: z19.array(
|
|
2990
|
-
z19.discriminatedUnion("type", [
|
|
2991
|
-
z19.object({
|
|
2992
|
-
type: z19.literal("url_citation"),
|
|
2993
|
-
start_index: z19.number(),
|
|
2994
|
-
end_index: z19.number(),
|
|
2995
|
-
url: z19.string(),
|
|
2996
|
-
title: z19.string()
|
|
2997
|
-
}),
|
|
2998
|
-
z19.object({
|
|
2999
|
-
type: z19.literal("file_citation"),
|
|
3000
|
-
file_id: z19.string(),
|
|
3001
|
-
filename: z19.string().nullish(),
|
|
3002
|
-
index: z19.number().nullish(),
|
|
3003
|
-
start_index: z19.number().nullish(),
|
|
3004
|
-
end_index: z19.number().nullish(),
|
|
3005
|
-
quote: z19.string().nullish()
|
|
3006
|
-
}),
|
|
3007
|
-
z19.object({
|
|
3008
|
-
type: z19.literal("container_file_citation")
|
|
3009
|
-
})
|
|
3010
|
-
])
|
|
3011
|
-
)
|
|
3012
|
-
})
|
|
3013
|
-
)
|
|
3014
|
-
}),
|
|
3015
|
-
webSearchCallItem,
|
|
3016
|
-
fileSearchCallItem,
|
|
3017
|
-
codeInterpreterCallItem,
|
|
3018
|
-
imageGenerationCallItem,
|
|
3019
|
-
localShellCallItem,
|
|
3020
|
-
z19.object({
|
|
3021
|
-
type: z19.literal("function_call"),
|
|
3022
|
-
call_id: z19.string(),
|
|
3023
|
-
name: z19.string(),
|
|
3024
|
-
arguments: z19.string(),
|
|
3025
|
-
id: z19.string()
|
|
3026
|
-
}),
|
|
3027
|
-
z19.object({
|
|
3028
|
-
type: z19.literal("computer_call"),
|
|
3029
|
-
id: z19.string(),
|
|
3030
|
-
status: z19.string().optional()
|
|
3031
|
-
}),
|
|
3032
|
-
z19.object({
|
|
3033
|
-
type: z19.literal("reasoning"),
|
|
3034
|
-
id: z19.string(),
|
|
3035
|
-
encrypted_content: z19.string().nullish(),
|
|
3036
|
-
summary: z19.array(
|
|
3037
|
-
z19.object({
|
|
3038
|
-
type: z19.literal("summary_text"),
|
|
3039
|
-
text: z19.string()
|
|
3040
|
-
})
|
|
3041
|
-
)
|
|
3042
|
-
})
|
|
3043
|
-
])
|
|
3044
|
-
),
|
|
3045
|
-
service_tier: z19.string().nullish(),
|
|
3046
|
-
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
3047
|
-
usage: usageSchema2
|
|
3048
|
-
})
|
|
3636
|
+
openaiResponsesResponseSchema
|
|
3049
3637
|
),
|
|
3050
3638
|
abortSignal: options.abortSignal,
|
|
3051
3639
|
fetch: this.config.fetch
|
|
@@ -3108,7 +3696,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3108
3696
|
type: "tool-call",
|
|
3109
3697
|
toolCallId: part.call_id,
|
|
3110
3698
|
toolName: "local_shell",
|
|
3111
|
-
input: JSON.stringify({
|
|
3699
|
+
input: JSON.stringify({
|
|
3700
|
+
action: part.action
|
|
3701
|
+
}),
|
|
3112
3702
|
providerMetadata: {
|
|
3113
3703
|
openai: {
|
|
3114
3704
|
itemId: part.id
|
|
@@ -3362,7 +3952,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3362
3952
|
controller.enqueue({
|
|
3363
3953
|
type: "tool-input-start",
|
|
3364
3954
|
id: value.item.id,
|
|
3365
|
-
toolName: webSearchToolName != null ? webSearchToolName : "web_search"
|
|
3955
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3956
|
+
providerExecuted: true
|
|
3366
3957
|
});
|
|
3367
3958
|
} else if (value.item.type === "computer_call") {
|
|
3368
3959
|
ongoingToolCalls[value.output_index] = {
|
|
@@ -3372,7 +3963,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3372
3963
|
controller.enqueue({
|
|
3373
3964
|
type: "tool-input-start",
|
|
3374
3965
|
id: value.item.id,
|
|
3375
|
-
toolName: "computer_use"
|
|
3966
|
+
toolName: "computer_use",
|
|
3967
|
+
providerExecuted: true
|
|
3376
3968
|
});
|
|
3377
3969
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3378
3970
|
ongoingToolCalls[value.output_index] = {
|
|
@@ -3385,7 +3977,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3385
3977
|
controller.enqueue({
|
|
3386
3978
|
type: "tool-input-start",
|
|
3387
3979
|
id: value.item.id,
|
|
3388
|
-
toolName: "code_interpreter"
|
|
3980
|
+
toolName: "code_interpreter",
|
|
3981
|
+
providerExecuted: true
|
|
3389
3982
|
});
|
|
3390
3983
|
controller.enqueue({
|
|
3391
3984
|
type: "tool-input-delta",
|
|
@@ -3725,196 +4318,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3725
4318
|
};
|
|
3726
4319
|
}
|
|
3727
4320
|
};
|
|
3728
|
-
var usageSchema2 = z19.object({
|
|
3729
|
-
input_tokens: z19.number(),
|
|
3730
|
-
input_tokens_details: z19.object({ cached_tokens: z19.number().nullish() }).nullish(),
|
|
3731
|
-
output_tokens: z19.number(),
|
|
3732
|
-
output_tokens_details: z19.object({ reasoning_tokens: z19.number().nullish() }).nullish()
|
|
3733
|
-
});
|
|
3734
|
-
var textDeltaChunkSchema = z19.object({
|
|
3735
|
-
type: z19.literal("response.output_text.delta"),
|
|
3736
|
-
item_id: z19.string(),
|
|
3737
|
-
delta: z19.string(),
|
|
3738
|
-
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3739
|
-
});
|
|
3740
|
-
var errorChunkSchema = z19.object({
|
|
3741
|
-
type: z19.literal("error"),
|
|
3742
|
-
code: z19.string(),
|
|
3743
|
-
message: z19.string(),
|
|
3744
|
-
param: z19.string().nullish(),
|
|
3745
|
-
sequence_number: z19.number()
|
|
3746
|
-
});
|
|
3747
|
-
var responseFinishedChunkSchema = z19.object({
|
|
3748
|
-
type: z19.enum(["response.completed", "response.incomplete"]),
|
|
3749
|
-
response: z19.object({
|
|
3750
|
-
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
3751
|
-
usage: usageSchema2,
|
|
3752
|
-
service_tier: z19.string().nullish()
|
|
3753
|
-
})
|
|
3754
|
-
});
|
|
3755
|
-
var responseCreatedChunkSchema = z19.object({
|
|
3756
|
-
type: z19.literal("response.created"),
|
|
3757
|
-
response: z19.object({
|
|
3758
|
-
id: z19.string(),
|
|
3759
|
-
created_at: z19.number(),
|
|
3760
|
-
model: z19.string(),
|
|
3761
|
-
service_tier: z19.string().nullish()
|
|
3762
|
-
})
|
|
3763
|
-
});
|
|
3764
|
-
var responseOutputItemAddedSchema = z19.object({
|
|
3765
|
-
type: z19.literal("response.output_item.added"),
|
|
3766
|
-
output_index: z19.number(),
|
|
3767
|
-
item: z19.discriminatedUnion("type", [
|
|
3768
|
-
z19.object({
|
|
3769
|
-
type: z19.literal("message"),
|
|
3770
|
-
id: z19.string()
|
|
3771
|
-
}),
|
|
3772
|
-
z19.object({
|
|
3773
|
-
type: z19.literal("reasoning"),
|
|
3774
|
-
id: z19.string(),
|
|
3775
|
-
encrypted_content: z19.string().nullish()
|
|
3776
|
-
}),
|
|
3777
|
-
z19.object({
|
|
3778
|
-
type: z19.literal("function_call"),
|
|
3779
|
-
id: z19.string(),
|
|
3780
|
-
call_id: z19.string(),
|
|
3781
|
-
name: z19.string(),
|
|
3782
|
-
arguments: z19.string()
|
|
3783
|
-
}),
|
|
3784
|
-
z19.object({
|
|
3785
|
-
type: z19.literal("web_search_call"),
|
|
3786
|
-
id: z19.string(),
|
|
3787
|
-
status: z19.string(),
|
|
3788
|
-
action: z19.object({
|
|
3789
|
-
type: z19.literal("search"),
|
|
3790
|
-
query: z19.string().optional()
|
|
3791
|
-
}).nullish()
|
|
3792
|
-
}),
|
|
3793
|
-
z19.object({
|
|
3794
|
-
type: z19.literal("computer_call"),
|
|
3795
|
-
id: z19.string(),
|
|
3796
|
-
status: z19.string()
|
|
3797
|
-
}),
|
|
3798
|
-
z19.object({
|
|
3799
|
-
type: z19.literal("file_search_call"),
|
|
3800
|
-
id: z19.string()
|
|
3801
|
-
}),
|
|
3802
|
-
z19.object({
|
|
3803
|
-
type: z19.literal("image_generation_call"),
|
|
3804
|
-
id: z19.string()
|
|
3805
|
-
}),
|
|
3806
|
-
z19.object({
|
|
3807
|
-
type: z19.literal("code_interpreter_call"),
|
|
3808
|
-
id: z19.string(),
|
|
3809
|
-
container_id: z19.string(),
|
|
3810
|
-
code: z19.string().nullable(),
|
|
3811
|
-
outputs: z19.array(
|
|
3812
|
-
z19.discriminatedUnion("type", [
|
|
3813
|
-
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
3814
|
-
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
3815
|
-
])
|
|
3816
|
-
).nullable(),
|
|
3817
|
-
status: z19.string()
|
|
3818
|
-
})
|
|
3819
|
-
])
|
|
3820
|
-
});
|
|
3821
|
-
var responseOutputItemDoneSchema = z19.object({
|
|
3822
|
-
type: z19.literal("response.output_item.done"),
|
|
3823
|
-
output_index: z19.number(),
|
|
3824
|
-
item: z19.discriminatedUnion("type", [
|
|
3825
|
-
z19.object({
|
|
3826
|
-
type: z19.literal("message"),
|
|
3827
|
-
id: z19.string()
|
|
3828
|
-
}),
|
|
3829
|
-
z19.object({
|
|
3830
|
-
type: z19.literal("reasoning"),
|
|
3831
|
-
id: z19.string(),
|
|
3832
|
-
encrypted_content: z19.string().nullish()
|
|
3833
|
-
}),
|
|
3834
|
-
z19.object({
|
|
3835
|
-
type: z19.literal("function_call"),
|
|
3836
|
-
id: z19.string(),
|
|
3837
|
-
call_id: z19.string(),
|
|
3838
|
-
name: z19.string(),
|
|
3839
|
-
arguments: z19.string(),
|
|
3840
|
-
status: z19.literal("completed")
|
|
3841
|
-
}),
|
|
3842
|
-
codeInterpreterCallItem,
|
|
3843
|
-
imageGenerationCallItem,
|
|
3844
|
-
webSearchCallItem,
|
|
3845
|
-
fileSearchCallItem,
|
|
3846
|
-
localShellCallItem,
|
|
3847
|
-
z19.object({
|
|
3848
|
-
type: z19.literal("computer_call"),
|
|
3849
|
-
id: z19.string(),
|
|
3850
|
-
status: z19.literal("completed")
|
|
3851
|
-
})
|
|
3852
|
-
])
|
|
3853
|
-
});
|
|
3854
|
-
var responseFunctionCallArgumentsDeltaSchema = z19.object({
|
|
3855
|
-
type: z19.literal("response.function_call_arguments.delta"),
|
|
3856
|
-
item_id: z19.string(),
|
|
3857
|
-
output_index: z19.number(),
|
|
3858
|
-
delta: z19.string()
|
|
3859
|
-
});
|
|
3860
|
-
var responseCodeInterpreterCallCodeDeltaSchema = z19.object({
|
|
3861
|
-
type: z19.literal("response.code_interpreter_call_code.delta"),
|
|
3862
|
-
item_id: z19.string(),
|
|
3863
|
-
output_index: z19.number(),
|
|
3864
|
-
delta: z19.string()
|
|
3865
|
-
});
|
|
3866
|
-
var responseCodeInterpreterCallCodeDoneSchema = z19.object({
|
|
3867
|
-
type: z19.literal("response.code_interpreter_call_code.done"),
|
|
3868
|
-
item_id: z19.string(),
|
|
3869
|
-
output_index: z19.number(),
|
|
3870
|
-
code: z19.string()
|
|
3871
|
-
});
|
|
3872
|
-
var responseAnnotationAddedSchema = z19.object({
|
|
3873
|
-
type: z19.literal("response.output_text.annotation.added"),
|
|
3874
|
-
annotation: z19.discriminatedUnion("type", [
|
|
3875
|
-
z19.object({
|
|
3876
|
-
type: z19.literal("url_citation"),
|
|
3877
|
-
url: z19.string(),
|
|
3878
|
-
title: z19.string()
|
|
3879
|
-
}),
|
|
3880
|
-
z19.object({
|
|
3881
|
-
type: z19.literal("file_citation"),
|
|
3882
|
-
file_id: z19.string(),
|
|
3883
|
-
filename: z19.string().nullish(),
|
|
3884
|
-
index: z19.number().nullish(),
|
|
3885
|
-
start_index: z19.number().nullish(),
|
|
3886
|
-
end_index: z19.number().nullish(),
|
|
3887
|
-
quote: z19.string().nullish()
|
|
3888
|
-
})
|
|
3889
|
-
])
|
|
3890
|
-
});
|
|
3891
|
-
var responseReasoningSummaryPartAddedSchema = z19.object({
|
|
3892
|
-
type: z19.literal("response.reasoning_summary_part.added"),
|
|
3893
|
-
item_id: z19.string(),
|
|
3894
|
-
summary_index: z19.number()
|
|
3895
|
-
});
|
|
3896
|
-
var responseReasoningSummaryTextDeltaSchema = z19.object({
|
|
3897
|
-
type: z19.literal("response.reasoning_summary_text.delta"),
|
|
3898
|
-
item_id: z19.string(),
|
|
3899
|
-
summary_index: z19.number(),
|
|
3900
|
-
delta: z19.string()
|
|
3901
|
-
});
|
|
3902
|
-
var openaiResponsesChunkSchema = z19.union([
|
|
3903
|
-
textDeltaChunkSchema,
|
|
3904
|
-
responseFinishedChunkSchema,
|
|
3905
|
-
responseCreatedChunkSchema,
|
|
3906
|
-
responseOutputItemAddedSchema,
|
|
3907
|
-
responseOutputItemDoneSchema,
|
|
3908
|
-
responseFunctionCallArgumentsDeltaSchema,
|
|
3909
|
-
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3910
|
-
responseCodeInterpreterCallCodeDoneSchema,
|
|
3911
|
-
responseAnnotationAddedSchema,
|
|
3912
|
-
responseReasoningSummaryPartAddedSchema,
|
|
3913
|
-
responseReasoningSummaryTextDeltaSchema,
|
|
3914
|
-
errorChunkSchema,
|
|
3915
|
-
z19.object({ type: z19.string() }).loose()
|
|
3916
|
-
// fallback for unknown chunks
|
|
3917
|
-
]);
|
|
3918
4321
|
function isTextDeltaChunk(chunk) {
|
|
3919
4322
|
return chunk.type === "response.output_text.delta";
|
|
3920
4323
|
}
|
|
@@ -3991,47 +4394,6 @@ function getResponsesModelConfig(modelId) {
|
|
|
3991
4394
|
isReasoningModel: false
|
|
3992
4395
|
};
|
|
3993
4396
|
}
|
|
3994
|
-
var openaiResponsesProviderOptionsSchema = z19.object({
|
|
3995
|
-
include: z19.array(
|
|
3996
|
-
z19.enum([
|
|
3997
|
-
"reasoning.encrypted_content",
|
|
3998
|
-
"file_search_call.results",
|
|
3999
|
-
"message.output_text.logprobs"
|
|
4000
|
-
])
|
|
4001
|
-
).nullish(),
|
|
4002
|
-
instructions: z19.string().nullish(),
|
|
4003
|
-
/**
|
|
4004
|
-
* Return the log probabilities of the tokens.
|
|
4005
|
-
*
|
|
4006
|
-
* Setting to true will return the log probabilities of the tokens that
|
|
4007
|
-
* were generated.
|
|
4008
|
-
*
|
|
4009
|
-
* Setting to a number will return the log probabilities of the top n
|
|
4010
|
-
* tokens that were generated.
|
|
4011
|
-
*
|
|
4012
|
-
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
4013
|
-
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
4014
|
-
*/
|
|
4015
|
-
logprobs: z19.union([z19.boolean(), z19.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
4016
|
-
/**
|
|
4017
|
-
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
4018
|
-
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
4019
|
-
* Any further attempts to call a tool by the model will be ignored.
|
|
4020
|
-
*/
|
|
4021
|
-
maxToolCalls: z19.number().nullish(),
|
|
4022
|
-
metadata: z19.any().nullish(),
|
|
4023
|
-
parallelToolCalls: z19.boolean().nullish(),
|
|
4024
|
-
previousResponseId: z19.string().nullish(),
|
|
4025
|
-
promptCacheKey: z19.string().nullish(),
|
|
4026
|
-
reasoningEffort: z19.string().nullish(),
|
|
4027
|
-
reasoningSummary: z19.string().nullish(),
|
|
4028
|
-
safetyIdentifier: z19.string().nullish(),
|
|
4029
|
-
serviceTier: z19.enum(["auto", "flex", "priority"]).nullish(),
|
|
4030
|
-
store: z19.boolean().nullish(),
|
|
4031
|
-
strictJsonSchema: z19.boolean().nullish(),
|
|
4032
|
-
textVerbosity: z19.enum(["low", "medium", "high"]).nullish(),
|
|
4033
|
-
user: z19.string().nullish()
|
|
4034
|
-
});
|
|
4035
4397
|
export {
|
|
4036
4398
|
OpenAIChatLanguageModel,
|
|
4037
4399
|
OpenAICompletionLanguageModel,
|
|
@@ -4056,6 +4418,7 @@ export {
|
|
|
4056
4418
|
openAITranscriptionProviderOptions,
|
|
4057
4419
|
openaiChatLanguageModelOptions,
|
|
4058
4420
|
openaiCompletionProviderOptions,
|
|
4059
|
-
openaiEmbeddingProviderOptions
|
|
4421
|
+
openaiEmbeddingProviderOptions,
|
|
4422
|
+
openaiSpeechProviderOptionsSchema
|
|
4060
4423
|
};
|
|
4061
4424
|
//# sourceMappingURL=index.mjs.map
|