@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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +85 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +11 -2
- package/dist/internal/index.d.ts +11 -2
- package/dist/internal/index.js +84 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +70 -3
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +24 -0
- package/package.json +3 -3
- package/src/image/openai-image-model-options.ts +44 -0
- package/src/image/openai-image-model.ts +44 -4
package/dist/index.mjs
CHANGED
|
@@ -2096,6 +2096,9 @@ var OpenAIEmbeddingModel = class {
|
|
|
2096
2096
|
};
|
|
2097
2097
|
|
|
2098
2098
|
// src/image/openai-image-model.ts
|
|
2099
|
+
import {
|
|
2100
|
+
InvalidArgumentError
|
|
2101
|
+
} from "@ai-sdk/provider";
|
|
2099
2102
|
import {
|
|
2100
2103
|
combineHeaders as combineHeaders4,
|
|
2101
2104
|
convertBase64ToUint8Array,
|
|
@@ -2150,6 +2153,8 @@ var modelMaxImagesPerCall = {
|
|
|
2150
2153
|
"gpt-image-1-mini": 10,
|
|
2151
2154
|
"gpt-image-1.5": 10,
|
|
2152
2155
|
"gpt-image-2": 10,
|
|
2156
|
+
"gpt-image-2.6-flare": 10,
|
|
2157
|
+
"gpt-image-2.6-sunburst": 10,
|
|
2153
2158
|
"gpt-image-2.5-flare": 10,
|
|
2154
2159
|
"gpt-image-2.5-flare-2026-09-08": 10,
|
|
2155
2160
|
"gpt-image-2.5-sunburst": 10,
|
|
@@ -2185,6 +2190,11 @@ var baseImageModelOptionsObject = () => z9.object({
|
|
|
2185
2190
|
* Format in which the generated image(s) are returned.
|
|
2186
2191
|
*/
|
|
2187
2192
|
outputFormat: z9.enum(["png", "jpeg", "webp"]).optional(),
|
|
2193
|
+
/**
|
|
2194
|
+
* How much detail the model puts into the image. Supported by GPT Image
|
|
2195
|
+
* 2.6 models. The API defaults to `high`.
|
|
2196
|
+
*/
|
|
2197
|
+
complexity: z9.enum(["low", "medium", "high"]).optional(),
|
|
2188
2198
|
/**
|
|
2189
2199
|
* Compression level (0-100) for the generated image(s). Applies to the
|
|
2190
2200
|
* `jpeg` and `webp` output formats.
|
|
@@ -2194,7 +2204,13 @@ var baseImageModelOptionsObject = () => z9.object({
|
|
|
2194
2204
|
* A unique identifier representing your end-user, which can help OpenAI
|
|
2195
2205
|
* to monitor and detect abuse.
|
|
2196
2206
|
*/
|
|
2197
|
-
user: z9.string().optional()
|
|
2207
|
+
user: z9.string().optional(),
|
|
2208
|
+
/**
|
|
2209
|
+
* A stable identifier used to help detect users of your application that
|
|
2210
|
+
* may be violating OpenAI's usage policies. Should be a hashed username
|
|
2211
|
+
* or email address.
|
|
2212
|
+
*/
|
|
2213
|
+
safetyIdentifier: z9.string().max(128).optional()
|
|
2198
2214
|
});
|
|
2199
2215
|
var openaiImageModelOptions = lazySchema9(
|
|
2200
2216
|
() => zodSchema9(baseImageModelOptionsObject())
|
|
@@ -2208,6 +2224,22 @@ var openaiImageModelGenerationOptions = lazySchema9(
|
|
|
2208
2224
|
* looking images.
|
|
2209
2225
|
*/
|
|
2210
2226
|
style: z9.enum(["vivid", "natural"]).optional(),
|
|
2227
|
+
/**
|
|
2228
|
+
* Format in which the generated image(s) are returned. `gif` produces
|
|
2229
|
+
* an animated GIF and is supported by GPT Image 2.6 models.
|
|
2230
|
+
*/
|
|
2231
|
+
outputFormat: z9.enum(["png", "jpeg", "webp", "gif"]).optional(),
|
|
2232
|
+
/**
|
|
2233
|
+
* Number of frames (2-64) of an animated GIF. Only applies to the `gif`
|
|
2234
|
+
* output format. The API defaults to 9.
|
|
2235
|
+
*/
|
|
2236
|
+
frameCount: z9.number().int().min(2).max(64).optional(),
|
|
2237
|
+
/**
|
|
2238
|
+
* Duration of each frame in milliseconds (20-2000) of an animated GIF.
|
|
2239
|
+
* The API rounds it to the nearest 10 ms. Only applies to the `gif`
|
|
2240
|
+
* output format. The API defaults to 200.
|
|
2241
|
+
*/
|
|
2242
|
+
frameDurationMs: z9.number().int().min(20).max(2e3).optional(),
|
|
2211
2243
|
/**
|
|
2212
2244
|
* Content moderation level for the generated image(s). `low` applies
|
|
2213
2245
|
* less restrictive filtering.
|
|
@@ -2222,7 +2254,14 @@ var openaiImageModelEditOptions = lazySchema9(
|
|
|
2222
2254
|
/**
|
|
2223
2255
|
* Fidelity of the output image(s) to the input image(s).
|
|
2224
2256
|
*/
|
|
2225
|
-
inputFidelity: z9.enum(["high", "low"]).optional()
|
|
2257
|
+
inputFidelity: z9.enum(["high", "low"]).optional(),
|
|
2258
|
+
/**
|
|
2259
|
+
* A transparent PNG overlaid on the first input image to mark up the
|
|
2260
|
+
* regions to change, as an HTTPS URL or a base64 data URL. It must match
|
|
2261
|
+
* the dimensions of the first image. Supported by GPT Image 2.5 and 2.6
|
|
2262
|
+
* models. Cannot be combined with a `mask`.
|
|
2263
|
+
*/
|
|
2264
|
+
markup: z9.string().optional()
|
|
2226
2265
|
})
|
|
2227
2266
|
)
|
|
2228
2267
|
);
|
|
@@ -2271,6 +2310,12 @@ var OpenAIImageModel = class {
|
|
|
2271
2310
|
providerOptions,
|
|
2272
2311
|
schema: openaiImageModelEditOptions
|
|
2273
2312
|
})) != null ? _d : {};
|
|
2313
|
+
if (mask != null && openaiOptions2.markup != null) {
|
|
2314
|
+
throw new InvalidArgumentError({
|
|
2315
|
+
argument: "providerOptions.openai.markup",
|
|
2316
|
+
message: "`markup` cannot be combined with `mask`."
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2274
2319
|
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
2275
2320
|
url: this.config.url({
|
|
2276
2321
|
path: "/images/edits",
|
|
@@ -2295,14 +2340,17 @@ var OpenAIImageModel = class {
|
|
|
2295
2340
|
)
|
|
2296
2341
|
),
|
|
2297
2342
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
2343
|
+
markup: openaiOptions2.markup != null ? await markupToBlob(openaiOptions2.markup) : void 0,
|
|
2298
2344
|
n,
|
|
2299
2345
|
size,
|
|
2300
2346
|
quality: openaiOptions2.quality,
|
|
2301
2347
|
background: openaiOptions2.background,
|
|
2302
2348
|
output_format: openaiOptions2.outputFormat,
|
|
2303
2349
|
output_compression: openaiOptions2.outputCompression,
|
|
2350
|
+
complexity: openaiOptions2.complexity,
|
|
2304
2351
|
input_fidelity: openaiOptions2.inputFidelity,
|
|
2305
|
-
user: openaiOptions2.user
|
|
2352
|
+
user: openaiOptions2.user,
|
|
2353
|
+
safety_identifier: openaiOptions2.safetyIdentifier
|
|
2306
2354
|
}),
|
|
2307
2355
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2308
2356
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
@@ -2368,7 +2416,11 @@ var OpenAIImageModel = class {
|
|
|
2368
2416
|
moderation: openaiOptions.moderation,
|
|
2369
2417
|
output_format: openaiOptions.outputFormat,
|
|
2370
2418
|
output_compression: openaiOptions.outputCompression,
|
|
2419
|
+
complexity: openaiOptions.complexity,
|
|
2420
|
+
frame_count: openaiOptions.frameCount,
|
|
2421
|
+
frame_duration_ms: openaiOptions.frameDurationMs,
|
|
2371
2422
|
user: openaiOptions.user,
|
|
2423
|
+
safety_identifier: openaiOptions.safetyIdentifier,
|
|
2372
2424
|
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
2373
2425
|
},
|
|
2374
2426
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -2431,6 +2483,21 @@ function distributeTokenDetails(details, index, total) {
|
|
|
2431
2483
|
}
|
|
2432
2484
|
return result;
|
|
2433
2485
|
}
|
|
2486
|
+
async function markupToBlob(markup) {
|
|
2487
|
+
const dataUrl = /^data:([^;,]*)(;base64)?,(.*)$/s.exec(markup);
|
|
2488
|
+
if (dataUrl == null) {
|
|
2489
|
+
return downloadBlob(markup);
|
|
2490
|
+
}
|
|
2491
|
+
if (dataUrl[2] == null) {
|
|
2492
|
+
throw new InvalidArgumentError({
|
|
2493
|
+
argument: "providerOptions.openai.markup",
|
|
2494
|
+
message: "`markup` data URLs must be base64 encoded."
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
return new Blob([convertBase64ToUint8Array(dataUrl[3])], {
|
|
2498
|
+
type: dataUrl[1] || "image/png"
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2434
2501
|
async function fileToBlob(file) {
|
|
2435
2502
|
if (!file) return void 0;
|
|
2436
2503
|
if (file.type === "url") {
|
|
@@ -8512,7 +8579,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8512
8579
|
};
|
|
8513
8580
|
|
|
8514
8581
|
// src/version.ts
|
|
8515
|
-
var VERSION = true ? "3.0.
|
|
8582
|
+
var VERSION = true ? "3.0.137" : "0.0.0-test";
|
|
8516
8583
|
|
|
8517
8584
|
// src/openai-provider.ts
|
|
8518
8585
|
function createOpenAI(options = {}) {
|