@ai-sdk/openai 1.3.16 → 1.3.18

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.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 74cd391: feat (providers/openai): support gpt-image-1 image generation
8
+
9
+ ## 1.3.17
10
+
11
+ ### Patch Changes
12
+
13
+ - ca7bce3: feat (providers/openai): add support for reasoning summaries
14
+
3
15
  ## 1.3.16
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -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
@@ -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
@@ -1533,8 +1533,10 @@ var import_zod5 = require("zod");
1533
1533
  // src/openai-image-settings.ts
1534
1534
  var modelMaxImagesPerCall = {
1535
1535
  "dall-e-3": 1,
1536
- "dall-e-2": 10
1536
+ "dall-e-2": 10,
1537
+ "gpt-image-1": 10
1537
1538
  };
1539
+ var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1538
1540
 
1539
1541
  // src/openai-image-model.ts
1540
1542
  var OpenAIImageModel = class {
@@ -1586,7 +1588,7 @@ var OpenAIImageModel = class {
1586
1588
  n,
1587
1589
  size,
1588
1590
  ...(_d = providerOptions.openai) != null ? _d : {},
1589
- response_format: "b64_json"
1591
+ ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1590
1592
  },
1591
1593
  failedResponseHandler: openaiFailedResponseHandler,
1592
1594
  successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
@@ -2100,8 +2102,15 @@ var OpenAIResponsesLanguageModel = class {
2100
2102
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2101
2103
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2102
2104
  // model-specific settings:
2103
- ...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2104
- reasoning: { effort: openaiOptions == null ? void 0 : openaiOptions.reasoningEffort }
2105
+ ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2106
+ reasoning: {
2107
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
2108
+ effort: openaiOptions.reasoningEffort
2109
+ },
2110
+ ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
2111
+ summary: openaiOptions.reasoningSummary
2112
+ }
2113
+ }
2105
2114
  },
2106
2115
  ...modelConfig.requiredAutoTruncation && {
2107
2116
  truncation: "auto"
@@ -2183,7 +2192,7 @@ var OpenAIResponsesLanguageModel = class {
2183
2192
  }
2184
2193
  }
2185
2194
  async doGenerate(options) {
2186
- var _a, _b, _c, _d, _e;
2195
+ var _a, _b, _c, _d, _e, _f, _g;
2187
2196
  const { args: body, warnings } = this.getArgs(options);
2188
2197
  const {
2189
2198
  responseHeaders,
@@ -2236,7 +2245,13 @@ var OpenAIResponsesLanguageModel = class {
2236
2245
  type: import_zod7.z.literal("computer_call")
2237
2246
  }),
2238
2247
  import_zod7.z.object({
2239
- type: import_zod7.z.literal("reasoning")
2248
+ type: import_zod7.z.literal("reasoning"),
2249
+ summary: import_zod7.z.array(
2250
+ import_zod7.z.object({
2251
+ type: import_zod7.z.literal("summary_text"),
2252
+ text: import_zod7.z.string()
2253
+ })
2254
+ )
2240
2255
  })
2241
2256
  ])
2242
2257
  ),
@@ -2254,6 +2269,7 @@ var OpenAIResponsesLanguageModel = class {
2254
2269
  toolName: output.name,
2255
2270
  args: output.arguments
2256
2271
  }));
2272
+ const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
2257
2273
  return {
2258
2274
  text: outputTextElements.map((content) => content.text).join("\n"),
2259
2275
  sources: outputTextElements.flatMap(
@@ -2268,10 +2284,14 @@ var OpenAIResponsesLanguageModel = class {
2268
2284
  })
2269
2285
  ),
2270
2286
  finishReason: mapOpenAIResponseFinishReason({
2271
- finishReason: (_a = response.incomplete_details) == null ? void 0 : _a.reason,
2287
+ finishReason: (_c = response.incomplete_details) == null ? void 0 : _c.reason,
2272
2288
  hasToolCalls: toolCalls.length > 0
2273
2289
  }),
2274
2290
  toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
2291
+ reasoning: reasoningSummary ? reasoningSummary.map((summary) => ({
2292
+ type: "text",
2293
+ text: summary.text
2294
+ })) : void 0,
2275
2295
  usage: {
2276
2296
  promptTokens: response.usage.input_tokens,
2277
2297
  completionTokens: response.usage.output_tokens
@@ -2295,8 +2315,8 @@ var OpenAIResponsesLanguageModel = class {
2295
2315
  providerMetadata: {
2296
2316
  openai: {
2297
2317
  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
2318
+ cachedPromptTokens: (_e = (_d = response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : null,
2319
+ reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : null
2300
2320
  }
2301
2321
  },
2302
2322
  warnings
@@ -2379,6 +2399,11 @@ var OpenAIResponsesLanguageModel = class {
2379
2399
  type: "text-delta",
2380
2400
  textDelta: value.delta
2381
2401
  });
2402
+ } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2403
+ controller.enqueue({
2404
+ type: "reasoning",
2405
+ textDelta: value.delta
2406
+ });
2382
2407
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
2383
2408
  ongoingToolCalls[value.output_index] = void 0;
2384
2409
  hasToolCalls = true;
@@ -2510,6 +2535,13 @@ var responseAnnotationAddedSchema = import_zod7.z.object({
2510
2535
  title: import_zod7.z.string()
2511
2536
  })
2512
2537
  });
2538
+ var responseReasoningSummaryTextDeltaSchema = import_zod7.z.object({
2539
+ type: import_zod7.z.literal("response.reasoning_summary_text.delta"),
2540
+ item_id: import_zod7.z.string(),
2541
+ output_index: import_zod7.z.number(),
2542
+ summary_index: import_zod7.z.number(),
2543
+ delta: import_zod7.z.string()
2544
+ });
2513
2545
  var openaiResponsesChunkSchema = import_zod7.z.union([
2514
2546
  textDeltaChunkSchema,
2515
2547
  responseFinishedChunkSchema,
@@ -2518,6 +2550,7 @@ var openaiResponsesChunkSchema = import_zod7.z.union([
2518
2550
  responseFunctionCallArgumentsDeltaSchema,
2519
2551
  responseOutputItemAddedSchema,
2520
2552
  responseAnnotationAddedSchema,
2553
+ responseReasoningSummaryTextDeltaSchema,
2521
2554
  import_zod7.z.object({ type: import_zod7.z.string() }).passthrough()
2522
2555
  // fallback for unknown chunks
2523
2556
  ]);
@@ -2542,6 +2575,9 @@ function isResponseOutputItemAddedChunk(chunk) {
2542
2575
  function isResponseAnnotationAddedChunk(chunk) {
2543
2576
  return chunk.type === "response.output_text.annotation.added";
2544
2577
  }
2578
+ function isResponseReasoningSummaryTextDeltaChunk(chunk) {
2579
+ return chunk.type === "response.reasoning_summary_text.delta";
2580
+ }
2545
2581
  function getResponsesModelConfig(modelId) {
2546
2582
  if (modelId.startsWith("o")) {
2547
2583
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2571,7 +2607,8 @@ var openaiResponsesProviderOptionsSchema = import_zod7.z.object({
2571
2607
  user: import_zod7.z.string().nullish(),
2572
2608
  reasoningEffort: import_zod7.z.string().nullish(),
2573
2609
  strictSchemas: import_zod7.z.boolean().nullish(),
2574
- instructions: import_zod7.z.string().nullish()
2610
+ instructions: import_zod7.z.string().nullish(),
2611
+ reasoningSummary: import_zod7.z.string().nullish()
2575
2612
  });
2576
2613
 
2577
2614
  // src/openai-tools.ts