@ai-sdk/openai 2.1.0-beta.9 → 3.0.0-beta.18

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