@ai-sdk/openai 1.3.16 → 1.3.17

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.
@@ -360,6 +360,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
360
360
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
361
361
  strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
362
362
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
+ reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
364
  }, "strip", z.ZodTypeAny, {
364
365
  user?: string | null | undefined;
365
366
  store?: boolean | null | undefined;
@@ -369,6 +370,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
369
370
  parallelToolCalls?: boolean | null | undefined;
370
371
  previousResponseId?: string | null | undefined;
371
372
  strictSchemas?: boolean | null | undefined;
373
+ reasoningSummary?: string | null | undefined;
372
374
  }, {
373
375
  user?: string | null | undefined;
374
376
  store?: boolean | null | undefined;
@@ -378,6 +380,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
378
380
  parallelToolCalls?: boolean | null | undefined;
379
381
  previousResponseId?: string | null | undefined;
380
382
  strictSchemas?: boolean | null | undefined;
383
+ reasoningSummary?: string | null | undefined;
381
384
  }>;
382
385
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
383
386
 
@@ -360,6 +360,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
360
360
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
361
361
  strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
362
362
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
+ reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
364
  }, "strip", z.ZodTypeAny, {
364
365
  user?: string | null | undefined;
365
366
  store?: boolean | null | undefined;
@@ -369,6 +370,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
369
370
  parallelToolCalls?: boolean | null | undefined;
370
371
  previousResponseId?: string | null | undefined;
371
372
  strictSchemas?: boolean | null | undefined;
373
+ reasoningSummary?: string | null | undefined;
372
374
  }, {
373
375
  user?: string | null | undefined;
374
376
  store?: boolean | null | undefined;
@@ -378,6 +380,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
378
380
  parallelToolCalls?: boolean | null | undefined;
379
381
  previousResponseId?: string | null | undefined;
380
382
  strictSchemas?: boolean | null | undefined;
383
+ reasoningSummary?: string | null | undefined;
381
384
  }>;
382
385
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
383
386
 
@@ -2202,8 +2202,15 @@ var OpenAIResponsesLanguageModel = class {
2202
2202
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2203
2203
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2204
2204
  // model-specific settings:
2205
- ...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2206
- reasoning: { effort: openaiOptions == null ? void 0 : openaiOptions.reasoningEffort }
2205
+ ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2206
+ reasoning: {
2207
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2208
+ effort: openaiOptions.reasoningEffort
2209
+ },
2210
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
2211
+ summary: openaiOptions.reasoningSummary
2212
+ }
2213
+ }
2207
2214
  },
2208
2215
  ...modelConfig.requiredAutoTruncation && {
2209
2216
  truncation: "auto"
@@ -2285,7 +2292,7 @@ var OpenAIResponsesLanguageModel = class {
2285
2292
  }
2286
2293
  }
2287
2294
  async doGenerate(options) {
2288
- var _a, _b, _c, _d, _e;
2295
+ var _a, _b, _c, _d, _e, _f, _g;
2289
2296
  const { args: body, warnings } = this.getArgs(options);
2290
2297
  const {
2291
2298
  responseHeaders,
@@ -2338,7 +2345,13 @@ var OpenAIResponsesLanguageModel = class {
2338
2345
  type: import_zod8.z.literal("computer_call")
2339
2346
  }),
2340
2347
  import_zod8.z.object({
2341
- type: import_zod8.z.literal("reasoning")
2348
+ type: import_zod8.z.literal("reasoning"),
2349
+ summary: import_zod8.z.array(
2350
+ import_zod8.z.object({
2351
+ type: import_zod8.z.literal("summary_text"),
2352
+ text: import_zod8.z.string()
2353
+ })
2354
+ )
2342
2355
  })
2343
2356
  ])
2344
2357
  ),
@@ -2356,6 +2369,7 @@ var OpenAIResponsesLanguageModel = class {
2356
2369
  toolName: output.name,
2357
2370
  args: output.arguments
2358
2371
  }));
2372
+ const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
2359
2373
  return {
2360
2374
  text: outputTextElements.map((content) => content.text).join("\n"),
2361
2375
  sources: outputTextElements.flatMap(
@@ -2370,10 +2384,14 @@ var OpenAIResponsesLanguageModel = class {
2370
2384
  })
2371
2385
  ),
2372
2386
  finishReason: mapOpenAIResponseFinishReason({
2373
- finishReason: (_a = response.incomplete_details) == null ? void 0 : _a.reason,
2387
+ finishReason: (_c = response.incomplete_details) == null ? void 0 : _c.reason,
2374
2388
  hasToolCalls: toolCalls.length > 0
2375
2389
  }),
2376
2390
  toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
2391
+ reasoning: reasoningSummary ? reasoningSummary.map((summary) => ({
2392
+ type: "text",
2393
+ text: summary.text
2394
+ })) : void 0,
2377
2395
  usage: {
2378
2396
  promptTokens: response.usage.input_tokens,
2379
2397
  completionTokens: response.usage.output_tokens
@@ -2397,8 +2415,8 @@ var OpenAIResponsesLanguageModel = class {
2397
2415
  providerMetadata: {
2398
2416
  openai: {
2399
2417
  responseId: response.id,
2400
- cachedPromptTokens: (_c = (_b = response.usage.input_tokens_details) == null ? void 0 : _b.cached_tokens) != null ? _c : null,
2401
- reasoningTokens: (_e = (_d = response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : null
2418
+ cachedPromptTokens: (_e = (_d = response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : null,
2419
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : null
2402
2420
  }
2403
2421
  },
2404
2422
  warnings
@@ -2481,6 +2499,11 @@ var OpenAIResponsesLanguageModel = class {
2481
2499
  type: "text-delta",
2482
2500
  textDelta: value.delta
2483
2501
  });
2502
+ } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2503
+ controller.enqueue({
2504
+ type: "reasoning",
2505
+ textDelta: value.delta
2506
+ });
2484
2507
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
2485
2508
  ongoingToolCalls[value.output_index] = void 0;
2486
2509
  hasToolCalls = true;
@@ -2612,6 +2635,13 @@ var responseAnnotationAddedSchema = import_zod8.z.object({
2612
2635
  title: import_zod8.z.string()
2613
2636
  })
2614
2637
  });
2638
+ var responseReasoningSummaryTextDeltaSchema = import_zod8.z.object({
2639
+ type: import_zod8.z.literal("response.reasoning_summary_text.delta"),
2640
+ item_id: import_zod8.z.string(),
2641
+ output_index: import_zod8.z.number(),
2642
+ summary_index: import_zod8.z.number(),
2643
+ delta: import_zod8.z.string()
2644
+ });
2615
2645
  var openaiResponsesChunkSchema = import_zod8.z.union([
2616
2646
  textDeltaChunkSchema,
2617
2647
  responseFinishedChunkSchema,
@@ -2620,6 +2650,7 @@ var openaiResponsesChunkSchema = import_zod8.z.union([
2620
2650
  responseFunctionCallArgumentsDeltaSchema,
2621
2651
  responseOutputItemAddedSchema,
2622
2652
  responseAnnotationAddedSchema,
2653
+ responseReasoningSummaryTextDeltaSchema,
2623
2654
  import_zod8.z.object({ type: import_zod8.z.string() }).passthrough()
2624
2655
  // fallback for unknown chunks
2625
2656
  ]);
@@ -2644,6 +2675,9 @@ function isResponseOutputItemAddedChunk(chunk) {
2644
2675
  function isResponseAnnotationAddedChunk(chunk) {
2645
2676
  return chunk.type === "response.output_text.annotation.added";
2646
2677
  }
2678
+ function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2679
+ return chunk.type === "response.reasoning_summary_text.delta";
2680
+ }
2647
2681
  function getResponsesModelConfig(modelId) {
2648
2682
  if (modelId.startsWith("o")) {
2649
2683
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2673,7 +2707,8 @@ var openaiResponsesProviderOptionsSchema = import_zod8.z.object({
2673
2707
  user: import_zod8.z.string().nullish(),
2674
2708
  reasoningEffort: import_zod8.z.string().nullish(),
2675
2709
  strictSchemas: import_zod8.z.boolean().nullish(),
2676
- instructions: import_zod8.z.string().nullish()
2710
+ instructions: import_zod8.z.string().nullish(),
2711
+ reasoningSummary: import_zod8.z.string().nullish()
2677
2712
  });
2678
2713
  // Annotate the CommonJS export names for ESM import in node:
2679
2714
  0 && (module.exports = {