@ai-sdk/openai 2.0.0-beta.2 → 2.0.0-beta.4

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
@@ -290,7 +290,13 @@ var openaiProviderOptions = z.object({
290
290
  *
291
291
  * @default 'auto'
292
292
  */
293
- serviceTier: z.enum(["auto", "flex"]).optional()
293
+ serviceTier: z.enum(["auto", "flex"]).optional(),
294
+ /**
295
+ * Whether to use strict JSON schema validation.
296
+ *
297
+ * @default true
298
+ */
299
+ strictJsonSchema: z.boolean().optional()
294
300
  });
295
301
 
296
302
  // src/openai-error.ts
@@ -389,7 +395,8 @@ var webSearchPreview = createProviderDefinedToolFactory2({
389
395
  function prepareTools({
390
396
  tools,
391
397
  toolChoice,
392
- structuredOutputs
398
+ structuredOutputs,
399
+ strictJsonSchema
393
400
  }) {
394
401
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
395
402
  const toolWarnings = [];
@@ -406,7 +413,7 @@ function prepareTools({
406
413
  name: tool.name,
407
414
  description: tool.description,
408
415
  parameters: tool.inputSchema,
409
- strict: structuredOutputs ? true : void 0
416
+ strict: structuredOutputs ? strictJsonSchema : void 0
410
417
  }
411
418
  });
412
419
  break;
@@ -498,7 +505,7 @@ var OpenAIChatLanguageModel = class {
498
505
  toolChoice,
499
506
  providerOptions
500
507
  }) {
501
- var _a, _b, _c;
508
+ var _a, _b, _c, _d;
502
509
  const warnings = [];
503
510
  const openaiOptions = (_a = await parseProviderOptions({
504
511
  provider: "openai",
@@ -526,6 +533,7 @@ var OpenAIChatLanguageModel = class {
526
533
  }
527
534
  );
528
535
  warnings.push(...messageWarnings);
536
+ const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
529
537
  const baseArgs = {
530
538
  // model id:
531
539
  model: this.modelId,
@@ -541,18 +549,15 @@ var OpenAIChatLanguageModel = class {
541
549
  top_p: topP,
542
550
  frequency_penalty: frequencyPenalty,
543
551
  presence_penalty: presencePenalty,
544
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
545
- // TODO convert into provider option
546
- structuredOutputs && responseFormat.schema != null ? {
547
- type: "json_schema",
548
- json_schema: {
549
- schema: responseFormat.schema,
550
- strict: true,
551
- name: (_c = responseFormat.name) != null ? _c : "response",
552
- description: responseFormat.description
553
- }
554
- } : { type: "json_object" }
555
- ) : void 0,
552
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
553
+ type: "json_schema",
554
+ json_schema: {
555
+ schema: responseFormat.schema,
556
+ strict: strictJsonSchema,
557
+ name: (_d = responseFormat.name) != null ? _d : "response",
558
+ description: responseFormat.description
559
+ }
560
+ } : { type: "json_object" } : void 0,
556
561
  stop: stopSequences,
557
562
  seed,
558
563
  // openai specific settings:
@@ -651,7 +656,8 @@ var OpenAIChatLanguageModel = class {
651
656
  } = prepareTools({
652
657
  tools,
653
658
  toolChoice,
654
- structuredOutputs
659
+ structuredOutputs,
660
+ strictJsonSchema
655
661
  });
656
662
  return {
657
663
  args: {
@@ -1882,19 +1888,22 @@ import {
1882
1888
  createEventSourceResponseHandler as createEventSourceResponseHandler3,
1883
1889
  createJsonResponseHandler as createJsonResponseHandler6,
1884
1890
  generateId as generateId2,
1885
- parseProviderOptions as parseProviderOptions5,
1891
+ parseProviderOptions as parseProviderOptions6,
1886
1892
  postJsonToApi as postJsonToApi5
1887
1893
  } from "@ai-sdk/provider-utils";
1888
- import { z as z13 } from "zod/v4";
1894
+ import { z as z14 } from "zod/v4";
1889
1895
 
1890
1896
  // src/responses/convert-to-openai-responses-messages.ts
1891
1897
  import {
1892
1898
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
1893
1899
  } from "@ai-sdk/provider";
1894
- function convertToOpenAIResponsesMessages({
1900
+ import { parseProviderOptions as parseProviderOptions5 } from "@ai-sdk/provider-utils";
1901
+ import { z as z13 } from "zod/v4";
1902
+ async function convertToOpenAIResponsesMessages({
1895
1903
  prompt,
1896
1904
  systemMessageMode
1897
1905
  }) {
1906
+ var _a, _b;
1898
1907
  const messages = [];
1899
1908
  const warnings = [];
1900
1909
  for (const { role, content } of prompt) {
@@ -1929,7 +1938,7 @@ function convertToOpenAIResponsesMessages({
1929
1938
  messages.push({
1930
1939
  role: "user",
1931
1940
  content: content.map((part, index) => {
1932
- var _a, _b, _c;
1941
+ var _a2, _b2, _c;
1933
1942
  switch (part.type) {
1934
1943
  case "text": {
1935
1944
  return { type: "input_text", text: part.text };
@@ -1941,7 +1950,7 @@ function convertToOpenAIResponsesMessages({
1941
1950
  type: "input_image",
1942
1951
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
1943
1952
  // OpenAI specific extension: image detail
1944
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
1953
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
1945
1954
  };
1946
1955
  } else if (part.mediaType === "application/pdf") {
1947
1956
  if (part.data instanceof URL) {
@@ -1966,6 +1975,7 @@ function convertToOpenAIResponsesMessages({
1966
1975
  break;
1967
1976
  }
1968
1977
  case "assistant": {
1978
+ const reasoningMessages = {};
1969
1979
  for (const part of content) {
1970
1980
  switch (part.type) {
1971
1981
  case "text": {
@@ -1994,6 +2004,43 @@ function convertToOpenAIResponsesMessages({
1994
2004
  });
1995
2005
  break;
1996
2006
  }
2007
+ case "reasoning": {
2008
+ const providerOptions = await parseProviderOptions5({
2009
+ provider: "openai",
2010
+ providerOptions: part.providerOptions,
2011
+ schema: openaiResponsesReasoningProviderOptionsSchema
2012
+ });
2013
+ const reasoningId = (_a = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _a.id;
2014
+ if (reasoningId != null) {
2015
+ const existingReasoningMessage = reasoningMessages[reasoningId];
2016
+ const summaryParts = [];
2017
+ if (part.text.length > 0) {
2018
+ summaryParts.push({ type: "summary_text", text: part.text });
2019
+ } else {
2020
+ warnings.push({
2021
+ type: "other",
2022
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
2023
+ });
2024
+ }
2025
+ if (existingReasoningMessage === void 0) {
2026
+ reasoningMessages[reasoningId] = {
2027
+ type: "reasoning",
2028
+ id: reasoningId,
2029
+ encrypted_content: (_b = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _b.encryptedContent,
2030
+ summary: summaryParts
2031
+ };
2032
+ messages.push(reasoningMessages[reasoningId]);
2033
+ } else {
2034
+ existingReasoningMessage.summary.push(...summaryParts);
2035
+ }
2036
+ } else {
2037
+ warnings.push({
2038
+ type: "other",
2039
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
2040
+ });
2041
+ }
2042
+ break;
2043
+ }
1997
2044
  }
1998
2045
  }
1999
2046
  break;
@@ -2029,6 +2076,12 @@ function convertToOpenAIResponsesMessages({
2029
2076
  }
2030
2077
  return { messages, warnings };
2031
2078
  }
2079
+ var openaiResponsesReasoningProviderOptionsSchema = z13.object({
2080
+ reasoning: z13.object({
2081
+ id: z13.string().nullish(),
2082
+ encryptedContent: z13.string().nullish()
2083
+ }).nullish()
2084
+ });
2032
2085
 
2033
2086
  // src/responses/map-openai-responses-finish-reason.ts
2034
2087
  function mapOpenAIResponseFinishReason({
@@ -2055,7 +2108,7 @@ import {
2055
2108
  function prepareResponsesTools({
2056
2109
  tools,
2057
2110
  toolChoice,
2058
- strict
2111
+ strictJsonSchema
2059
2112
  }) {
2060
2113
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
2061
2114
  const toolWarnings = [];
@@ -2071,7 +2124,7 @@ function prepareResponsesTools({
2071
2124
  name: tool.name,
2072
2125
  description: tool.description,
2073
2126
  parameters: tool.inputSchema,
2074
- strict: strict ? true : void 0
2127
+ strict: strictJsonSchema
2075
2128
  });
2076
2129
  break;
2077
2130
  case "provider-defined":
@@ -2169,17 +2222,17 @@ var OpenAIResponsesLanguageModel = class {
2169
2222
  if (stopSequences != null) {
2170
2223
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2171
2224
  }
2172
- const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
2225
+ const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2173
2226
  prompt,
2174
2227
  systemMessageMode: modelConfig.systemMessageMode
2175
2228
  });
2176
2229
  warnings.push(...messageWarnings);
2177
- const openaiOptions = await parseProviderOptions5({
2230
+ const openaiOptions = await parseProviderOptions6({
2178
2231
  provider: "openai",
2179
2232
  providerOptions,
2180
2233
  schema: openaiResponsesProviderOptionsSchema
2181
2234
  });
2182
- const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
2235
+ const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2183
2236
  const baseArgs = {
2184
2237
  model: this.modelId,
2185
2238
  input: messages,
@@ -2190,7 +2243,7 @@ var OpenAIResponsesLanguageModel = class {
2190
2243
  text: {
2191
2244
  format: responseFormat.schema != null ? {
2192
2245
  type: "json_schema",
2193
- strict: isStrict,
2246
+ strict: strictJsonSchema,
2194
2247
  name: (_b = responseFormat.name) != null ? _b : "response",
2195
2248
  description: responseFormat.description,
2196
2249
  schema: responseFormat.schema
@@ -2205,6 +2258,7 @@ var OpenAIResponsesLanguageModel = class {
2205
2258
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2206
2259
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2207
2260
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2261
+ include: openaiOptions == null ? void 0 : openaiOptions.include,
2208
2262
  // model-specific settings:
2209
2263
  ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2210
2264
  reasoning: {
@@ -2237,6 +2291,21 @@ var OpenAIResponsesLanguageModel = class {
2237
2291
  details: "topP is not supported for reasoning models"
2238
2292
  });
2239
2293
  }
2294
+ } else {
2295
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
2296
+ warnings.push({
2297
+ type: "unsupported-setting",
2298
+ setting: "reasoningEffort",
2299
+ details: "reasoningEffort is not supported for non-reasoning models"
2300
+ });
2301
+ }
2302
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) {
2303
+ warnings.push({
2304
+ type: "unsupported-setting",
2305
+ setting: "reasoningSummary",
2306
+ details: "reasoningSummary is not supported for non-reasoning models"
2307
+ });
2308
+ }
2240
2309
  }
2241
2310
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !supportsFlexProcessing2(this.modelId)) {
2242
2311
  warnings.push({
@@ -2253,7 +2322,7 @@ var OpenAIResponsesLanguageModel = class {
2253
2322
  } = prepareResponsesTools({
2254
2323
  tools,
2255
2324
  toolChoice,
2256
- strict: isStrict
2325
+ strictJsonSchema
2257
2326
  });
2258
2327
  return {
2259
2328
  args: {
@@ -2265,7 +2334,7 @@ var OpenAIResponsesLanguageModel = class {
2265
2334
  };
2266
2335
  }
2267
2336
  async doGenerate(options) {
2268
- var _a, _b, _c, _d, _e, _f, _g, _h;
2337
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2269
2338
  const { args: body, warnings } = await this.getArgs(options);
2270
2339
  const {
2271
2340
  responseHeaders,
@@ -2280,59 +2349,61 @@ var OpenAIResponsesLanguageModel = class {
2280
2349
  body,
2281
2350
  failedResponseHandler: openaiFailedResponseHandler,
2282
2351
  successfulResponseHandler: createJsonResponseHandler6(
2283
- z13.object({
2284
- id: z13.string(),
2285
- created_at: z13.number(),
2286
- model: z13.string(),
2287
- output: z13.array(
2288
- z13.discriminatedUnion("type", [
2289
- z13.object({
2290
- type: z13.literal("message"),
2291
- role: z13.literal("assistant"),
2292
- content: z13.array(
2293
- z13.object({
2294
- type: z13.literal("output_text"),
2295
- text: z13.string(),
2296
- annotations: z13.array(
2297
- z13.object({
2298
- type: z13.literal("url_citation"),
2299
- start_index: z13.number(),
2300
- end_index: z13.number(),
2301
- url: z13.string(),
2302
- title: z13.string()
2352
+ z14.object({
2353
+ id: z14.string(),
2354
+ created_at: z14.number(),
2355
+ model: z14.string(),
2356
+ output: z14.array(
2357
+ z14.discriminatedUnion("type", [
2358
+ z14.object({
2359
+ type: z14.literal("message"),
2360
+ role: z14.literal("assistant"),
2361
+ content: z14.array(
2362
+ z14.object({
2363
+ type: z14.literal("output_text"),
2364
+ text: z14.string(),
2365
+ annotations: z14.array(
2366
+ z14.object({
2367
+ type: z14.literal("url_citation"),
2368
+ start_index: z14.number(),
2369
+ end_index: z14.number(),
2370
+ url: z14.string(),
2371
+ title: z14.string()
2303
2372
  })
2304
2373
  )
2305
2374
  })
2306
2375
  )
2307
2376
  }),
2308
- z13.object({
2309
- type: z13.literal("function_call"),
2310
- call_id: z13.string(),
2311
- name: z13.string(),
2312
- arguments: z13.string()
2377
+ z14.object({
2378
+ type: z14.literal("function_call"),
2379
+ call_id: z14.string(),
2380
+ name: z14.string(),
2381
+ arguments: z14.string()
2313
2382
  }),
2314
- z13.object({
2315
- type: z13.literal("web_search_call"),
2316
- id: z13.string(),
2317
- status: z13.string().optional()
2383
+ z14.object({
2384
+ type: z14.literal("web_search_call"),
2385
+ id: z14.string(),
2386
+ status: z14.string().optional()
2318
2387
  }),
2319
- z13.object({
2320
- type: z13.literal("computer_call"),
2321
- id: z13.string(),
2322
- status: z13.string().optional()
2388
+ z14.object({
2389
+ type: z14.literal("computer_call"),
2390
+ id: z14.string(),
2391
+ status: z14.string().optional()
2323
2392
  }),
2324
- z13.object({
2325
- type: z13.literal("reasoning"),
2326
- summary: z13.array(
2327
- z13.object({
2328
- type: z13.literal("summary_text"),
2329
- text: z13.string()
2393
+ z14.object({
2394
+ type: z14.literal("reasoning"),
2395
+ id: z14.string(),
2396
+ encrypted_content: z14.string().nullish(),
2397
+ summary: z14.array(
2398
+ z14.object({
2399
+ type: z14.literal("summary_text"),
2400
+ text: z14.string()
2330
2401
  })
2331
2402
  )
2332
2403
  })
2333
2404
  ])
2334
2405
  ),
2335
- incomplete_details: z13.object({ reason: z13.string() }).nullable(),
2406
+ incomplete_details: z14.object({ reason: z14.string() }).nullable(),
2336
2407
  usage: usageSchema2
2337
2408
  })
2338
2409
  ),
@@ -2343,10 +2414,23 @@ var OpenAIResponsesLanguageModel = class {
2343
2414
  for (const part of response.output) {
2344
2415
  switch (part.type) {
2345
2416
  case "reasoning": {
2346
- content.push({
2347
- type: "reasoning",
2348
- text: part.summary.map((summary) => summary.text).join()
2349
- });
2417
+ if (part.summary.length === 0) {
2418
+ part.summary.push({ type: "summary_text", text: "" });
2419
+ }
2420
+ for (const summary of part.summary) {
2421
+ content.push({
2422
+ type: "reasoning",
2423
+ text: summary.text,
2424
+ providerMetadata: {
2425
+ openai: {
2426
+ reasoning: {
2427
+ id: part.id,
2428
+ encryptedContent: (_a = part.encrypted_content) != null ? _a : null
2429
+ }
2430
+ }
2431
+ }
2432
+ });
2433
+ }
2350
2434
  break;
2351
2435
  }
2352
2436
  case "message": {
@@ -2359,7 +2443,7 @@ var OpenAIResponsesLanguageModel = class {
2359
2443
  content.push({
2360
2444
  type: "source",
2361
2445
  sourceType: "url",
2362
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : generateId2(),
2446
+ id: (_d = (_c = (_b = this.config).generateId) == null ? void 0 : _c.call(_b)) != null ? _d : generateId2(),
2363
2447
  url: annotation.url,
2364
2448
  title: annotation.title
2365
2449
  });
@@ -2418,15 +2502,15 @@ var OpenAIResponsesLanguageModel = class {
2418
2502
  return {
2419
2503
  content,
2420
2504
  finishReason: mapOpenAIResponseFinishReason({
2421
- finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
2505
+ finishReason: (_e = response.incomplete_details) == null ? void 0 : _e.reason,
2422
2506
  hasToolCalls: content.some((part) => part.type === "tool-call")
2423
2507
  }),
2424
2508
  usage: {
2425
2509
  inputTokens: response.usage.input_tokens,
2426
2510
  outputTokens: response.usage.output_tokens,
2427
2511
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
2428
- reasoningTokens: (_f = (_e = response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : void 0,
2429
- cachedInputTokens: (_h = (_g = response.usage.input_tokens_details) == null ? void 0 : _g.cached_tokens) != null ? _h : void 0
2512
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : void 0,
2513
+ cachedInputTokens: (_i = (_h = response.usage.input_tokens_details) == null ? void 0 : _h.cached_tokens) != null ? _i : void 0
2430
2514
  },
2431
2515
  request: { body },
2432
2516
  response: {
@@ -2480,7 +2564,7 @@ var OpenAIResponsesLanguageModel = class {
2480
2564
  controller.enqueue({ type: "stream-start", warnings });
2481
2565
  },
2482
2566
  transform(chunk, controller) {
2483
- var _a, _b, _c, _d, _e, _f, _g, _h;
2567
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2484
2568
  if (options.includeRawChunks) {
2485
2569
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2486
2570
  }
@@ -2529,7 +2613,15 @@ var OpenAIResponsesLanguageModel = class {
2529
2613
  } else if (value.item.type === "reasoning") {
2530
2614
  controller.enqueue({
2531
2615
  type: "reasoning-start",
2532
- id: value.item.id
2616
+ id: value.item.id,
2617
+ providerMetadata: {
2618
+ openai: {
2619
+ reasoning: {
2620
+ id: value.item.id,
2621
+ encryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
2622
+ }
2623
+ }
2624
+ }
2533
2625
  });
2534
2626
  }
2535
2627
  } else if (isResponseOutputItemDoneChunk(value)) {
@@ -2602,7 +2694,15 @@ var OpenAIResponsesLanguageModel = class {
2602
2694
  } else if (value.item.type === "reasoning") {
2603
2695
  controller.enqueue({
2604
2696
  type: "reasoning-end",
2605
- id: value.item.id
2697
+ id: value.item.id,
2698
+ providerMetadata: {
2699
+ openai: {
2700
+ reasoning: {
2701
+ id: value.item.id,
2702
+ encryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
2703
+ }
2704
+ }
2705
+ }
2606
2706
  });
2607
2707
  }
2608
2708
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
@@ -2631,24 +2731,24 @@ var OpenAIResponsesLanguageModel = class {
2631
2731
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2632
2732
  controller.enqueue({
2633
2733
  type: "reasoning-delta",
2634
- delta: value.delta,
2635
- id: value.item_id
2734
+ id: value.item_id,
2735
+ delta: value.delta
2636
2736
  });
2637
2737
  } else if (isResponseFinishedChunk(value)) {
2638
2738
  finishReason = mapOpenAIResponseFinishReason({
2639
- finishReason: (_a = value.response.incomplete_details) == null ? void 0 : _a.reason,
2739
+ finishReason: (_c = value.response.incomplete_details) == null ? void 0 : _c.reason,
2640
2740
  hasToolCalls
2641
2741
  });
2642
2742
  usage.inputTokens = value.response.usage.input_tokens;
2643
2743
  usage.outputTokens = value.response.usage.output_tokens;
2644
2744
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
2645
- usage.reasoningTokens = (_c = (_b = value.response.usage.output_tokens_details) == null ? void 0 : _b.reasoning_tokens) != null ? _c : void 0;
2646
- usage.cachedInputTokens = (_e = (_d = value.response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : void 0;
2745
+ usage.reasoningTokens = (_e = (_d = value.response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
2746
+ usage.cachedInputTokens = (_g = (_f = value.response.usage.input_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
2647
2747
  } else if (isResponseAnnotationAddedChunk(value)) {
2648
2748
  controller.enqueue({
2649
2749
  type: "source",
2650
2750
  sourceType: "url",
2651
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : generateId2(),
2751
+ id: (_j = (_i = (_h = self.config).generateId) == null ? void 0 : _i.call(_h)) != null ? _j : generateId2(),
2652
2752
  url: value.annotation.url,
2653
2753
  title: value.annotation.title
2654
2754
  });
@@ -2673,124 +2773,129 @@ var OpenAIResponsesLanguageModel = class {
2673
2773
  };
2674
2774
  }
2675
2775
  };
2676
- var usageSchema2 = z13.object({
2677
- input_tokens: z13.number(),
2678
- input_tokens_details: z13.object({ cached_tokens: z13.number().nullish() }).nullish(),
2679
- output_tokens: z13.number(),
2680
- output_tokens_details: z13.object({ reasoning_tokens: z13.number().nullish() }).nullish()
2776
+ var usageSchema2 = z14.object({
2777
+ input_tokens: z14.number(),
2778
+ input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
2779
+ output_tokens: z14.number(),
2780
+ output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
2681
2781
  });
2682
- var textDeltaChunkSchema = z13.object({
2683
- type: z13.literal("response.output_text.delta"),
2684
- item_id: z13.string(),
2685
- delta: z13.string()
2782
+ var textDeltaChunkSchema = z14.object({
2783
+ type: z14.literal("response.output_text.delta"),
2784
+ item_id: z14.string(),
2785
+ delta: z14.string()
2686
2786
  });
2687
- var responseFinishedChunkSchema = z13.object({
2688
- type: z13.enum(["response.completed", "response.incomplete"]),
2689
- response: z13.object({
2690
- incomplete_details: z13.object({ reason: z13.string() }).nullish(),
2787
+ var responseFinishedChunkSchema = z14.object({
2788
+ type: z14.enum(["response.completed", "response.incomplete"]),
2789
+ response: z14.object({
2790
+ incomplete_details: z14.object({ reason: z14.string() }).nullish(),
2691
2791
  usage: usageSchema2
2692
2792
  })
2693
2793
  });
2694
- var responseCreatedChunkSchema = z13.object({
2695
- type: z13.literal("response.created"),
2696
- response: z13.object({
2697
- id: z13.string(),
2698
- created_at: z13.number(),
2699
- model: z13.string()
2794
+ var responseCreatedChunkSchema = z14.object({
2795
+ type: z14.literal("response.created"),
2796
+ response: z14.object({
2797
+ id: z14.string(),
2798
+ created_at: z14.number(),
2799
+ model: z14.string()
2700
2800
  })
2701
2801
  });
2702
- var responseOutputItemAddedSchema = z13.object({
2703
- type: z13.literal("response.output_item.added"),
2704
- output_index: z13.number(),
2705
- item: z13.discriminatedUnion("type", [
2706
- z13.object({
2707
- type: z13.literal("message"),
2708
- id: z13.string()
2802
+ var responseOutputItemAddedSchema = z14.object({
2803
+ type: z14.literal("response.output_item.added"),
2804
+ output_index: z14.number(),
2805
+ item: z14.discriminatedUnion("type", [
2806
+ z14.object({
2807
+ type: z14.literal("message"),
2808
+ id: z14.string()
2709
2809
  }),
2710
- z13.object({
2711
- type: z13.literal("reasoning"),
2712
- id: z13.string()
2810
+ z14.object({
2811
+ type: z14.literal("reasoning"),
2812
+ id: z14.string(),
2813
+ encrypted_content: z14.string().nullish(),
2814
+ summary: z14.array(
2815
+ z14.object({
2816
+ type: z14.literal("summary_text"),
2817
+ text: z14.string()
2818
+ })
2819
+ )
2713
2820
  }),
2714
- z13.object({
2715
- type: z13.literal("function_call"),
2716
- id: z13.string(),
2717
- call_id: z13.string(),
2718
- name: z13.string(),
2719
- arguments: z13.string()
2821
+ z14.object({
2822
+ type: z14.literal("function_call"),
2823
+ id: z14.string(),
2824
+ call_id: z14.string(),
2825
+ name: z14.string(),
2826
+ arguments: z14.string()
2720
2827
  }),
2721
- z13.object({
2722
- type: z13.literal("web_search_call"),
2723
- id: z13.string(),
2724
- status: z13.string()
2828
+ z14.object({
2829
+ type: z14.literal("web_search_call"),
2830
+ id: z14.string(),
2831
+ status: z14.string()
2725
2832
  }),
2726
- z13.object({
2727
- type: z13.literal("computer_call"),
2728
- id: z13.string(),
2729
- status: z13.string()
2833
+ z14.object({
2834
+ type: z14.literal("computer_call"),
2835
+ id: z14.string(),
2836
+ status: z14.string()
2730
2837
  })
2731
2838
  ])
2732
2839
  });
2733
- var responseOutputItemDoneSchema = z13.object({
2734
- type: z13.literal("response.output_item.done"),
2735
- output_index: z13.number(),
2736
- item: z13.discriminatedUnion("type", [
2737
- z13.object({
2738
- type: z13.literal("message"),
2739
- id: z13.string()
2840
+ var responseOutputItemDoneSchema = z14.object({
2841
+ type: z14.literal("response.output_item.done"),
2842
+ output_index: z14.number(),
2843
+ item: z14.discriminatedUnion("type", [
2844
+ z14.object({
2845
+ type: z14.literal("message"),
2846
+ id: z14.string()
2740
2847
  }),
2741
- z13.object({
2742
- type: z13.literal("reasoning"),
2743
- id: z13.string()
2848
+ z14.object({
2849
+ type: z14.literal("reasoning"),
2850
+ id: z14.string(),
2851
+ encrypted_content: z14.string().nullish(),
2852
+ summary: z14.array(
2853
+ z14.object({
2854
+ type: z14.literal("summary_text"),
2855
+ text: z14.string()
2856
+ })
2857
+ )
2744
2858
  }),
2745
- z13.object({
2746
- type: z13.literal("function_call"),
2747
- id: z13.string(),
2748
- call_id: z13.string(),
2749
- name: z13.string(),
2750
- arguments: z13.string(),
2751
- status: z13.literal("completed")
2859
+ z14.object({
2860
+ type: z14.literal("function_call"),
2861
+ id: z14.string(),
2862
+ call_id: z14.string(),
2863
+ name: z14.string(),
2864
+ arguments: z14.string(),
2865
+ status: z14.literal("completed")
2752
2866
  }),
2753
- z13.object({
2754
- type: z13.literal("web_search_call"),
2755
- id: z13.string(),
2756
- status: z13.literal("completed")
2867
+ z14.object({
2868
+ type: z14.literal("web_search_call"),
2869
+ id: z14.string(),
2870
+ status: z14.literal("completed")
2757
2871
  }),
2758
- z13.object({
2759
- type: z13.literal("computer_call"),
2760
- id: z13.string(),
2761
- status: z13.literal("completed")
2872
+ z14.object({
2873
+ type: z14.literal("computer_call"),
2874
+ id: z14.string(),
2875
+ status: z14.literal("completed")
2762
2876
  })
2763
2877
  ])
2764
2878
  });
2765
- var responseFunctionCallArgumentsDeltaSchema = z13.object({
2766
- type: z13.literal("response.function_call_arguments.delta"),
2767
- item_id: z13.string(),
2768
- output_index: z13.number(),
2769
- delta: z13.string()
2879
+ var responseFunctionCallArgumentsDeltaSchema = z14.object({
2880
+ type: z14.literal("response.function_call_arguments.delta"),
2881
+ item_id: z14.string(),
2882
+ output_index: z14.number(),
2883
+ delta: z14.string()
2770
2884
  });
2771
- var responseAnnotationAddedSchema = z13.object({
2772
- type: z13.literal("response.output_text.annotation.added"),
2773
- annotation: z13.object({
2774
- type: z13.literal("url_citation"),
2775
- url: z13.string(),
2776
- title: z13.string()
2885
+ var responseAnnotationAddedSchema = z14.object({
2886
+ type: z14.literal("response.output_text.annotation.added"),
2887
+ annotation: z14.object({
2888
+ type: z14.literal("url_citation"),
2889
+ url: z14.string(),
2890
+ title: z14.string()
2777
2891
  })
2778
2892
  });
2779
- var responseReasoningSummaryTextDeltaSchema = z13.object({
2780
- type: z13.literal("response.reasoning_summary_text.delta"),
2781
- item_id: z13.string(),
2782
- output_index: z13.number(),
2783
- summary_index: z13.number(),
2784
- delta: z13.string()
2893
+ var responseReasoningSummaryTextDeltaSchema = z14.object({
2894
+ type: z14.literal("response.reasoning_summary_text.delta"),
2895
+ item_id: z14.string(),
2896
+ delta: z14.string()
2785
2897
  });
2786
- var responseReasoningSummaryPartDoneSchema = z13.object({
2787
- type: z13.literal("response.reasoning_summary_part.done"),
2788
- item_id: z13.string(),
2789
- output_index: z13.number(),
2790
- summary_index: z13.number(),
2791
- part: z13.unknown().nullish()
2792
- });
2793
- var openaiResponsesChunkSchema = z13.union([
2898
+ var openaiResponsesChunkSchema = z14.union([
2794
2899
  textDeltaChunkSchema,
2795
2900
  responseFinishedChunkSchema,
2796
2901
  responseCreatedChunkSchema,
@@ -2799,8 +2904,7 @@ var openaiResponsesChunkSchema = z13.union([
2799
2904
  responseFunctionCallArgumentsDeltaSchema,
2800
2905
  responseAnnotationAddedSchema,
2801
2906
  responseReasoningSummaryTextDeltaSchema,
2802
- responseReasoningSummaryPartDoneSchema,
2803
- z13.object({ type: z13.string() }).passthrough()
2907
+ z14.object({ type: z14.string() }).passthrough()
2804
2908
  // fallback for unknown chunks
2805
2909
  ]);
2806
2910
  function isTextDeltaChunk(chunk) {
@@ -2828,7 +2932,7 @@ function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2828
2932
  return chunk.type === "response.reasoning_summary_text.delta";
2829
2933
  }
2830
2934
  function getResponsesModelConfig(modelId) {
2831
- if (modelId.startsWith("o")) {
2935
+ if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
2832
2936
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
2833
2937
  return {
2834
2938
  isReasoningModel: true,
@@ -2851,30 +2955,31 @@ function getResponsesModelConfig(modelId) {
2851
2955
  function supportsFlexProcessing2(modelId) {
2852
2956
  return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
2853
2957
  }
2854
- var openaiResponsesProviderOptionsSchema = z13.object({
2855
- metadata: z13.any().nullish(),
2856
- parallelToolCalls: z13.boolean().nullish(),
2857
- previousResponseId: z13.string().nullish(),
2858
- store: z13.boolean().nullish(),
2859
- user: z13.string().nullish(),
2860
- reasoningEffort: z13.string().nullish(),
2861
- strictSchemas: z13.boolean().nullish(),
2862
- instructions: z13.string().nullish(),
2863
- reasoningSummary: z13.string().nullish(),
2864
- serviceTier: z13.enum(["auto", "flex"]).nullish()
2958
+ var openaiResponsesProviderOptionsSchema = z14.object({
2959
+ metadata: z14.any().nullish(),
2960
+ parallelToolCalls: z14.boolean().nullish(),
2961
+ previousResponseId: z14.string().nullish(),
2962
+ store: z14.boolean().nullish(),
2963
+ user: z14.string().nullish(),
2964
+ reasoningEffort: z14.string().nullish(),
2965
+ strictJsonSchema: z14.boolean().nullish(),
2966
+ instructions: z14.string().nullish(),
2967
+ reasoningSummary: z14.string().nullish(),
2968
+ serviceTier: z14.enum(["auto", "flex"]).nullish(),
2969
+ include: z14.array(z14.enum(["reasoning.encrypted_content"])).nullish()
2865
2970
  });
2866
2971
 
2867
2972
  // src/openai-speech-model.ts
2868
2973
  import {
2869
2974
  combineHeaders as combineHeaders7,
2870
2975
  createBinaryResponseHandler,
2871
- parseProviderOptions as parseProviderOptions6,
2976
+ parseProviderOptions as parseProviderOptions7,
2872
2977
  postJsonToApi as postJsonToApi6
2873
2978
  } from "@ai-sdk/provider-utils";
2874
- import { z as z14 } from "zod/v4";
2875
- var OpenAIProviderOptionsSchema = z14.object({
2876
- instructions: z14.string().nullish(),
2877
- speed: z14.number().min(0.25).max(4).default(1).nullish()
2979
+ import { z as z15 } from "zod/v4";
2980
+ var OpenAIProviderOptionsSchema = z15.object({
2981
+ instructions: z15.string().nullish(),
2982
+ speed: z15.number().min(0.25).max(4).default(1).nullish()
2878
2983
  });
2879
2984
  var OpenAISpeechModel = class {
2880
2985
  constructor(modelId, config) {
@@ -2895,7 +3000,7 @@ var OpenAISpeechModel = class {
2895
3000
  providerOptions
2896
3001
  }) {
2897
3002
  const warnings = [];
2898
- const openAIOptions = await parseProviderOptions6({
3003
+ const openAIOptions = await parseProviderOptions7({
2899
3004
  provider: "openai",
2900
3005
  providerOptions,
2901
3006
  schema: OpenAIProviderOptionsSchema