@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.
@@ -310,7 +310,13 @@ var openaiProviderOptions = import_v4.z.object({
310
310
  *
311
311
  * @default 'auto'
312
312
  */
313
- serviceTier: import_v4.z.enum(["auto", "flex"]).optional()
313
+ serviceTier: import_v4.z.enum(["auto", "flex"]).optional(),
314
+ /**
315
+ * Whether to use strict JSON schema validation.
316
+ *
317
+ * @default true
318
+ */
319
+ strictJsonSchema: import_v4.z.boolean().optional()
314
320
  });
315
321
 
316
322
  // src/openai-error.ts
@@ -407,7 +413,8 @@ var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFacto
407
413
  function prepareTools({
408
414
  tools,
409
415
  toolChoice,
410
- structuredOutputs
416
+ structuredOutputs,
417
+ strictJsonSchema
411
418
  }) {
412
419
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
413
420
  const toolWarnings = [];
@@ -424,7 +431,7 @@ function prepareTools({
424
431
  name: tool.name,
425
432
  description: tool.description,
426
433
  parameters: tool.inputSchema,
427
- strict: structuredOutputs ? true : void 0
434
+ strict: structuredOutputs ? strictJsonSchema : void 0
428
435
  }
429
436
  });
430
437
  break;
@@ -516,7 +523,7 @@ var OpenAIChatLanguageModel = class {
516
523
  toolChoice,
517
524
  providerOptions
518
525
  }) {
519
- var _a, _b, _c;
526
+ var _a, _b, _c, _d;
520
527
  const warnings = [];
521
528
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
522
529
  provider: "openai",
@@ -544,6 +551,7 @@ var OpenAIChatLanguageModel = class {
544
551
  }
545
552
  );
546
553
  warnings.push(...messageWarnings);
554
+ const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
547
555
  const baseArgs = {
548
556
  // model id:
549
557
  model: this.modelId,
@@ -559,18 +567,15 @@ var OpenAIChatLanguageModel = class {
559
567
  top_p: topP,
560
568
  frequency_penalty: frequencyPenalty,
561
569
  presence_penalty: presencePenalty,
562
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
563
- // TODO convert into provider option
564
- structuredOutputs && responseFormat.schema != null ? {
565
- type: "json_schema",
566
- json_schema: {
567
- schema: responseFormat.schema,
568
- strict: true,
569
- name: (_c = responseFormat.name) != null ? _c : "response",
570
- description: responseFormat.description
571
- }
572
- } : { type: "json_object" }
573
- ) : void 0,
570
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
571
+ type: "json_schema",
572
+ json_schema: {
573
+ schema: responseFormat.schema,
574
+ strict: strictJsonSchema,
575
+ name: (_d = responseFormat.name) != null ? _d : "response",
576
+ description: responseFormat.description
577
+ }
578
+ } : { type: "json_object" } : void 0,
574
579
  stop: stopSequences,
575
580
  seed,
576
581
  // openai specific settings:
@@ -669,7 +674,8 @@ var OpenAIChatLanguageModel = class {
669
674
  } = prepareTools({
670
675
  tools,
671
676
  toolChoice,
672
- structuredOutputs
677
+ structuredOutputs,
678
+ strictJsonSchema
673
679
  });
674
680
  return {
675
681
  args: {
@@ -1970,15 +1976,18 @@ var OpenAISpeechModel = class {
1970
1976
  };
1971
1977
 
1972
1978
  // src/responses/openai-responses-language-model.ts
1973
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1974
- var import_v414 = require("zod/v4");
1979
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1980
+ var import_v415 = require("zod/v4");
1975
1981
 
1976
1982
  // src/responses/convert-to-openai-responses-messages.ts
1977
1983
  var import_provider6 = require("@ai-sdk/provider");
1978
- function convertToOpenAIResponsesMessages({
1984
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1985
+ var import_v414 = require("zod/v4");
1986
+ async function convertToOpenAIResponsesMessages({
1979
1987
  prompt,
1980
1988
  systemMessageMode
1981
1989
  }) {
1990
+ var _a, _b;
1982
1991
  const messages = [];
1983
1992
  const warnings = [];
1984
1993
  for (const { role, content } of prompt) {
@@ -2013,7 +2022,7 @@ function convertToOpenAIResponsesMessages({
2013
2022
  messages.push({
2014
2023
  role: "user",
2015
2024
  content: content.map((part, index) => {
2016
- var _a, _b, _c;
2025
+ var _a2, _b2, _c;
2017
2026
  switch (part.type) {
2018
2027
  case "text": {
2019
2028
  return { type: "input_text", text: part.text };
@@ -2025,7 +2034,7 @@ function convertToOpenAIResponsesMessages({
2025
2034
  type: "input_image",
2026
2035
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
2027
2036
  // OpenAI specific extension: image detail
2028
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
2037
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2029
2038
  };
2030
2039
  } else if (part.mediaType === "application/pdf") {
2031
2040
  if (part.data instanceof URL) {
@@ -2050,6 +2059,7 @@ function convertToOpenAIResponsesMessages({
2050
2059
  break;
2051
2060
  }
2052
2061
  case "assistant": {
2062
+ const reasoningMessages = {};
2053
2063
  for (const part of content) {
2054
2064
  switch (part.type) {
2055
2065
  case "text": {
@@ -2078,6 +2088,43 @@ function convertToOpenAIResponsesMessages({
2078
2088
  });
2079
2089
  break;
2080
2090
  }
2091
+ case "reasoning": {
2092
+ const providerOptions = await (0, import_provider_utils11.parseProviderOptions)({
2093
+ provider: "openai",
2094
+ providerOptions: part.providerOptions,
2095
+ schema: openaiResponsesReasoningProviderOptionsSchema
2096
+ });
2097
+ const reasoningId = (_a = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _a.id;
2098
+ if (reasoningId != null) {
2099
+ const existingReasoningMessage = reasoningMessages[reasoningId];
2100
+ const summaryParts = [];
2101
+ if (part.text.length > 0) {
2102
+ summaryParts.push({ type: "summary_text", text: part.text });
2103
+ } else {
2104
+ warnings.push({
2105
+ type: "other",
2106
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
2107
+ });
2108
+ }
2109
+ if (existingReasoningMessage === void 0) {
2110
+ reasoningMessages[reasoningId] = {
2111
+ type: "reasoning",
2112
+ id: reasoningId,
2113
+ encrypted_content: (_b = providerOptions == null ? void 0 : providerOptions.reasoning) == null ? void 0 : _b.encryptedContent,
2114
+ summary: summaryParts
2115
+ };
2116
+ messages.push(reasoningMessages[reasoningId]);
2117
+ } else {
2118
+ existingReasoningMessage.summary.push(...summaryParts);
2119
+ }
2120
+ } else {
2121
+ warnings.push({
2122
+ type: "other",
2123
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
2124
+ });
2125
+ }
2126
+ break;
2127
+ }
2081
2128
  }
2082
2129
  }
2083
2130
  break;
@@ -2113,6 +2160,12 @@ function convertToOpenAIResponsesMessages({
2113
2160
  }
2114
2161
  return { messages, warnings };
2115
2162
  }
2163
+ var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
2164
+ reasoning: import_v414.z.object({
2165
+ id: import_v414.z.string().nullish(),
2166
+ encryptedContent: import_v414.z.string().nullish()
2167
+ }).nullish()
2168
+ });
2116
2169
 
2117
2170
  // src/responses/map-openai-responses-finish-reason.ts
2118
2171
  function mapOpenAIResponseFinishReason({
@@ -2137,7 +2190,7 @@ var import_provider7 = require("@ai-sdk/provider");
2137
2190
  function prepareResponsesTools({
2138
2191
  tools,
2139
2192
  toolChoice,
2140
- strict
2193
+ strictJsonSchema
2141
2194
  }) {
2142
2195
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
2143
2196
  const toolWarnings = [];
@@ -2153,7 +2206,7 @@ function prepareResponsesTools({
2153
2206
  name: tool.name,
2154
2207
  description: tool.description,
2155
2208
  parameters: tool.inputSchema,
2156
- strict: strict ? true : void 0
2209
+ strict: strictJsonSchema
2157
2210
  });
2158
2211
  break;
2159
2212
  case "provider-defined":
@@ -2251,17 +2304,17 @@ var OpenAIResponsesLanguageModel = class {
2251
2304
  if (stopSequences != null) {
2252
2305
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2253
2306
  }
2254
- const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
2307
+ const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2255
2308
  prompt,
2256
2309
  systemMessageMode: modelConfig.systemMessageMode
2257
2310
  });
2258
2311
  warnings.push(...messageWarnings);
2259
- const openaiOptions = await (0, import_provider_utils11.parseProviderOptions)({
2312
+ const openaiOptions = await (0, import_provider_utils12.parseProviderOptions)({
2260
2313
  provider: "openai",
2261
2314
  providerOptions,
2262
2315
  schema: openaiResponsesProviderOptionsSchema
2263
2316
  });
2264
- const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
2317
+ const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2265
2318
  const baseArgs = {
2266
2319
  model: this.modelId,
2267
2320
  input: messages,
@@ -2272,7 +2325,7 @@ var OpenAIResponsesLanguageModel = class {
2272
2325
  text: {
2273
2326
  format: responseFormat.schema != null ? {
2274
2327
  type: "json_schema",
2275
- strict: isStrict,
2328
+ strict: strictJsonSchema,
2276
2329
  name: (_b = responseFormat.name) != null ? _b : "response",
2277
2330
  description: responseFormat.description,
2278
2331
  schema: responseFormat.schema
@@ -2287,6 +2340,7 @@ var OpenAIResponsesLanguageModel = class {
2287
2340
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2288
2341
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2289
2342
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2343
+ include: openaiOptions == null ? void 0 : openaiOptions.include,
2290
2344
  // model-specific settings:
2291
2345
  ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2292
2346
  reasoning: {
@@ -2319,6 +2373,21 @@ var OpenAIResponsesLanguageModel = class {
2319
2373
  details: "topP is not supported for reasoning models"
2320
2374
  });
2321
2375
  }
2376
+ } else {
2377
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
2378
+ warnings.push({
2379
+ type: "unsupported-setting",
2380
+ setting: "reasoningEffort",
2381
+ details: "reasoningEffort is not supported for non-reasoning models"
2382
+ });
2383
+ }
2384
+ if ((openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) {
2385
+ warnings.push({
2386
+ type: "unsupported-setting",
2387
+ setting: "reasoningSummary",
2388
+ details: "reasoningSummary is not supported for non-reasoning models"
2389
+ });
2390
+ }
2322
2391
  }
2323
2392
  if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !supportsFlexProcessing2(this.modelId)) {
2324
2393
  warnings.push({
@@ -2335,7 +2404,7 @@ var OpenAIResponsesLanguageModel = class {
2335
2404
  } = prepareResponsesTools({
2336
2405
  tools,
2337
2406
  toolChoice,
2338
- strict: isStrict
2407
+ strictJsonSchema
2339
2408
  });
2340
2409
  return {
2341
2410
  args: {
@@ -2347,74 +2416,76 @@ var OpenAIResponsesLanguageModel = class {
2347
2416
  };
2348
2417
  }
2349
2418
  async doGenerate(options) {
2350
- var _a, _b, _c, _d, _e, _f, _g, _h;
2419
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2351
2420
  const { args: body, warnings } = await this.getArgs(options);
2352
2421
  const {
2353
2422
  responseHeaders,
2354
2423
  value: response,
2355
2424
  rawValue: rawResponse
2356
- } = await (0, import_provider_utils11.postJsonToApi)({
2425
+ } = await (0, import_provider_utils12.postJsonToApi)({
2357
2426
  url: this.config.url({
2358
2427
  path: "/responses",
2359
2428
  modelId: this.modelId
2360
2429
  }),
2361
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2430
+ headers: (0, import_provider_utils12.combineHeaders)(this.config.headers(), options.headers),
2362
2431
  body,
2363
2432
  failedResponseHandler: openaiFailedResponseHandler,
2364
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2365
- import_v414.z.object({
2366
- id: import_v414.z.string(),
2367
- created_at: import_v414.z.number(),
2368
- model: import_v414.z.string(),
2369
- output: import_v414.z.array(
2370
- import_v414.z.discriminatedUnion("type", [
2371
- import_v414.z.object({
2372
- type: import_v414.z.literal("message"),
2373
- role: import_v414.z.literal("assistant"),
2374
- content: import_v414.z.array(
2375
- import_v414.z.object({
2376
- type: import_v414.z.literal("output_text"),
2377
- text: import_v414.z.string(),
2378
- annotations: import_v414.z.array(
2379
- import_v414.z.object({
2380
- type: import_v414.z.literal("url_citation"),
2381
- start_index: import_v414.z.number(),
2382
- end_index: import_v414.z.number(),
2383
- url: import_v414.z.string(),
2384
- title: import_v414.z.string()
2433
+ successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
2434
+ import_v415.z.object({
2435
+ id: import_v415.z.string(),
2436
+ created_at: import_v415.z.number(),
2437
+ model: import_v415.z.string(),
2438
+ output: import_v415.z.array(
2439
+ import_v415.z.discriminatedUnion("type", [
2440
+ import_v415.z.object({
2441
+ type: import_v415.z.literal("message"),
2442
+ role: import_v415.z.literal("assistant"),
2443
+ content: import_v415.z.array(
2444
+ import_v415.z.object({
2445
+ type: import_v415.z.literal("output_text"),
2446
+ text: import_v415.z.string(),
2447
+ annotations: import_v415.z.array(
2448
+ import_v415.z.object({
2449
+ type: import_v415.z.literal("url_citation"),
2450
+ start_index: import_v415.z.number(),
2451
+ end_index: import_v415.z.number(),
2452
+ url: import_v415.z.string(),
2453
+ title: import_v415.z.string()
2385
2454
  })
2386
2455
  )
2387
2456
  })
2388
2457
  )
2389
2458
  }),
2390
- import_v414.z.object({
2391
- type: import_v414.z.literal("function_call"),
2392
- call_id: import_v414.z.string(),
2393
- name: import_v414.z.string(),
2394
- arguments: import_v414.z.string()
2459
+ import_v415.z.object({
2460
+ type: import_v415.z.literal("function_call"),
2461
+ call_id: import_v415.z.string(),
2462
+ name: import_v415.z.string(),
2463
+ arguments: import_v415.z.string()
2395
2464
  }),
2396
- import_v414.z.object({
2397
- type: import_v414.z.literal("web_search_call"),
2398
- id: import_v414.z.string(),
2399
- status: import_v414.z.string().optional()
2465
+ import_v415.z.object({
2466
+ type: import_v415.z.literal("web_search_call"),
2467
+ id: import_v415.z.string(),
2468
+ status: import_v415.z.string().optional()
2400
2469
  }),
2401
- import_v414.z.object({
2402
- type: import_v414.z.literal("computer_call"),
2403
- id: import_v414.z.string(),
2404
- status: import_v414.z.string().optional()
2470
+ import_v415.z.object({
2471
+ type: import_v415.z.literal("computer_call"),
2472
+ id: import_v415.z.string(),
2473
+ status: import_v415.z.string().optional()
2405
2474
  }),
2406
- import_v414.z.object({
2407
- type: import_v414.z.literal("reasoning"),
2408
- summary: import_v414.z.array(
2409
- import_v414.z.object({
2410
- type: import_v414.z.literal("summary_text"),
2411
- text: import_v414.z.string()
2475
+ import_v415.z.object({
2476
+ type: import_v415.z.literal("reasoning"),
2477
+ id: import_v415.z.string(),
2478
+ encrypted_content: import_v415.z.string().nullish(),
2479
+ summary: import_v415.z.array(
2480
+ import_v415.z.object({
2481
+ type: import_v415.z.literal("summary_text"),
2482
+ text: import_v415.z.string()
2412
2483
  })
2413
2484
  )
2414
2485
  })
2415
2486
  ])
2416
2487
  ),
2417
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullable(),
2488
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullable(),
2418
2489
  usage: usageSchema2
2419
2490
  })
2420
2491
  ),
@@ -2425,10 +2496,23 @@ var OpenAIResponsesLanguageModel = class {
2425
2496
  for (const part of response.output) {
2426
2497
  switch (part.type) {
2427
2498
  case "reasoning": {
2428
- content.push({
2429
- type: "reasoning",
2430
- text: part.summary.map((summary) => summary.text).join()
2431
- });
2499
+ if (part.summary.length === 0) {
2500
+ part.summary.push({ type: "summary_text", text: "" });
2501
+ }
2502
+ for (const summary of part.summary) {
2503
+ content.push({
2504
+ type: "reasoning",
2505
+ text: summary.text,
2506
+ providerMetadata: {
2507
+ openai: {
2508
+ reasoning: {
2509
+ id: part.id,
2510
+ encryptedContent: (_a = part.encrypted_content) != null ? _a : null
2511
+ }
2512
+ }
2513
+ }
2514
+ });
2515
+ }
2432
2516
  break;
2433
2517
  }
2434
2518
  case "message": {
@@ -2441,7 +2525,7 @@ var OpenAIResponsesLanguageModel = class {
2441
2525
  content.push({
2442
2526
  type: "source",
2443
2527
  sourceType: "url",
2444
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils11.generateId)(),
2528
+ id: (_d = (_c = (_b = this.config).generateId) == null ? void 0 : _c.call(_b)) != null ? _d : (0, import_provider_utils12.generateId)(),
2445
2529
  url: annotation.url,
2446
2530
  title: annotation.title
2447
2531
  });
@@ -2500,15 +2584,15 @@ var OpenAIResponsesLanguageModel = class {
2500
2584
  return {
2501
2585
  content,
2502
2586
  finishReason: mapOpenAIResponseFinishReason({
2503
- finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
2587
+ finishReason: (_e = response.incomplete_details) == null ? void 0 : _e.reason,
2504
2588
  hasToolCalls: content.some((part) => part.type === "tool-call")
2505
2589
  }),
2506
2590
  usage: {
2507
2591
  inputTokens: response.usage.input_tokens,
2508
2592
  outputTokens: response.usage.output_tokens,
2509
2593
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
2510
- reasoningTokens: (_f = (_e = response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : void 0,
2511
- cachedInputTokens: (_h = (_g = response.usage.input_tokens_details) == null ? void 0 : _g.cached_tokens) != null ? _h : void 0
2594
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : void 0,
2595
+ cachedInputTokens: (_i = (_h = response.usage.input_tokens_details) == null ? void 0 : _h.cached_tokens) != null ? _i : void 0
2512
2596
  },
2513
2597
  request: { body },
2514
2598
  response: {
@@ -2528,18 +2612,18 @@ var OpenAIResponsesLanguageModel = class {
2528
2612
  }
2529
2613
  async doStream(options) {
2530
2614
  const { args: body, warnings } = await this.getArgs(options);
2531
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2615
+ const { responseHeaders, value: response } = await (0, import_provider_utils12.postJsonToApi)({
2532
2616
  url: this.config.url({
2533
2617
  path: "/responses",
2534
2618
  modelId: this.modelId
2535
2619
  }),
2536
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2620
+ headers: (0, import_provider_utils12.combineHeaders)(this.config.headers(), options.headers),
2537
2621
  body: {
2538
2622
  ...body,
2539
2623
  stream: true
2540
2624
  },
2541
2625
  failedResponseHandler: openaiFailedResponseHandler,
2542
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2626
+ successfulResponseHandler: (0, import_provider_utils12.createEventSourceResponseHandler)(
2543
2627
  openaiResponsesChunkSchema
2544
2628
  ),
2545
2629
  abortSignal: options.abortSignal,
@@ -2562,7 +2646,7 @@ var OpenAIResponsesLanguageModel = class {
2562
2646
  controller.enqueue({ type: "stream-start", warnings });
2563
2647
  },
2564
2648
  transform(chunk, controller) {
2565
- var _a, _b, _c, _d, _e, _f, _g, _h;
2649
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2566
2650
  if (options.includeRawChunks) {
2567
2651
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2568
2652
  }
@@ -2611,7 +2695,15 @@ var OpenAIResponsesLanguageModel = class {
2611
2695
  } else if (value.item.type === "reasoning") {
2612
2696
  controller.enqueue({
2613
2697
  type: "reasoning-start",
2614
- id: value.item.id
2698
+ id: value.item.id,
2699
+ providerMetadata: {
2700
+ openai: {
2701
+ reasoning: {
2702
+ id: value.item.id,
2703
+ encryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
2704
+ }
2705
+ }
2706
+ }
2615
2707
  });
2616
2708
  }
2617
2709
  } else if (isResponseOutputItemDoneChunk(value)) {
@@ -2684,7 +2776,15 @@ var OpenAIResponsesLanguageModel = class {
2684
2776
  } else if (value.item.type === "reasoning") {
2685
2777
  controller.enqueue({
2686
2778
  type: "reasoning-end",
2687
- id: value.item.id
2779
+ id: value.item.id,
2780
+ providerMetadata: {
2781
+ openai: {
2782
+ reasoning: {
2783
+ id: value.item.id,
2784
+ encryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
2785
+ }
2786
+ }
2787
+ }
2688
2788
  });
2689
2789
  }
2690
2790
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
@@ -2713,24 +2813,24 @@ var OpenAIResponsesLanguageModel = class {
2713
2813
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2714
2814
  controller.enqueue({
2715
2815
  type: "reasoning-delta",
2716
- delta: value.delta,
2717
- id: value.item_id
2816
+ id: value.item_id,
2817
+ delta: value.delta
2718
2818
  });
2719
2819
  } else if (isResponseFinishedChunk(value)) {
2720
2820
  finishReason = mapOpenAIResponseFinishReason({
2721
- finishReason: (_a = value.response.incomplete_details) == null ? void 0 : _a.reason,
2821
+ finishReason: (_c = value.response.incomplete_details) == null ? void 0 : _c.reason,
2722
2822
  hasToolCalls
2723
2823
  });
2724
2824
  usage.inputTokens = value.response.usage.input_tokens;
2725
2825
  usage.outputTokens = value.response.usage.output_tokens;
2726
2826
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
2727
- usage.reasoningTokens = (_c = (_b = value.response.usage.output_tokens_details) == null ? void 0 : _b.reasoning_tokens) != null ? _c : void 0;
2728
- usage.cachedInputTokens = (_e = (_d = value.response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : void 0;
2827
+ usage.reasoningTokens = (_e = (_d = value.response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : void 0;
2828
+ usage.cachedInputTokens = (_g = (_f = value.response.usage.input_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0;
2729
2829
  } else if (isResponseAnnotationAddedChunk(value)) {
2730
2830
  controller.enqueue({
2731
2831
  type: "source",
2732
2832
  sourceType: "url",
2733
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils11.generateId)(),
2833
+ id: (_j = (_i = (_h = self.config).generateId) == null ? void 0 : _i.call(_h)) != null ? _j : (0, import_provider_utils12.generateId)(),
2734
2834
  url: value.annotation.url,
2735
2835
  title: value.annotation.title
2736
2836
  });
@@ -2755,124 +2855,129 @@ var OpenAIResponsesLanguageModel = class {
2755
2855
  };
2756
2856
  }
2757
2857
  };
2758
- var usageSchema2 = import_v414.z.object({
2759
- input_tokens: import_v414.z.number(),
2760
- input_tokens_details: import_v414.z.object({ cached_tokens: import_v414.z.number().nullish() }).nullish(),
2761
- output_tokens: import_v414.z.number(),
2762
- output_tokens_details: import_v414.z.object({ reasoning_tokens: import_v414.z.number().nullish() }).nullish()
2858
+ var usageSchema2 = import_v415.z.object({
2859
+ input_tokens: import_v415.z.number(),
2860
+ input_tokens_details: import_v415.z.object({ cached_tokens: import_v415.z.number().nullish() }).nullish(),
2861
+ output_tokens: import_v415.z.number(),
2862
+ output_tokens_details: import_v415.z.object({ reasoning_tokens: import_v415.z.number().nullish() }).nullish()
2763
2863
  });
2764
- var textDeltaChunkSchema = import_v414.z.object({
2765
- type: import_v414.z.literal("response.output_text.delta"),
2766
- item_id: import_v414.z.string(),
2767
- delta: import_v414.z.string()
2864
+ var textDeltaChunkSchema = import_v415.z.object({
2865
+ type: import_v415.z.literal("response.output_text.delta"),
2866
+ item_id: import_v415.z.string(),
2867
+ delta: import_v415.z.string()
2768
2868
  });
2769
- var responseFinishedChunkSchema = import_v414.z.object({
2770
- type: import_v414.z.enum(["response.completed", "response.incomplete"]),
2771
- response: import_v414.z.object({
2772
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullish(),
2869
+ var responseFinishedChunkSchema = import_v415.z.object({
2870
+ type: import_v415.z.enum(["response.completed", "response.incomplete"]),
2871
+ response: import_v415.z.object({
2872
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
2773
2873
  usage: usageSchema2
2774
2874
  })
2775
2875
  });
2776
- var responseCreatedChunkSchema = import_v414.z.object({
2777
- type: import_v414.z.literal("response.created"),
2778
- response: import_v414.z.object({
2779
- id: import_v414.z.string(),
2780
- created_at: import_v414.z.number(),
2781
- model: import_v414.z.string()
2876
+ var responseCreatedChunkSchema = import_v415.z.object({
2877
+ type: import_v415.z.literal("response.created"),
2878
+ response: import_v415.z.object({
2879
+ id: import_v415.z.string(),
2880
+ created_at: import_v415.z.number(),
2881
+ model: import_v415.z.string()
2782
2882
  })
2783
2883
  });
2784
- var responseOutputItemAddedSchema = import_v414.z.object({
2785
- type: import_v414.z.literal("response.output_item.added"),
2786
- output_index: import_v414.z.number(),
2787
- item: import_v414.z.discriminatedUnion("type", [
2788
- import_v414.z.object({
2789
- type: import_v414.z.literal("message"),
2790
- id: import_v414.z.string()
2884
+ var responseOutputItemAddedSchema = import_v415.z.object({
2885
+ type: import_v415.z.literal("response.output_item.added"),
2886
+ output_index: import_v415.z.number(),
2887
+ item: import_v415.z.discriminatedUnion("type", [
2888
+ import_v415.z.object({
2889
+ type: import_v415.z.literal("message"),
2890
+ id: import_v415.z.string()
2791
2891
  }),
2792
- import_v414.z.object({
2793
- type: import_v414.z.literal("reasoning"),
2794
- id: import_v414.z.string()
2892
+ import_v415.z.object({
2893
+ type: import_v415.z.literal("reasoning"),
2894
+ id: import_v415.z.string(),
2895
+ encrypted_content: import_v415.z.string().nullish(),
2896
+ summary: import_v415.z.array(
2897
+ import_v415.z.object({
2898
+ type: import_v415.z.literal("summary_text"),
2899
+ text: import_v415.z.string()
2900
+ })
2901
+ )
2795
2902
  }),
2796
- import_v414.z.object({
2797
- type: import_v414.z.literal("function_call"),
2798
- id: import_v414.z.string(),
2799
- call_id: import_v414.z.string(),
2800
- name: import_v414.z.string(),
2801
- arguments: import_v414.z.string()
2903
+ import_v415.z.object({
2904
+ type: import_v415.z.literal("function_call"),
2905
+ id: import_v415.z.string(),
2906
+ call_id: import_v415.z.string(),
2907
+ name: import_v415.z.string(),
2908
+ arguments: import_v415.z.string()
2802
2909
  }),
2803
- import_v414.z.object({
2804
- type: import_v414.z.literal("web_search_call"),
2805
- id: import_v414.z.string(),
2806
- status: import_v414.z.string()
2910
+ import_v415.z.object({
2911
+ type: import_v415.z.literal("web_search_call"),
2912
+ id: import_v415.z.string(),
2913
+ status: import_v415.z.string()
2807
2914
  }),
2808
- import_v414.z.object({
2809
- type: import_v414.z.literal("computer_call"),
2810
- id: import_v414.z.string(),
2811
- status: import_v414.z.string()
2915
+ import_v415.z.object({
2916
+ type: import_v415.z.literal("computer_call"),
2917
+ id: import_v415.z.string(),
2918
+ status: import_v415.z.string()
2812
2919
  })
2813
2920
  ])
2814
2921
  });
2815
- var responseOutputItemDoneSchema = import_v414.z.object({
2816
- type: import_v414.z.literal("response.output_item.done"),
2817
- output_index: import_v414.z.number(),
2818
- item: import_v414.z.discriminatedUnion("type", [
2819
- import_v414.z.object({
2820
- type: import_v414.z.literal("message"),
2821
- id: import_v414.z.string()
2922
+ var responseOutputItemDoneSchema = import_v415.z.object({
2923
+ type: import_v415.z.literal("response.output_item.done"),
2924
+ output_index: import_v415.z.number(),
2925
+ item: import_v415.z.discriminatedUnion("type", [
2926
+ import_v415.z.object({
2927
+ type: import_v415.z.literal("message"),
2928
+ id: import_v415.z.string()
2822
2929
  }),
2823
- import_v414.z.object({
2824
- type: import_v414.z.literal("reasoning"),
2825
- id: import_v414.z.string()
2930
+ import_v415.z.object({
2931
+ type: import_v415.z.literal("reasoning"),
2932
+ id: import_v415.z.string(),
2933
+ encrypted_content: import_v415.z.string().nullish(),
2934
+ summary: import_v415.z.array(
2935
+ import_v415.z.object({
2936
+ type: import_v415.z.literal("summary_text"),
2937
+ text: import_v415.z.string()
2938
+ })
2939
+ )
2826
2940
  }),
2827
- import_v414.z.object({
2828
- type: import_v414.z.literal("function_call"),
2829
- id: import_v414.z.string(),
2830
- call_id: import_v414.z.string(),
2831
- name: import_v414.z.string(),
2832
- arguments: import_v414.z.string(),
2833
- status: import_v414.z.literal("completed")
2941
+ import_v415.z.object({
2942
+ type: import_v415.z.literal("function_call"),
2943
+ id: import_v415.z.string(),
2944
+ call_id: import_v415.z.string(),
2945
+ name: import_v415.z.string(),
2946
+ arguments: import_v415.z.string(),
2947
+ status: import_v415.z.literal("completed")
2834
2948
  }),
2835
- import_v414.z.object({
2836
- type: import_v414.z.literal("web_search_call"),
2837
- id: import_v414.z.string(),
2838
- status: import_v414.z.literal("completed")
2949
+ import_v415.z.object({
2950
+ type: import_v415.z.literal("web_search_call"),
2951
+ id: import_v415.z.string(),
2952
+ status: import_v415.z.literal("completed")
2839
2953
  }),
2840
- import_v414.z.object({
2841
- type: import_v414.z.literal("computer_call"),
2842
- id: import_v414.z.string(),
2843
- status: import_v414.z.literal("completed")
2954
+ import_v415.z.object({
2955
+ type: import_v415.z.literal("computer_call"),
2956
+ id: import_v415.z.string(),
2957
+ status: import_v415.z.literal("completed")
2844
2958
  })
2845
2959
  ])
2846
2960
  });
2847
- var responseFunctionCallArgumentsDeltaSchema = import_v414.z.object({
2848
- type: import_v414.z.literal("response.function_call_arguments.delta"),
2849
- item_id: import_v414.z.string(),
2850
- output_index: import_v414.z.number(),
2851
- delta: import_v414.z.string()
2961
+ var responseFunctionCallArgumentsDeltaSchema = import_v415.z.object({
2962
+ type: import_v415.z.literal("response.function_call_arguments.delta"),
2963
+ item_id: import_v415.z.string(),
2964
+ output_index: import_v415.z.number(),
2965
+ delta: import_v415.z.string()
2852
2966
  });
2853
- var responseAnnotationAddedSchema = import_v414.z.object({
2854
- type: import_v414.z.literal("response.output_text.annotation.added"),
2855
- annotation: import_v414.z.object({
2856
- type: import_v414.z.literal("url_citation"),
2857
- url: import_v414.z.string(),
2858
- title: import_v414.z.string()
2967
+ var responseAnnotationAddedSchema = import_v415.z.object({
2968
+ type: import_v415.z.literal("response.output_text.annotation.added"),
2969
+ annotation: import_v415.z.object({
2970
+ type: import_v415.z.literal("url_citation"),
2971
+ url: import_v415.z.string(),
2972
+ title: import_v415.z.string()
2859
2973
  })
2860
2974
  });
2861
- var responseReasoningSummaryTextDeltaSchema = import_v414.z.object({
2862
- type: import_v414.z.literal("response.reasoning_summary_text.delta"),
2863
- item_id: import_v414.z.string(),
2864
- output_index: import_v414.z.number(),
2865
- summary_index: import_v414.z.number(),
2866
- delta: import_v414.z.string()
2867
- });
2868
- var responseReasoningSummaryPartDoneSchema = import_v414.z.object({
2869
- type: import_v414.z.literal("response.reasoning_summary_part.done"),
2870
- item_id: import_v414.z.string(),
2871
- output_index: import_v414.z.number(),
2872
- summary_index: import_v414.z.number(),
2873
- part: import_v414.z.unknown().nullish()
2975
+ var responseReasoningSummaryTextDeltaSchema = import_v415.z.object({
2976
+ type: import_v415.z.literal("response.reasoning_summary_text.delta"),
2977
+ item_id: import_v415.z.string(),
2978
+ delta: import_v415.z.string()
2874
2979
  });
2875
- var openaiResponsesChunkSchema = import_v414.z.union([
2980
+ var openaiResponsesChunkSchema = import_v415.z.union([
2876
2981
  textDeltaChunkSchema,
2877
2982
  responseFinishedChunkSchema,
2878
2983
  responseCreatedChunkSchema,
@@ -2881,8 +2986,7 @@ var openaiResponsesChunkSchema = import_v414.z.union([
2881
2986
  responseFunctionCallArgumentsDeltaSchema,
2882
2987
  responseAnnotationAddedSchema,
2883
2988
  responseReasoningSummaryTextDeltaSchema,
2884
- responseReasoningSummaryPartDoneSchema,
2885
- import_v414.z.object({ type: import_v414.z.string() }).passthrough()
2989
+ import_v415.z.object({ type: import_v415.z.string() }).passthrough()
2886
2990
  // fallback for unknown chunks
2887
2991
  ]);
2888
2992
  function isTextDeltaChunk(chunk) {
@@ -2910,7 +3014,7 @@ function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2910
3014
  return chunk.type === "response.reasoning_summary_text.delta";
2911
3015
  }
2912
3016
  function getResponsesModelConfig(modelId) {
2913
- if (modelId.startsWith("o")) {
3017
+ if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
2914
3018
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
2915
3019
  return {
2916
3020
  isReasoningModel: true,
@@ -2933,17 +3037,18 @@ function getResponsesModelConfig(modelId) {
2933
3037
  function supportsFlexProcessing2(modelId) {
2934
3038
  return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
2935
3039
  }
2936
- var openaiResponsesProviderOptionsSchema = import_v414.z.object({
2937
- metadata: import_v414.z.any().nullish(),
2938
- parallelToolCalls: import_v414.z.boolean().nullish(),
2939
- previousResponseId: import_v414.z.string().nullish(),
2940
- store: import_v414.z.boolean().nullish(),
2941
- user: import_v414.z.string().nullish(),
2942
- reasoningEffort: import_v414.z.string().nullish(),
2943
- strictSchemas: import_v414.z.boolean().nullish(),
2944
- instructions: import_v414.z.string().nullish(),
2945
- reasoningSummary: import_v414.z.string().nullish(),
2946
- serviceTier: import_v414.z.enum(["auto", "flex"]).nullish()
3040
+ var openaiResponsesProviderOptionsSchema = import_v415.z.object({
3041
+ metadata: import_v415.z.any().nullish(),
3042
+ parallelToolCalls: import_v415.z.boolean().nullish(),
3043
+ previousResponseId: import_v415.z.string().nullish(),
3044
+ store: import_v415.z.boolean().nullish(),
3045
+ user: import_v415.z.string().nullish(),
3046
+ reasoningEffort: import_v415.z.string().nullish(),
3047
+ strictJsonSchema: import_v415.z.boolean().nullish(),
3048
+ instructions: import_v415.z.string().nullish(),
3049
+ reasoningSummary: import_v415.z.string().nullish(),
3050
+ serviceTier: import_v415.z.enum(["auto", "flex"]).nullish(),
3051
+ include: import_v415.z.array(import_v415.z.enum(["reasoning.encrypted_content"])).nullish()
2947
3052
  });
2948
3053
  // Annotate the CommonJS export names for ESM import in node:
2949
3054
  0 && (module.exports = {