@ai-sdk/openai 1.3.15 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 1.3.17
4
+
5
+ ### Patch Changes
6
+
7
+ - ca7bce3: feat (providers/openai): add support for reasoning summaries
8
+
9
+ ## 1.3.16
10
+
11
+ ### Patch Changes
12
+
13
+ - bd6e457: feat (provider/openai): o4 updates for responses api
14
+
3
15
  ## 1.3.15
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -181,7 +181,7 @@ interface OpenAIImageSettings {
181
181
 
182
182
  type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
183
183
 
184
- type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
184
+ type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
185
185
 
186
186
  declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
187
187
  declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
@@ -315,6 +315,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
315
315
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
316
316
  strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
317
317
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
318
+ reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
318
319
  }, "strip", z.ZodTypeAny, {
319
320
  user?: string | null | undefined;
320
321
  store?: boolean | null | undefined;
@@ -324,6 +325,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
324
325
  previousResponseId?: string | null | undefined;
325
326
  strictSchemas?: boolean | null | undefined;
326
327
  instructions?: string | null | undefined;
328
+ reasoningSummary?: string | null | undefined;
327
329
  }, {
328
330
  user?: string | null | undefined;
329
331
  store?: boolean | null | undefined;
@@ -333,6 +335,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
333
335
  previousResponseId?: string | null | undefined;
334
336
  strictSchemas?: boolean | null | undefined;
335
337
  instructions?: string | null | undefined;
338
+ reasoningSummary?: string | null | undefined;
336
339
  }>;
337
340
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
338
341
 
package/dist/index.d.ts CHANGED
@@ -181,7 +181,7 @@ interface OpenAIImageSettings {
181
181
 
182
182
  type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
183
183
 
184
- type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
184
+ type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-10-01' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
185
185
 
186
186
  declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
187
187
  declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
@@ -315,6 +315,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
315
315
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
316
316
  strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
317
317
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
318
+ reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
318
319
  }, "strip", z.ZodTypeAny, {
319
320
  user?: string | null | undefined;
320
321
  store?: boolean | null | undefined;
@@ -324,6 +325,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
324
325
  previousResponseId?: string | null | undefined;
325
326
  strictSchemas?: boolean | null | undefined;
326
327
  instructions?: string | null | undefined;
328
+ reasoningSummary?: string | null | undefined;
327
329
  }, {
328
330
  user?: string | null | undefined;
329
331
  store?: boolean | null | undefined;
@@ -333,6 +335,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
333
335
  previousResponseId?: string | null | undefined;
334
336
  strictSchemas?: boolean | null | undefined;
335
337
  instructions?: string | null | undefined;
338
+ reasoningSummary?: string | null | undefined;
336
339
  }>;
337
340
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
338
341
 
package/dist/index.js CHANGED
@@ -1053,7 +1053,7 @@ var openaiChatChunkSchema = import_zod2.z.union([
1053
1053
  openaiErrorDataSchema
1054
1054
  ]);
1055
1055
  function isReasoningModel(modelId) {
1056
- return modelId === "o1" || modelId.startsWith("o1-") || modelId === "o3" || modelId.startsWith("o3-") || modelId.startsWith("o4-");
1056
+ return modelId.startsWith("o");
1057
1057
  }
1058
1058
  function isAudioModel(modelId) {
1059
1059
  return modelId.startsWith("gpt-4o-audio-preview");
@@ -2100,8 +2100,15 @@ var OpenAIResponsesLanguageModel = class {
2100
2100
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2101
2101
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2102
2102
  // model-specific settings:
2103
- ...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2104
- reasoning: { effort: openaiOptions == null ? void 0 : openaiOptions.reasoningEffort }
2103
+ ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2104
+ reasoning: {
2105
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2106
+ effort: openaiOptions.reasoningEffort
2107
+ },
2108
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
2109
+ summary: openaiOptions.reasoningSummary
2110
+ }
2111
+ }
2105
2112
  },
2106
2113
  ...modelConfig.requiredAutoTruncation && {
2107
2114
  truncation: "auto"
@@ -2183,7 +2190,7 @@ var OpenAIResponsesLanguageModel = class {
2183
2190
  }
2184
2191
  }
2185
2192
  async doGenerate(options) {
2186
- var _a, _b, _c, _d, _e;
2193
+ var _a, _b, _c, _d, _e, _f, _g;
2187
2194
  const { args: body, warnings } = this.getArgs(options);
2188
2195
  const {
2189
2196
  responseHeaders,
@@ -2236,7 +2243,13 @@ var OpenAIResponsesLanguageModel = class {
2236
2243
  type: import_zod7.z.literal("computer_call")
2237
2244
  }),
2238
2245
  import_zod7.z.object({
2239
- type: import_zod7.z.literal("reasoning")
2246
+ type: import_zod7.z.literal("reasoning"),
2247
+ summary: import_zod7.z.array(
2248
+ import_zod7.z.object({
2249
+ type: import_zod7.z.literal("summary_text"),
2250
+ text: import_zod7.z.string()
2251
+ })
2252
+ )
2240
2253
  })
2241
2254
  ])
2242
2255
  ),
@@ -2254,6 +2267,7 @@ var OpenAIResponsesLanguageModel = class {
2254
2267
  toolName: output.name,
2255
2268
  args: output.arguments
2256
2269
  }));
2270
+ const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
2257
2271
  return {
2258
2272
  text: outputTextElements.map((content) => content.text).join("\n"),
2259
2273
  sources: outputTextElements.flatMap(
@@ -2268,10 +2282,14 @@ var OpenAIResponsesLanguageModel = class {
2268
2282
  })
2269
2283
  ),
2270
2284
  finishReason: mapOpenAIResponseFinishReason({
2271
- finishReason: (_a = response.incomplete_details) == null ? void 0 : _a.reason,
2285
+ finishReason: (_c = response.incomplete_details) == null ? void 0 : _c.reason,
2272
2286
  hasToolCalls: toolCalls.length > 0
2273
2287
  }),
2274
2288
  toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
2289
+ reasoning: reasoningSummary ? reasoningSummary.map((summary) => ({
2290
+ type: "text",
2291
+ text: summary.text
2292
+ })) : void 0,
2275
2293
  usage: {
2276
2294
  promptTokens: response.usage.input_tokens,
2277
2295
  completionTokens: response.usage.output_tokens
@@ -2295,8 +2313,8 @@ var OpenAIResponsesLanguageModel = class {
2295
2313
  providerMetadata: {
2296
2314
  openai: {
2297
2315
  responseId: response.id,
2298
- cachedPromptTokens: (_c = (_b = response.usage.input_tokens_details) == null ? void 0 : _b.cached_tokens) != null ? _c : null,
2299
- reasoningTokens: (_e = (_d = response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : null
2316
+ cachedPromptTokens: (_e = (_d = response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : null,
2317
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : null
2300
2318
  }
2301
2319
  },
2302
2320
  warnings
@@ -2379,6 +2397,11 @@ var OpenAIResponsesLanguageModel = class {
2379
2397
  type: "text-delta",
2380
2398
  textDelta: value.delta
2381
2399
  });
2400
+ } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2401
+ controller.enqueue({
2402
+ type: "reasoning",
2403
+ textDelta: value.delta
2404
+ });
2382
2405
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
2383
2406
  ongoingToolCalls[value.output_index] = void 0;
2384
2407
  hasToolCalls = true;
@@ -2510,6 +2533,13 @@ var responseAnnotationAddedSchema = import_zod7.z.object({
2510
2533
  title: import_zod7.z.string()
2511
2534
  })
2512
2535
  });
2536
+ var responseReasoningSummaryTextDeltaSchema = import_zod7.z.object({
2537
+ type: import_zod7.z.literal("response.reasoning_summary_text.delta"),
2538
+ item_id: import_zod7.z.string(),
2539
+ output_index: import_zod7.z.number(),
2540
+ summary_index: import_zod7.z.number(),
2541
+ delta: import_zod7.z.string()
2542
+ });
2513
2543
  var openaiResponsesChunkSchema = import_zod7.z.union([
2514
2544
  textDeltaChunkSchema,
2515
2545
  responseFinishedChunkSchema,
@@ -2518,6 +2548,7 @@ var openaiResponsesChunkSchema = import_zod7.z.union([
2518
2548
  responseFunctionCallArgumentsDeltaSchema,
2519
2549
  responseOutputItemAddedSchema,
2520
2550
  responseAnnotationAddedSchema,
2551
+ responseReasoningSummaryTextDeltaSchema,
2521
2552
  import_zod7.z.object({ type: import_zod7.z.string() }).passthrough()
2522
2553
  // fallback for unknown chunks
2523
2554
  ]);
@@ -2542,6 +2573,9 @@ function isResponseOutputItemAddedChunk(chunk) {
2542
2573
  function isResponseAnnotationAddedChunk(chunk) {
2543
2574
  return chunk.type === "response.output_text.annotation.added";
2544
2575
  }
2576
+ function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2577
+ return chunk.type === "response.reasoning_summary_text.delta";
2578
+ }
2545
2579
  function getResponsesModelConfig(modelId) {
2546
2580
  if (modelId.startsWith("o")) {
2547
2581
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2571,7 +2605,8 @@ var openaiResponsesProviderOptionsSchema = import_zod7.z.object({
2571
2605
  user: import_zod7.z.string().nullish(),
2572
2606
  reasoningEffort: import_zod7.z.string().nullish(),
2573
2607
  strictSchemas: import_zod7.z.boolean().nullish(),
2574
- instructions: import_zod7.z.string().nullish()
2608
+ instructions: import_zod7.z.string().nullish(),
2609
+ reasoningSummary: import_zod7.z.string().nullish()
2575
2610
  });
2576
2611
 
2577
2612
  // src/openai-tools.ts