@ai-sdk/openai 3.0.136 → 3.0.137

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.
@@ -2088,6 +2088,9 @@ var OpenAIEmbeddingModel = class {
2088
2088
  };
2089
2089
 
2090
2090
  // src/image/openai-image-model.ts
2091
+ import {
2092
+ InvalidArgumentError
2093
+ } from "@ai-sdk/provider";
2091
2094
  import {
2092
2095
  combineHeaders as combineHeaders4,
2093
2096
  convertBase64ToUint8Array,
@@ -2142,6 +2145,8 @@ var modelMaxImagesPerCall = {
2142
2145
  "gpt-image-1-mini": 10,
2143
2146
  "gpt-image-1.5": 10,
2144
2147
  "gpt-image-2": 10,
2148
+ "gpt-image-2.6-flare": 10,
2149
+ "gpt-image-2.6-sunburst": 10,
2145
2150
  "gpt-image-2.5-flare": 10,
2146
2151
  "gpt-image-2.5-flare-2026-09-08": 10,
2147
2152
  "gpt-image-2.5-sunburst": 10,
@@ -2177,6 +2182,11 @@ var baseImageModelOptionsObject = () => z9.object({
2177
2182
  * Format in which the generated image(s) are returned.
2178
2183
  */
2179
2184
  outputFormat: z9.enum(["png", "jpeg", "webp"]).optional(),
2185
+ /**
2186
+ * How much detail the model puts into the image. Supported by GPT Image
2187
+ * 2.6 models. The API defaults to `high`.
2188
+ */
2189
+ complexity: z9.enum(["low", "medium", "high"]).optional(),
2180
2190
  /**
2181
2191
  * Compression level (0-100) for the generated image(s). Applies to the
2182
2192
  * `jpeg` and `webp` output formats.
@@ -2186,7 +2196,13 @@ var baseImageModelOptionsObject = () => z9.object({
2186
2196
  * A unique identifier representing your end-user, which can help OpenAI
2187
2197
  * to monitor and detect abuse.
2188
2198
  */
2189
- user: z9.string().optional()
2199
+ user: z9.string().optional(),
2200
+ /**
2201
+ * A stable identifier used to help detect users of your application that
2202
+ * may be violating OpenAI's usage policies. Should be a hashed username
2203
+ * or email address.
2204
+ */
2205
+ safetyIdentifier: z9.string().max(128).optional()
2190
2206
  });
2191
2207
  var openaiImageModelOptions = lazySchema9(
2192
2208
  () => zodSchema9(baseImageModelOptionsObject())
@@ -2200,6 +2216,22 @@ var openaiImageModelGenerationOptions = lazySchema9(
2200
2216
  * looking images.
2201
2217
  */
2202
2218
  style: z9.enum(["vivid", "natural"]).optional(),
2219
+ /**
2220
+ * Format in which the generated image(s) are returned. `gif` produces
2221
+ * an animated GIF and is supported by GPT Image 2.6 models.
2222
+ */
2223
+ outputFormat: z9.enum(["png", "jpeg", "webp", "gif"]).optional(),
2224
+ /**
2225
+ * Number of frames (2-64) of an animated GIF. Only applies to the `gif`
2226
+ * output format. The API defaults to 9.
2227
+ */
2228
+ frameCount: z9.number().int().min(2).max(64).optional(),
2229
+ /**
2230
+ * Duration of each frame in milliseconds (20-2000) of an animated GIF.
2231
+ * The API rounds it to the nearest 10 ms. Only applies to the `gif`
2232
+ * output format. The API defaults to 200.
2233
+ */
2234
+ frameDurationMs: z9.number().int().min(20).max(2e3).optional(),
2203
2235
  /**
2204
2236
  * Content moderation level for the generated image(s). `low` applies
2205
2237
  * less restrictive filtering.
@@ -2214,7 +2246,14 @@ var openaiImageModelEditOptions = lazySchema9(
2214
2246
  /**
2215
2247
  * Fidelity of the output image(s) to the input image(s).
2216
2248
  */
2217
- inputFidelity: z9.enum(["high", "low"]).optional()
2249
+ inputFidelity: z9.enum(["high", "low"]).optional(),
2250
+ /**
2251
+ * A transparent PNG overlaid on the first input image to mark up the
2252
+ * regions to change, as an HTTPS URL or a base64 data URL. It must match
2253
+ * the dimensions of the first image. Supported by GPT Image 2.5 and 2.6
2254
+ * models. Cannot be combined with a `mask`.
2255
+ */
2256
+ markup: z9.string().optional()
2218
2257
  })
2219
2258
  )
2220
2259
  );
@@ -2263,6 +2302,12 @@ var OpenAIImageModel = class {
2263
2302
  providerOptions,
2264
2303
  schema: openaiImageModelEditOptions
2265
2304
  })) != null ? _d : {};
2305
+ if (mask != null && openaiOptions2.markup != null) {
2306
+ throw new InvalidArgumentError({
2307
+ argument: "providerOptions.openai.markup",
2308
+ message: "`markup` cannot be combined with `mask`."
2309
+ });
2310
+ }
2266
2311
  const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
2267
2312
  url: this.config.url({
2268
2313
  path: "/images/edits",
@@ -2287,14 +2332,17 @@ var OpenAIImageModel = class {
2287
2332
  )
2288
2333
  ),
2289
2334
  mask: mask != null ? await fileToBlob(mask) : void 0,
2335
+ markup: openaiOptions2.markup != null ? await markupToBlob(openaiOptions2.markup) : void 0,
2290
2336
  n,
2291
2337
  size,
2292
2338
  quality: openaiOptions2.quality,
2293
2339
  background: openaiOptions2.background,
2294
2340
  output_format: openaiOptions2.outputFormat,
2295
2341
  output_compression: openaiOptions2.outputCompression,
2342
+ complexity: openaiOptions2.complexity,
2296
2343
  input_fidelity: openaiOptions2.inputFidelity,
2297
- user: openaiOptions2.user
2344
+ user: openaiOptions2.user,
2345
+ safety_identifier: openaiOptions2.safetyIdentifier
2298
2346
  }),
2299
2347
  failedResponseHandler: openaiFailedResponseHandler,
2300
2348
  successfulResponseHandler: createJsonResponseHandler4(
@@ -2360,7 +2408,11 @@ var OpenAIImageModel = class {
2360
2408
  moderation: openaiOptions.moderation,
2361
2409
  output_format: openaiOptions.outputFormat,
2362
2410
  output_compression: openaiOptions.outputCompression,
2411
+ complexity: openaiOptions.complexity,
2412
+ frame_count: openaiOptions.frameCount,
2413
+ frame_duration_ms: openaiOptions.frameDurationMs,
2363
2414
  user: openaiOptions.user,
2415
+ safety_identifier: openaiOptions.safetyIdentifier,
2364
2416
  ...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
2365
2417
  },
2366
2418
  failedResponseHandler: openaiFailedResponseHandler,
@@ -2423,6 +2475,21 @@ function distributeTokenDetails(details, index, total) {
2423
2475
  }
2424
2476
  return result;
2425
2477
  }
2478
+ async function markupToBlob(markup) {
2479
+ const dataUrl = /^data:([^;,]*)(;base64)?,(.*)$/s.exec(markup);
2480
+ if (dataUrl == null) {
2481
+ return downloadBlob(markup);
2482
+ }
2483
+ if (dataUrl[2] == null) {
2484
+ throw new InvalidArgumentError({
2485
+ argument: "providerOptions.openai.markup",
2486
+ message: "`markup` data URLs must be base64 encoded."
2487
+ });
2488
+ }
2489
+ return new Blob([convertBase64ToUint8Array(dataUrl[3])], {
2490
+ type: dataUrl[1] || "image/png"
2491
+ });
2492
+ }
2426
2493
  async function fileToBlob(file) {
2427
2494
  if (!file) return void 0;
2428
2495
  if (file.type === "url") {