@ai-sdk/openai 2.0.135 → 2.0.137

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/dist/index.mjs CHANGED
@@ -22,8 +22,12 @@ import {
22
22
 
23
23
  // src/openai-error.ts
24
24
  import { z } from "zod/v4";
25
- import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
26
- var openaiErrorDataSchema = z.object({
25
+ import {
26
+ lazySchema,
27
+ zodSchema,
28
+ createJsonErrorResponseHandler
29
+ } from "@ai-sdk/provider-utils";
30
+ var openaiErrorDataSchema = () => z.object({
27
31
  error: z.object({
28
32
  message: z.string(),
29
33
  // The additional information below is handled loosely to support
@@ -34,8 +38,11 @@ var openaiErrorDataSchema = z.object({
34
38
  code: z.union([z.string(), z.number()]).nullish()
35
39
  })
36
40
  });
41
+ var openaiErrorDataSchemaValidator = lazySchema(
42
+ () => zodSchema(openaiErrorDataSchema())
43
+ );
37
44
  var openaiFailedResponseHandler = createJsonErrorResponseHandler({
38
- errorSchema: openaiErrorDataSchema,
45
+ errorSchema: openaiErrorDataSchemaValidator,
39
46
  errorToMessage: (data) => data.error.message
40
47
  });
41
48
 
@@ -368,11 +375,11 @@ function mapOpenAIFinishReason(finishReason) {
368
375
  // src/chat/openai-chat-api.ts
369
376
  import {
370
377
  lazyValidator,
371
- zodSchema
378
+ zodSchema as zodSchema2
372
379
  } from "@ai-sdk/provider-utils";
373
380
  import { z as z2 } from "zod/v4";
374
381
  var openaiChatResponseSchema = lazyValidator(
375
- () => zodSchema(
382
+ () => zodSchema2(
376
383
  z2.object({
377
384
  id: z2.string().nullish(),
378
385
  created: z2.number().nullish(),
@@ -443,7 +450,7 @@ var openaiChatResponseSchema = lazyValidator(
443
450
  )
444
451
  );
445
452
  var openaiChatChunkSchema = lazyValidator(
446
- () => zodSchema(
453
+ () => zodSchema2(
447
454
  z2.union([
448
455
  z2.object({
449
456
  id: z2.string().nullish(),
@@ -510,7 +517,7 @@ var openaiChatChunkSchema = lazyValidator(
510
517
  }).nullish()
511
518
  }).nullish()
512
519
  }),
513
- openaiErrorDataSchema
520
+ openaiErrorDataSchema()
514
521
  ])
515
522
  )
516
523
  );
@@ -518,11 +525,11 @@ var openaiChatChunkSchema = lazyValidator(
518
525
  // src/chat/openai-chat-options.ts
519
526
  import {
520
527
  lazyValidator as lazyValidator2,
521
- zodSchema as zodSchema2
528
+ zodSchema as zodSchema3
522
529
  } from "@ai-sdk/provider-utils";
523
530
  import { z as z3 } from "zod/v4";
524
531
  var openaiChatLanguageModelOptions = lazyValidator2(
525
- () => zodSchema2(
532
+ () => zodSchema3(
526
533
  z3.object({
527
534
  /**
528
535
  * Modify the likelihood of specified tokens appearing in the completion.
@@ -1278,10 +1285,10 @@ function mapOpenAIFinishReason2(finishReason) {
1278
1285
  import { z as z4 } from "zod/v4";
1279
1286
  import {
1280
1287
  lazyValidator as lazyValidator3,
1281
- zodSchema as zodSchema3
1288
+ zodSchema as zodSchema4
1282
1289
  } from "@ai-sdk/provider-utils";
1283
1290
  var openaiCompletionResponseSchema = lazyValidator3(
1284
- () => zodSchema3(
1291
+ () => zodSchema4(
1285
1292
  z4.object({
1286
1293
  id: z4.string().nullish(),
1287
1294
  created: z4.number().nullish(),
@@ -1306,7 +1313,7 @@ var openaiCompletionResponseSchema = lazyValidator3(
1306
1313
  )
1307
1314
  );
1308
1315
  var openaiCompletionChunkSchema = lazyValidator3(
1309
- () => zodSchema3(
1316
+ () => zodSchema4(
1310
1317
  z4.union([
1311
1318
  z4.object({
1312
1319
  id: z4.string().nullish(),
@@ -1330,7 +1337,7 @@ var openaiCompletionChunkSchema = lazyValidator3(
1330
1337
  total_tokens: z4.number()
1331
1338
  }).nullish()
1332
1339
  }),
1333
- openaiErrorDataSchema
1340
+ openaiErrorDataSchema()
1334
1341
  ])
1335
1342
  )
1336
1343
  );
@@ -1338,11 +1345,11 @@ var openaiCompletionChunkSchema = lazyValidator3(
1338
1345
  // src/completion/openai-completion-options.ts
1339
1346
  import {
1340
1347
  lazyValidator as lazyValidator4,
1341
- zodSchema as zodSchema4
1348
+ zodSchema as zodSchema5
1342
1349
  } from "@ai-sdk/provider-utils";
1343
1350
  import { z as z5 } from "zod/v4";
1344
1351
  var openaiCompletionProviderOptions = lazyValidator4(
1345
- () => zodSchema4(
1352
+ () => zodSchema5(
1346
1353
  z5.object({
1347
1354
  /**
1348
1355
  Echo back the prompt in addition to the completion.
@@ -1631,11 +1638,11 @@ import {
1631
1638
  // src/embedding/openai-embedding-options.ts
1632
1639
  import {
1633
1640
  lazyValidator as lazyValidator5,
1634
- zodSchema as zodSchema5
1641
+ zodSchema as zodSchema6
1635
1642
  } from "@ai-sdk/provider-utils";
1636
1643
  import { z as z6 } from "zod/v4";
1637
1644
  var openaiEmbeddingProviderOptions = lazyValidator5(
1638
- () => zodSchema5(
1645
+ () => zodSchema6(
1639
1646
  z6.object({
1640
1647
  /**
1641
1648
  The number of dimensions the resulting output embeddings should have.
@@ -1652,10 +1659,10 @@ var openaiEmbeddingProviderOptions = lazyValidator5(
1652
1659
  );
1653
1660
 
1654
1661
  // src/embedding/openai-embedding-api.ts
1655
- import { lazyValidator as lazyValidator6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
1662
+ import { lazyValidator as lazyValidator6, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
1656
1663
  import { z as z7 } from "zod/v4";
1657
1664
  var openaiTextEmbeddingResponseSchema = lazyValidator6(
1658
- () => zodSchema6(
1665
+ () => zodSchema7(
1659
1666
  z7.object({
1660
1667
  data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1661
1668
  usage: z7.object({ prompt_tokens: z7.number() }).nullish()
@@ -1739,10 +1746,10 @@ import {
1739
1746
  } from "@ai-sdk/provider-utils";
1740
1747
 
1741
1748
  // src/image/openai-image-api.ts
1742
- import { lazyValidator as lazyValidator7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
1749
+ import { lazyValidator as lazyValidator7, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
1743
1750
  import { z as z8 } from "zod/v4";
1744
1751
  var openaiImageResponseSchema = lazyValidator7(
1745
- () => zodSchema7(
1752
+ () => zodSchema8(
1746
1753
  z8.object({
1747
1754
  created: z8.number().nullish(),
1748
1755
  data: z8.array(
@@ -1771,7 +1778,7 @@ var openaiImageResponseSchema = lazyValidator7(
1771
1778
  // src/image/openai-image-options.ts
1772
1779
  import {
1773
1780
  lazyValidator as lazyValidator8,
1774
- zodSchema as zodSchema8
1781
+ zodSchema as zodSchema9
1775
1782
  } from "@ai-sdk/provider-utils";
1776
1783
  import { z as z9 } from "zod/v4";
1777
1784
  var modelMaxImagesPerCall = {
@@ -1792,7 +1799,7 @@ function getMaxImagesPerCall(modelId) {
1792
1799
  var _a2;
1793
1800
  return (_a2 = modelMaxImagesPerCall[modelId]) != null ? _a2 : modelId.startsWith("gpt-image-") ? 10 : 1;
1794
1801
  }
1795
- var baseImageModelOptionsObject = z9.object({
1802
+ var baseImageModelOptionsObject = () => z9.object({
1796
1803
  /**
1797
1804
  * Quality of the generated image(s).
1798
1805
  *
@@ -1822,11 +1829,11 @@ var baseImageModelOptionsObject = z9.object({
1822
1829
  user: z9.string().optional()
1823
1830
  });
1824
1831
  var openaiImageModelOptions = lazyValidator8(
1825
- () => zodSchema8(baseImageModelOptionsObject)
1832
+ () => zodSchema9(baseImageModelOptionsObject())
1826
1833
  );
1827
1834
  var openaiImageModelGenerationOptions = lazyValidator8(
1828
- () => zodSchema8(
1829
- baseImageModelOptionsObject.extend({
1835
+ () => zodSchema9(
1836
+ baseImageModelOptionsObject().extend({
1830
1837
  /**
1831
1838
  * Style of the generated image. `vivid` produces hyper-real and
1832
1839
  * dramatic images; `natural` produces more subdued, less hyper-real
@@ -1970,20 +1977,20 @@ function distributeTokenDetails(usage, index, total) {
1970
1977
  // src/tool/code-interpreter.ts
1971
1978
  import {
1972
1979
  createProviderDefinedToolFactoryWithOutputSchema,
1973
- lazySchema,
1974
- zodSchema as zodSchema9
1980
+ lazySchema as lazySchema2,
1981
+ zodSchema as zodSchema10
1975
1982
  } from "@ai-sdk/provider-utils";
1976
1983
  import { z as z10 } from "zod/v4";
1977
- var codeInterpreterInputSchema = lazySchema(
1978
- () => zodSchema9(
1984
+ var codeInterpreterInputSchema = lazySchema2(
1985
+ () => zodSchema10(
1979
1986
  z10.object({
1980
1987
  code: z10.string().nullish(),
1981
1988
  containerId: z10.string()
1982
1989
  })
1983
1990
  )
1984
1991
  );
1985
- var codeInterpreterOutputSchema = lazySchema(
1986
- () => zodSchema9(
1992
+ var codeInterpreterOutputSchema = lazySchema2(
1993
+ () => zodSchema10(
1987
1994
  z10.object({
1988
1995
  outputs: z10.array(
1989
1996
  z10.discriminatedUnion("type", [
@@ -1994,8 +2001,8 @@ var codeInterpreterOutputSchema = lazySchema(
1994
2001
  })
1995
2002
  )
1996
2003
  );
1997
- var codeInterpreterArgsSchema = lazySchema(
1998
- () => zodSchema9(
2004
+ var codeInterpreterArgsSchema = lazySchema2(
2005
+ () => zodSchema10(
1999
2006
  z10.object({
2000
2007
  container: z10.union([
2001
2008
  z10.string(),
@@ -2019,23 +2026,24 @@ var codeInterpreter = (args = {}) => {
2019
2026
  // src/tool/file-search.ts
2020
2027
  import {
2021
2028
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
2022
- lazySchema as lazySchema2,
2023
- zodSchema as zodSchema10
2029
+ lazySchema as lazySchema3,
2030
+ zodSchema as zodSchema11
2024
2031
  } from "@ai-sdk/provider-utils";
2025
2032
  import { z as z11 } from "zod/v4";
2026
- var comparisonFilterSchema = z11.object({
2033
+ var comparisonFilterSchema = () => z11.object({
2027
2034
  key: z11.string(),
2028
2035
  type: z11.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
2029
2036
  value: z11.union([z11.string(), z11.number(), z11.boolean(), z11.array(z11.string())])
2030
2037
  });
2031
- var compoundFilterSchema = z11.object({
2038
+ var cachedCompoundFilterSchema;
2039
+ var compoundFilterSchema = () => cachedCompoundFilterSchema != null ? cachedCompoundFilterSchema : cachedCompoundFilterSchema = z11.object({
2032
2040
  type: z11.enum(["and", "or"]),
2033
2041
  filters: z11.array(
2034
- z11.union([comparisonFilterSchema, z11.lazy(() => compoundFilterSchema)])
2042
+ z11.union([comparisonFilterSchema(), z11.lazy(() => compoundFilterSchema())])
2035
2043
  )
2036
2044
  });
2037
- var fileSearchArgsSchema = lazySchema2(
2038
- () => zodSchema10(
2045
+ var fileSearchArgsSchema = lazySchema3(
2046
+ () => zodSchema11(
2039
2047
  z11.object({
2040
2048
  vectorStoreIds: z11.array(z11.string()),
2041
2049
  maxNumResults: z11.number().optional(),
@@ -2043,12 +2051,12 @@ var fileSearchArgsSchema = lazySchema2(
2043
2051
  ranker: z11.string().optional(),
2044
2052
  scoreThreshold: z11.number().optional()
2045
2053
  }).optional(),
2046
- filters: z11.union([comparisonFilterSchema, compoundFilterSchema]).optional()
2054
+ filters: z11.union([comparisonFilterSchema(), compoundFilterSchema()]).optional()
2047
2055
  })
2048
2056
  )
2049
2057
  );
2050
- var fileSearchOutputSchema = lazySchema2(
2051
- () => zodSchema10(
2058
+ var fileSearchOutputSchema = lazySchema3(
2059
+ () => zodSchema11(
2052
2060
  z11.object({
2053
2061
  queries: z11.array(z11.string()),
2054
2062
  results: z11.array(
@@ -2073,12 +2081,12 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema2({
2073
2081
  // src/tool/image-generation.ts
2074
2082
  import {
2075
2083
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
2076
- lazySchema as lazySchema3,
2077
- zodSchema as zodSchema11
2084
+ lazySchema as lazySchema4,
2085
+ zodSchema as zodSchema12
2078
2086
  } from "@ai-sdk/provider-utils";
2079
2087
  import { z as z12 } from "zod/v4";
2080
- var imageGenerationArgsSchema = lazySchema3(
2081
- () => zodSchema11(
2088
+ var imageGenerationArgsSchema = lazySchema4(
2089
+ () => zodSchema12(
2082
2090
  z12.object({
2083
2091
  background: z12.enum(["auto", "opaque", "transparent"]).optional(),
2084
2092
  inputFidelity: z12.enum(["low", "high"]).optional(),
@@ -2096,9 +2104,9 @@ var imageGenerationArgsSchema = lazySchema3(
2096
2104
  }).strict()
2097
2105
  )
2098
2106
  );
2099
- var imageGenerationInputSchema = lazySchema3(() => zodSchema11(z12.object({})));
2100
- var imageGenerationOutputSchema = lazySchema3(
2101
- () => zodSchema11(z12.object({ result: z12.string() }))
2107
+ var imageGenerationInputSchema = lazySchema4(() => zodSchema12(z12.object({})));
2108
+ var imageGenerationOutputSchema = lazySchema4(
2109
+ () => zodSchema12(z12.object({ result: z12.string() }))
2102
2110
  );
2103
2111
  var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
2104
2112
  id: "openai.image_generation",
@@ -2113,12 +2121,12 @@ var imageGeneration = (args = {}) => {
2113
2121
  // src/tool/local-shell.ts
2114
2122
  import {
2115
2123
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
2116
- lazySchema as lazySchema4,
2117
- zodSchema as zodSchema12
2124
+ lazySchema as lazySchema5,
2125
+ zodSchema as zodSchema13
2118
2126
  } from "@ai-sdk/provider-utils";
2119
2127
  import { z as z13 } from "zod/v4";
2120
- var localShellInputSchema = lazySchema4(
2121
- () => zodSchema12(
2128
+ var localShellInputSchema = lazySchema5(
2129
+ () => zodSchema13(
2122
2130
  z13.object({
2123
2131
  action: z13.object({
2124
2132
  type: z13.literal("exec"),
@@ -2131,8 +2139,8 @@ var localShellInputSchema = lazySchema4(
2131
2139
  })
2132
2140
  )
2133
2141
  );
2134
- var localShellOutputSchema = lazySchema4(
2135
- () => zodSchema12(z13.object({ output: z13.string() }))
2142
+ var localShellOutputSchema = lazySchema5(
2143
+ () => zodSchema13(z13.object({ output: z13.string() }))
2136
2144
  );
2137
2145
  var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
2138
2146
  id: "openai.local_shell",
@@ -2144,12 +2152,12 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
2144
2152
  // src/tool/web-search.ts
2145
2153
  import {
2146
2154
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
2147
- lazySchema as lazySchema5,
2148
- zodSchema as zodSchema13
2155
+ lazySchema as lazySchema6,
2156
+ zodSchema as zodSchema14
2149
2157
  } from "@ai-sdk/provider-utils";
2150
2158
  import { z as z14 } from "zod/v4";
2151
- var webSearchArgsSchema = lazySchema5(
2152
- () => zodSchema13(
2159
+ var webSearchArgsSchema = lazySchema6(
2160
+ () => zodSchema14(
2153
2161
  z14.object({
2154
2162
  externalWebAccess: z14.boolean().optional(),
2155
2163
  filters: z14.object({
@@ -2167,9 +2175,9 @@ var webSearchArgsSchema = lazySchema5(
2167
2175
  })
2168
2176
  )
2169
2177
  );
2170
- var webSearchInputSchema = lazySchema5(() => zodSchema13(z14.object({})));
2171
- var webSearchOutputSchema = lazySchema5(
2172
- () => zodSchema13(
2178
+ var webSearchInputSchema = lazySchema6(() => zodSchema14(z14.object({})));
2179
+ var webSearchOutputSchema = lazySchema6(
2180
+ () => zodSchema14(
2173
2181
  z14.object({
2174
2182
  action: z14.discriminatedUnion("type", [
2175
2183
  z14.object({
@@ -2206,12 +2214,12 @@ var webSearch = (args = {}) => webSearchToolFactory(args);
2206
2214
  // src/tool/web-search-preview.ts
2207
2215
  import {
2208
2216
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
2209
- lazySchema as lazySchema6,
2210
- zodSchema as zodSchema14
2217
+ lazySchema as lazySchema7,
2218
+ zodSchema as zodSchema15
2211
2219
  } from "@ai-sdk/provider-utils";
2212
2220
  import { z as z15 } from "zod/v4";
2213
- var webSearchPreviewArgsSchema = lazySchema6(
2214
- () => zodSchema14(
2221
+ var webSearchPreviewArgsSchema = lazySchema7(
2222
+ () => zodSchema15(
2215
2223
  z15.object({
2216
2224
  searchContextSize: z15.enum(["low", "medium", "high"]).optional(),
2217
2225
  userLocation: z15.object({
@@ -2224,11 +2232,11 @@ var webSearchPreviewArgsSchema = lazySchema6(
2224
2232
  })
2225
2233
  )
2226
2234
  );
2227
- var webSearchPreviewInputSchema = lazySchema6(
2228
- () => zodSchema14(z15.object({}))
2235
+ var webSearchPreviewInputSchema = lazySchema7(
2236
+ () => zodSchema15(z15.object({}))
2229
2237
  );
2230
- var webSearchPreviewOutputSchema = lazySchema6(
2231
- () => zodSchema14(
2238
+ var webSearchPreviewOutputSchema = lazySchema7(
2239
+ () => zodSchema15(
2232
2240
  z15.object({
2233
2241
  action: z15.discriminatedUnion("type", [
2234
2242
  z15.object({
@@ -2347,6 +2355,8 @@ import {
2347
2355
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
2348
2356
  } from "@ai-sdk/provider";
2349
2357
  import {
2358
+ lazySchema as lazySchema8,
2359
+ zodSchema as zodSchema17,
2350
2360
  convertToBase64 as convertToBase642,
2351
2361
  parseProviderOptions as parseProviderOptions5,
2352
2362
  safeValidateTypes,
@@ -2357,7 +2367,7 @@ import { z as z17 } from "zod/v4";
2357
2367
  // src/responses/openai-responses-options.ts
2358
2368
  import {
2359
2369
  lazyValidator as lazyValidator9,
2360
- zodSchema as zodSchema15
2370
+ zodSchema as zodSchema16
2361
2371
  } from "@ai-sdk/provider-utils";
2362
2372
  import { z as z16 } from "zod/v4";
2363
2373
  var TOP_LOGPROBS_MAX = 20;
@@ -2450,7 +2460,7 @@ var openaiResponsesModelIds = [
2450
2460
  ...openaiResponsesReasoningModelIds
2451
2461
  ];
2452
2462
  var openaiResponsesProviderOptionsSchema = lazyValidator9(
2453
- () => zodSchema15(
2463
+ () => zodSchema16(
2454
2464
  z16.object({
2455
2465
  conversation: z16.string().nullish(),
2456
2466
  include: z16.array(
@@ -2544,7 +2554,7 @@ var openaiResponsesProviderOptionsSchema = lazyValidator9(
2544
2554
  )
2545
2555
  );
2546
2556
  var openaiResponsesSystemMessageOptionsSchema = lazyValidator9(
2547
- () => zodSchema15(
2557
+ () => zodSchema16(
2548
2558
  z16.object({
2549
2559
  /**
2550
2560
  * Emit a configuration update at this position in Responses history.
@@ -3027,10 +3037,14 @@ async function convertToOpenAIResponsesInput({
3027
3037
  }
3028
3038
  return { input, warnings };
3029
3039
  }
3030
- var openaiResponsesReasoningProviderOptionsSchema = z17.object({
3031
- itemId: z17.string().nullish(),
3032
- reasoningEncryptedContent: z17.string().nullish()
3033
- });
3040
+ var openaiResponsesReasoningProviderOptionsSchema = lazySchema8(
3041
+ () => zodSchema17(
3042
+ z17.object({
3043
+ itemId: z17.string().nullish(),
3044
+ reasoningEncryptedContent: z17.string().nullish()
3045
+ })
3046
+ )
3047
+ );
3034
3048
 
3035
3049
  // src/responses/map-openai-responses-finish-reason.ts
3036
3050
  function mapOpenAIResponseFinishReason({
@@ -3053,11 +3067,11 @@ function mapOpenAIResponseFinishReason({
3053
3067
  // src/responses/openai-responses-api.ts
3054
3068
  import {
3055
3069
  lazyValidator as lazyValidator10,
3056
- zodSchema as zodSchema16
3070
+ zodSchema as zodSchema18
3057
3071
  } from "@ai-sdk/provider-utils";
3058
3072
  import { z as z18 } from "zod/v4";
3059
3073
  var openaiResponsesChunkSchema = lazyValidator10(
3060
- () => zodSchema16(
3074
+ () => zodSchema18(
3061
3075
  z18.union([
3062
3076
  z18.object({
3063
3077
  type: z18.literal("response.output_text.delta"),
@@ -3344,7 +3358,7 @@ var openaiResponsesChunkSchema = lazyValidator10(
3344
3358
  )
3345
3359
  );
3346
3360
  var openaiResponsesResponseSchema = lazyValidator10(
3347
- () => zodSchema16(
3361
+ () => zodSchema18(
3348
3362
  z18.object({
3349
3363
  id: z18.string().optional(),
3350
3364
  created_at: z18.number().optional(),
@@ -4950,11 +4964,11 @@ import {
4950
4964
  // src/speech/openai-speech-options.ts
4951
4965
  import {
4952
4966
  lazyValidator as lazyValidator11,
4953
- zodSchema as zodSchema17
4967
+ zodSchema as zodSchema19
4954
4968
  } from "@ai-sdk/provider-utils";
4955
4969
  import { z as z19 } from "zod/v4";
4956
4970
  var openaiSpeechProviderOptionsSchema = lazyValidator11(
4957
- () => zodSchema17(
4971
+ () => zodSchema19(
4958
4972
  z19.object({
4959
4973
  instructions: z19.string().nullish(),
4960
4974
  speed: z19.number().min(0.25).max(4).default(1).nullish()
@@ -5074,10 +5088,10 @@ import {
5074
5088
  } from "@ai-sdk/provider-utils";
5075
5089
 
5076
5090
  // src/transcription/openai-transcription-api.ts
5077
- import { lazyValidator as lazyValidator12, zodSchema as zodSchema18 } from "@ai-sdk/provider-utils";
5091
+ import { lazyValidator as lazyValidator12, zodSchema as zodSchema20 } from "@ai-sdk/provider-utils";
5078
5092
  import { z as z20 } from "zod/v4";
5079
5093
  var openaiTranscriptionResponseSchema = lazyValidator12(
5080
- () => zodSchema18(
5094
+ () => zodSchema20(
5081
5095
  z20.object({
5082
5096
  text: z20.string(),
5083
5097
  language: z20.string().nullish(),
@@ -5102,7 +5116,12 @@ var openaiTranscriptionResponseSchema = lazyValidator12(
5102
5116
  compression_ratio: z20.number(),
5103
5117
  no_speech_prob: z20.number()
5104
5118
  })
5105
- ).nullish()
5119
+ ).nullish(),
5120
+ // Lenient: an unexpected usage shape must not fail the transcription.
5121
+ usage: z20.object({
5122
+ type: z20.string().nullish(),
5123
+ seconds: z20.number().nullish()
5124
+ }).nullish().catch(void 0)
5106
5125
  })
5107
5126
  )
5108
5127
  );
@@ -5110,11 +5129,11 @@ var openaiTranscriptionResponseSchema = lazyValidator12(
5110
5129
  // src/transcription/openai-transcription-options.ts
5111
5130
  import {
5112
5131
  lazyValidator as lazyValidator13,
5113
- zodSchema as zodSchema19
5132
+ zodSchema as zodSchema21
5114
5133
  } from "@ai-sdk/provider-utils";
5115
5134
  import { z as z21 } from "zod/v4";
5116
5135
  var openAITranscriptionProviderOptions = lazyValidator13(
5117
- () => zodSchema19(
5136
+ () => zodSchema21(
5118
5137
  z21.object({
5119
5138
  /**
5120
5139
  * Additional information to include in the transcription response.
@@ -5238,10 +5257,10 @@ var OpenAITranscriptionModel = class {
5238
5257
  prompt: openAIOptions.prompt,
5239
5258
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
5240
5259
  // prefer verbose_json to get segments for models that support it
5241
- response_format: [
5242
- "gpt-4o-transcribe",
5243
- "gpt-4o-mini-transcribe"
5244
- ].includes(this.modelId) ? "json" : "verbose_json",
5260
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
5261
+ response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
5262
+ this.modelId
5263
+ ) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
5245
5264
  temperature: openAIOptions.temperature,
5246
5265
  timestamp_granularities: openAIOptions.timestampGranularities
5247
5266
  };
@@ -5263,7 +5282,7 @@ var OpenAITranscriptionModel = class {
5263
5282
  };
5264
5283
  }
5265
5284
  async doGenerate(options) {
5266
- var _a2, _b, _c, _d, _e, _f, _g, _h;
5285
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5267
5286
  const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
5268
5287
  const { formData, warnings } = await this.getArgs(options);
5269
5288
  const {
@@ -5297,7 +5316,8 @@ var OpenAITranscriptionModel = class {
5297
5316
  endSecond: word.end
5298
5317
  }))) != null ? _g : [],
5299
5318
  language,
5300
- durationInSeconds: (_h = response.duration) != null ? _h : void 0,
5319
+ // Duration-billed json responses report the duration only in `usage`:
5320
+ durationInSeconds: (_j = response.duration) != null ? _j : ((_h = response.usage) == null ? void 0 : _h.type) === "duration" ? (_i = response.usage.seconds) != null ? _i : void 0 : void 0,
5301
5321
  warnings,
5302
5322
  response: {
5303
5323
  timestamp: currentDate,
@@ -5310,7 +5330,7 @@ var OpenAITranscriptionModel = class {
5310
5330
  };
5311
5331
 
5312
5332
  // src/version.ts
5313
- var VERSION = true ? "2.0.135" : "0.0.0-test";
5333
+ var VERSION = true ? "2.0.137" : "0.0.0-test";
5314
5334
 
5315
5335
  // src/openai-provider.ts
5316
5336
  function createOpenAI(options = {}) {