@ai-sdk/openai 3.0.135 → 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 +17 -0
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +127 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +13 -2
- package/dist/internal/index.d.ts +13 -2
- package/dist/internal/index.js +126 -28
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +119 -13
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +58 -0
- package/package.json +5 -5
- package/src/chat/convert-to-openai-chat-messages.ts +22 -3
- package/src/image/openai-image-model-options.ts +44 -0
- package/src/image/openai-image-model.ts +44 -4
- package/src/responses/convert-to-openai-responses-input.ts +21 -7
- package/src/transcription/openai-transcription-model.ts +2 -0
- package/src/transcription/openai-transcription-options.ts +12 -0
|
@@ -127,7 +127,7 @@ declare class OpenAIEmbeddingModel implements EmbeddingModelV3 {
|
|
|
127
127
|
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV3['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
|
|
130
|
+
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
|
|
131
131
|
declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
|
|
132
132
|
declare function hasDefaultResponseFormat(modelId: string): boolean;
|
|
133
133
|
declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
|
|
@@ -135,17 +135,23 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
135
135
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
136
136
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
137
137
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
138
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
138
139
|
outputCompression?: number | undefined;
|
|
139
140
|
user?: string | undefined;
|
|
141
|
+
safetyIdentifier?: string | undefined;
|
|
140
142
|
}>;
|
|
141
143
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
142
144
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
143
145
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
144
146
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
145
|
-
|
|
147
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
146
148
|
outputCompression?: number | undefined;
|
|
147
149
|
user?: string | undefined;
|
|
150
|
+
safetyIdentifier?: string | undefined;
|
|
148
151
|
style?: "vivid" | "natural" | undefined;
|
|
152
|
+
outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
|
|
153
|
+
frameCount?: number | undefined;
|
|
154
|
+
frameDurationMs?: number | undefined;
|
|
149
155
|
moderation?: "low" | "auto" | undefined;
|
|
150
156
|
}>;
|
|
151
157
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
@@ -153,9 +159,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
153
159
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
154
160
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
155
161
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
162
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
156
163
|
outputCompression?: number | undefined;
|
|
157
164
|
user?: string | undefined;
|
|
165
|
+
safetyIdentifier?: string | undefined;
|
|
158
166
|
inputFidelity?: "low" | "high" | undefined;
|
|
167
|
+
markup?: string | undefined;
|
|
159
168
|
}>;
|
|
160
169
|
type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
|
|
161
170
|
|
|
@@ -178,6 +187,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
178
187
|
declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
179
188
|
include?: string[] | undefined;
|
|
180
189
|
language?: string | undefined;
|
|
190
|
+
languages?: string[] | undefined;
|
|
191
|
+
keywords?: string[] | undefined;
|
|
181
192
|
prompt?: string | undefined;
|
|
182
193
|
temperature?: number | undefined;
|
|
183
194
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ declare class OpenAIEmbeddingModel implements EmbeddingModelV3 {
|
|
|
127
127
|
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV3['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
|
|
130
|
+
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
|
|
131
131
|
declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
|
|
132
132
|
declare function hasDefaultResponseFormat(modelId: string): boolean;
|
|
133
133
|
declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
|
|
@@ -135,17 +135,23 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
135
135
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
136
136
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
137
137
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
138
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
138
139
|
outputCompression?: number | undefined;
|
|
139
140
|
user?: string | undefined;
|
|
141
|
+
safetyIdentifier?: string | undefined;
|
|
140
142
|
}>;
|
|
141
143
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
142
144
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
143
145
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
144
146
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
145
|
-
|
|
147
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
146
148
|
outputCompression?: number | undefined;
|
|
147
149
|
user?: string | undefined;
|
|
150
|
+
safetyIdentifier?: string | undefined;
|
|
148
151
|
style?: "vivid" | "natural" | undefined;
|
|
152
|
+
outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
|
|
153
|
+
frameCount?: number | undefined;
|
|
154
|
+
frameDurationMs?: number | undefined;
|
|
149
155
|
moderation?: "low" | "auto" | undefined;
|
|
150
156
|
}>;
|
|
151
157
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
@@ -153,9 +159,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
153
159
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
154
160
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
155
161
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
162
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
156
163
|
outputCompression?: number | undefined;
|
|
157
164
|
user?: string | undefined;
|
|
165
|
+
safetyIdentifier?: string | undefined;
|
|
158
166
|
inputFidelity?: "low" | "high" | undefined;
|
|
167
|
+
markup?: string | undefined;
|
|
159
168
|
}>;
|
|
160
169
|
type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
|
|
161
170
|
|
|
@@ -178,6 +187,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
178
187
|
declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
179
188
|
include?: string[] | undefined;
|
|
180
189
|
language?: string | undefined;
|
|
190
|
+
languages?: string[] | undefined;
|
|
191
|
+
keywords?: string[] | undefined;
|
|
181
192
|
prompt?: string | undefined;
|
|
182
193
|
temperature?: number | undefined;
|
|
183
194
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/internal/index.js
CHANGED
|
@@ -419,7 +419,18 @@ function convertOpenAIChatUsage(usage) {
|
|
|
419
419
|
var import_provider2 = require("@ai-sdk/provider");
|
|
420
420
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
421
421
|
function serializeToolCallArguments(input) {
|
|
422
|
-
|
|
422
|
+
if (typeof input === "string") {
|
|
423
|
+
try {
|
|
424
|
+
const parsed = (0, import_provider_utils2.secureJsonParse)(input);
|
|
425
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
426
|
+
return "{}";
|
|
427
|
+
}
|
|
428
|
+
return input;
|
|
429
|
+
} catch (e) {
|
|
430
|
+
return "{}";
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return (0, import_provider_utils2.stringifyWithBigIntAndCycles)(
|
|
423
434
|
typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
424
435
|
);
|
|
425
436
|
}
|
|
@@ -647,7 +658,7 @@ function convertToOpenAIChatMessages({
|
|
|
647
658
|
case "content":
|
|
648
659
|
case "json":
|
|
649
660
|
case "error-json":
|
|
650
|
-
contentValue =
|
|
661
|
+
contentValue = (0, import_provider_utils2.stringifyWithBigIntAndCycles)(output.value);
|
|
651
662
|
break;
|
|
652
663
|
}
|
|
653
664
|
messages.push({
|
|
@@ -2094,6 +2105,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
2094
2105
|
};
|
|
2095
2106
|
|
|
2096
2107
|
// src/image/openai-image-model.ts
|
|
2108
|
+
var import_provider7 = require("@ai-sdk/provider");
|
|
2097
2109
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2098
2110
|
|
|
2099
2111
|
// src/image/openai-image-api.ts
|
|
@@ -2136,6 +2148,8 @@ var modelMaxImagesPerCall = {
|
|
|
2136
2148
|
"gpt-image-1-mini": 10,
|
|
2137
2149
|
"gpt-image-1.5": 10,
|
|
2138
2150
|
"gpt-image-2": 10,
|
|
2151
|
+
"gpt-image-2.6-flare": 10,
|
|
2152
|
+
"gpt-image-2.6-sunburst": 10,
|
|
2139
2153
|
"gpt-image-2.5-flare": 10,
|
|
2140
2154
|
"gpt-image-2.5-flare-2026-09-08": 10,
|
|
2141
2155
|
"gpt-image-2.5-sunburst": 10,
|
|
@@ -2171,6 +2185,11 @@ var baseImageModelOptionsObject = () => import_v49.z.object({
|
|
|
2171
2185
|
* Format in which the generated image(s) are returned.
|
|
2172
2186
|
*/
|
|
2173
2187
|
outputFormat: import_v49.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
2188
|
+
/**
|
|
2189
|
+
* How much detail the model puts into the image. Supported by GPT Image
|
|
2190
|
+
* 2.6 models. The API defaults to `high`.
|
|
2191
|
+
*/
|
|
2192
|
+
complexity: import_v49.z.enum(["low", "medium", "high"]).optional(),
|
|
2174
2193
|
/**
|
|
2175
2194
|
* Compression level (0-100) for the generated image(s). Applies to the
|
|
2176
2195
|
* `jpeg` and `webp` output formats.
|
|
@@ -2180,7 +2199,13 @@ var baseImageModelOptionsObject = () => import_v49.z.object({
|
|
|
2180
2199
|
* A unique identifier representing your end-user, which can help OpenAI
|
|
2181
2200
|
* to monitor and detect abuse.
|
|
2182
2201
|
*/
|
|
2183
|
-
user: import_v49.z.string().optional()
|
|
2202
|
+
user: import_v49.z.string().optional(),
|
|
2203
|
+
/**
|
|
2204
|
+
* A stable identifier used to help detect users of your application that
|
|
2205
|
+
* may be violating OpenAI's usage policies. Should be a hashed username
|
|
2206
|
+
* or email address.
|
|
2207
|
+
*/
|
|
2208
|
+
safetyIdentifier: import_v49.z.string().max(128).optional()
|
|
2184
2209
|
});
|
|
2185
2210
|
var openaiImageModelOptions = (0, import_provider_utils13.lazySchema)(
|
|
2186
2211
|
() => (0, import_provider_utils13.zodSchema)(baseImageModelOptionsObject())
|
|
@@ -2194,6 +2219,22 @@ var openaiImageModelGenerationOptions = (0, import_provider_utils13.lazySchema)(
|
|
|
2194
2219
|
* looking images.
|
|
2195
2220
|
*/
|
|
2196
2221
|
style: import_v49.z.enum(["vivid", "natural"]).optional(),
|
|
2222
|
+
/**
|
|
2223
|
+
* Format in which the generated image(s) are returned. `gif` produces
|
|
2224
|
+
* an animated GIF and is supported by GPT Image 2.6 models.
|
|
2225
|
+
*/
|
|
2226
|
+
outputFormat: import_v49.z.enum(["png", "jpeg", "webp", "gif"]).optional(),
|
|
2227
|
+
/**
|
|
2228
|
+
* Number of frames (2-64) of an animated GIF. Only applies to the `gif`
|
|
2229
|
+
* output format. The API defaults to 9.
|
|
2230
|
+
*/
|
|
2231
|
+
frameCount: import_v49.z.number().int().min(2).max(64).optional(),
|
|
2232
|
+
/**
|
|
2233
|
+
* Duration of each frame in milliseconds (20-2000) of an animated GIF.
|
|
2234
|
+
* The API rounds it to the nearest 10 ms. Only applies to the `gif`
|
|
2235
|
+
* output format. The API defaults to 200.
|
|
2236
|
+
*/
|
|
2237
|
+
frameDurationMs: import_v49.z.number().int().min(20).max(2e3).optional(),
|
|
2197
2238
|
/**
|
|
2198
2239
|
* Content moderation level for the generated image(s). `low` applies
|
|
2199
2240
|
* less restrictive filtering.
|
|
@@ -2208,7 +2249,14 @@ var openaiImageModelEditOptions = (0, import_provider_utils13.lazySchema)(
|
|
|
2208
2249
|
/**
|
|
2209
2250
|
* Fidelity of the output image(s) to the input image(s).
|
|
2210
2251
|
*/
|
|
2211
|
-
inputFidelity: import_v49.z.enum(["high", "low"]).optional()
|
|
2252
|
+
inputFidelity: import_v49.z.enum(["high", "low"]).optional(),
|
|
2253
|
+
/**
|
|
2254
|
+
* A transparent PNG overlaid on the first input image to mark up the
|
|
2255
|
+
* regions to change, as an HTTPS URL or a base64 data URL. It must match
|
|
2256
|
+
* the dimensions of the first image. Supported by GPT Image 2.5 and 2.6
|
|
2257
|
+
* models. Cannot be combined with a `mask`.
|
|
2258
|
+
*/
|
|
2259
|
+
markup: import_v49.z.string().optional()
|
|
2212
2260
|
})
|
|
2213
2261
|
)
|
|
2214
2262
|
);
|
|
@@ -2257,6 +2305,12 @@ var OpenAIImageModel = class {
|
|
|
2257
2305
|
providerOptions,
|
|
2258
2306
|
schema: openaiImageModelEditOptions
|
|
2259
2307
|
})) != null ? _d : {};
|
|
2308
|
+
if (mask != null && openaiOptions2.markup != null) {
|
|
2309
|
+
throw new import_provider7.InvalidArgumentError({
|
|
2310
|
+
argument: "providerOptions.openai.markup",
|
|
2311
|
+
message: "`markup` cannot be combined with `mask`."
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2260
2314
|
const { value: response2, responseHeaders: responseHeaders2 } = await (0, import_provider_utils14.postFormDataToApi)({
|
|
2261
2315
|
url: this.config.url({
|
|
2262
2316
|
path: "/images/edits",
|
|
@@ -2281,14 +2335,17 @@ var OpenAIImageModel = class {
|
|
|
2281
2335
|
)
|
|
2282
2336
|
),
|
|
2283
2337
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
2338
|
+
markup: openaiOptions2.markup != null ? await markupToBlob(openaiOptions2.markup) : void 0,
|
|
2284
2339
|
n,
|
|
2285
2340
|
size,
|
|
2286
2341
|
quality: openaiOptions2.quality,
|
|
2287
2342
|
background: openaiOptions2.background,
|
|
2288
2343
|
output_format: openaiOptions2.outputFormat,
|
|
2289
2344
|
output_compression: openaiOptions2.outputCompression,
|
|
2345
|
+
complexity: openaiOptions2.complexity,
|
|
2290
2346
|
input_fidelity: openaiOptions2.inputFidelity,
|
|
2291
|
-
user: openaiOptions2.user
|
|
2347
|
+
user: openaiOptions2.user,
|
|
2348
|
+
safety_identifier: openaiOptions2.safetyIdentifier
|
|
2292
2349
|
}),
|
|
2293
2350
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2294
2351
|
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
@@ -2354,7 +2411,11 @@ var OpenAIImageModel = class {
|
|
|
2354
2411
|
moderation: openaiOptions.moderation,
|
|
2355
2412
|
output_format: openaiOptions.outputFormat,
|
|
2356
2413
|
output_compression: openaiOptions.outputCompression,
|
|
2414
|
+
complexity: openaiOptions.complexity,
|
|
2415
|
+
frame_count: openaiOptions.frameCount,
|
|
2416
|
+
frame_duration_ms: openaiOptions.frameDurationMs,
|
|
2357
2417
|
user: openaiOptions.user,
|
|
2418
|
+
safety_identifier: openaiOptions.safetyIdentifier,
|
|
2358
2419
|
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
2359
2420
|
},
|
|
2360
2421
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -2417,6 +2478,21 @@ function distributeTokenDetails(details, index, total) {
|
|
|
2417
2478
|
}
|
|
2418
2479
|
return result;
|
|
2419
2480
|
}
|
|
2481
|
+
async function markupToBlob(markup) {
|
|
2482
|
+
const dataUrl = /^data:([^;,]*)(;base64)?,(.*)$/s.exec(markup);
|
|
2483
|
+
if (dataUrl == null) {
|
|
2484
|
+
return (0, import_provider_utils14.downloadBlob)(markup);
|
|
2485
|
+
}
|
|
2486
|
+
if (dataUrl[2] == null) {
|
|
2487
|
+
throw new import_provider7.InvalidArgumentError({
|
|
2488
|
+
argument: "providerOptions.openai.markup",
|
|
2489
|
+
message: "`markup` data URLs must be base64 encoded."
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
return new Blob([(0, import_provider_utils14.convertBase64ToUint8Array)(dataUrl[3])], {
|
|
2493
|
+
type: dataUrl[1] || "image/png"
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2420
2496
|
async function fileToBlob(file) {
|
|
2421
2497
|
if (!file) return void 0;
|
|
2422
2498
|
if (file.type === "url") {
|
|
@@ -2482,6 +2558,16 @@ var openAITranscriptionModelOptions = (0, import_provider_utils16.lazySchema)(
|
|
|
2482
2558
|
* The language of the input audio in ISO-639-1 format.
|
|
2483
2559
|
*/
|
|
2484
2560
|
language: import_v411.z.string().optional(),
|
|
2561
|
+
/**
|
|
2562
|
+
* Expected languages for REST transcription, e.g. with gpt-transcribe.
|
|
2563
|
+
* Use this instead of language. The API validates model support.
|
|
2564
|
+
*/
|
|
2565
|
+
languages: import_v411.z.array(import_v411.z.string()).optional(),
|
|
2566
|
+
/**
|
|
2567
|
+
* Vocabulary hints for REST transcription, e.g. names or technical terms.
|
|
2568
|
+
* The API validates model support.
|
|
2569
|
+
*/
|
|
2570
|
+
keywords: import_v411.z.array(import_v411.z.string()).optional(),
|
|
2485
2571
|
/**
|
|
2486
2572
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
2487
2573
|
*/
|
|
@@ -2593,6 +2679,8 @@ var OpenAITranscriptionModel = class {
|
|
|
2593
2679
|
const transcriptionModelOptions = {
|
|
2594
2680
|
include: openAIOptions.include,
|
|
2595
2681
|
language: openAIOptions.language,
|
|
2682
|
+
languages: openAIOptions.languages,
|
|
2683
|
+
keywords: openAIOptions.keywords,
|
|
2596
2684
|
prompt: openAIOptions.prompt,
|
|
2597
2685
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
2598
2686
|
// prefer verbose_json to get segments for models that support it
|
|
@@ -2785,7 +2873,7 @@ var OpenAISpeechModel = class {
|
|
|
2785
2873
|
};
|
|
2786
2874
|
|
|
2787
2875
|
// src/responses/openai-responses-language-model.ts
|
|
2788
|
-
var
|
|
2876
|
+
var import_provider11 = require("@ai-sdk/provider");
|
|
2789
2877
|
var import_provider_utils36 = require("@ai-sdk/provider-utils");
|
|
2790
2878
|
|
|
2791
2879
|
// src/responses/convert-openai-responses-usage.ts
|
|
@@ -2829,7 +2917,7 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2829
2917
|
}
|
|
2830
2918
|
|
|
2831
2919
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2832
|
-
var
|
|
2920
|
+
var import_provider9 = require("@ai-sdk/provider");
|
|
2833
2921
|
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
2834
2922
|
var import_v419 = require("zod/v4");
|
|
2835
2923
|
|
|
@@ -3394,7 +3482,7 @@ var webSearchToolFactory = (0, import_provider_utils25.createProviderToolFactory
|
|
|
3394
3482
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
3395
3483
|
|
|
3396
3484
|
// src/responses/expand-parallel-tool-call.ts
|
|
3397
|
-
var
|
|
3485
|
+
var import_provider8 = require("@ai-sdk/provider");
|
|
3398
3486
|
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
3399
3487
|
var parallelToolName = "parallel";
|
|
3400
3488
|
var recipientNamePrefix = "functions.";
|
|
@@ -3404,7 +3492,7 @@ function getParallelToolCallMetadata({
|
|
|
3404
3492
|
}) {
|
|
3405
3493
|
var _a2;
|
|
3406
3494
|
const metadata = (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.parallelToolCall;
|
|
3407
|
-
if (!(0,
|
|
3495
|
+
if (!(0, import_provider8.isJSONObject)(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
|
|
3408
3496
|
return void 0;
|
|
3409
3497
|
}
|
|
3410
3498
|
return metadata;
|
|
@@ -3425,7 +3513,7 @@ async function expandParallelToolCall({
|
|
|
3425
3513
|
return void 0;
|
|
3426
3514
|
}
|
|
3427
3515
|
const parsedInput = await (0, import_provider_utils26.safeParseJSON)({ text: toolCall.input });
|
|
3428
|
-
if (!parsedInput.success || !(0,
|
|
3516
|
+
if (!parsedInput.success || !(0, import_provider8.isJSONObject)(parsedInput.value)) {
|
|
3429
3517
|
return void 0;
|
|
3430
3518
|
}
|
|
3431
3519
|
const toolUses = parsedInput.value.tool_uses;
|
|
@@ -3435,12 +3523,12 @@ async function expandParallelToolCall({
|
|
|
3435
3523
|
const availableToolNames = new Set(tools.map((tool) => tool.name));
|
|
3436
3524
|
const expandedToolCalls = [];
|
|
3437
3525
|
for (const [index, toolUse] of toolUses.entries()) {
|
|
3438
|
-
if (!(0,
|
|
3526
|
+
if (!(0, import_provider8.isJSONObject)(toolUse)) {
|
|
3439
3527
|
return void 0;
|
|
3440
3528
|
}
|
|
3441
3529
|
const recipientName = toolUse.recipient_name;
|
|
3442
3530
|
const parameters = toolUse.parameters;
|
|
3443
|
-
if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0,
|
|
3531
|
+
if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0, import_provider8.isJSONObject)(parameters)) {
|
|
3444
3532
|
return void 0;
|
|
3445
3533
|
}
|
|
3446
3534
|
const toolName = recipientName.slice(recipientNamePrefix.length);
|
|
@@ -3471,7 +3559,15 @@ async function expandParallelToolCall({
|
|
|
3471
3559
|
|
|
3472
3560
|
// src/responses/convert-to-openai-responses-input.ts
|
|
3473
3561
|
function serializeToolCallArguments2(input) {
|
|
3474
|
-
|
|
3562
|
+
if (typeof input === "string") {
|
|
3563
|
+
try {
|
|
3564
|
+
(0, import_provider_utils27.secureJsonParse)(input);
|
|
3565
|
+
return input;
|
|
3566
|
+
} catch (e) {
|
|
3567
|
+
return (0, import_provider_utils27.stringifyWithBigIntAndCycles)(input);
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
return (0, import_provider_utils27.stringifyWithBigIntAndCycles)(input === void 0 ? {} : input);
|
|
3475
3571
|
}
|
|
3476
3572
|
async function convertWebSearchToolResultOutput({
|
|
3477
3573
|
output,
|
|
@@ -3549,7 +3645,7 @@ async function convertFunctionToolResultOutput({
|
|
|
3549
3645
|
}
|
|
3550
3646
|
case "json":
|
|
3551
3647
|
case "error-json":
|
|
3552
|
-
return convertScalarOutput(
|
|
3648
|
+
return convertScalarOutput((0, import_provider_utils27.stringifyWithBigIntAndCycles)(output.value));
|
|
3553
3649
|
case "content":
|
|
3554
3650
|
return output.value.map((item) => {
|
|
3555
3651
|
var _a3, _b, _c, _d, _e, _f, _g;
|
|
@@ -3760,7 +3856,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3760
3856
|
if (effort != null) {
|
|
3761
3857
|
const unsupportedReason = content !== "" ? "Message-level reasoningEffortUpdate requires empty system message content." : configurationUpdateUnsupportedReason;
|
|
3762
3858
|
if (unsupportedReason != null) {
|
|
3763
|
-
throw new
|
|
3859
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
3764
3860
|
functionality: "Message-level reasoningEffortUpdate",
|
|
3765
3861
|
message: unsupportedReason
|
|
3766
3862
|
});
|
|
@@ -3872,7 +3968,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3872
3968
|
};
|
|
3873
3969
|
}
|
|
3874
3970
|
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
3875
|
-
throw new
|
|
3971
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
3876
3972
|
functionality: `file part media type ${mediaType}`
|
|
3877
3973
|
});
|
|
3878
3974
|
}
|
|
@@ -4052,7 +4148,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4052
4148
|
type: "custom_tool_call",
|
|
4053
4149
|
call_id: part.toolCallId,
|
|
4054
4150
|
name: resolvedToolName,
|
|
4055
|
-
input: typeof part.input === "string" ? part.input :
|
|
4151
|
+
input: typeof part.input === "string" ? part.input : (0, import_provider_utils27.stringifyWithBigIntAndCycles)(part.input),
|
|
4056
4152
|
...isAsync != null && { async: isAsync },
|
|
4057
4153
|
id
|
|
4058
4154
|
});
|
|
@@ -4178,7 +4274,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4178
4274
|
} else if (reasoningMessage !== void 0) {
|
|
4179
4275
|
warnings.push({
|
|
4180
4276
|
type: "other",
|
|
4181
|
-
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${
|
|
4277
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${(0, import_provider_utils27.stringifyWithBigIntAndCycles)(part)}.`
|
|
4182
4278
|
});
|
|
4183
4279
|
}
|
|
4184
4280
|
if (reasoningMessage === void 0) {
|
|
@@ -4214,7 +4310,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4214
4310
|
} else {
|
|
4215
4311
|
warnings.push({
|
|
4216
4312
|
type: "other",
|
|
4217
|
-
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${
|
|
4313
|
+
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${(0, import_provider_utils27.stringifyWithBigIntAndCycles)(part)}.`
|
|
4218
4314
|
});
|
|
4219
4315
|
}
|
|
4220
4316
|
}
|
|
@@ -4280,7 +4376,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4280
4376
|
})
|
|
4281
4377
|
);
|
|
4282
4378
|
const serializedToolOutputs = toolOutputs.map(
|
|
4283
|
-
({ output: output2 }) => typeof output2 === "string" ? output2 :
|
|
4379
|
+
({ output: output2 }) => typeof output2 === "string" ? output2 : (0, import_provider_utils27.stringifyWithBigIntAndCycles)(output2)
|
|
4284
4380
|
);
|
|
4285
4381
|
const hasPromptCacheBreakpoint = toolOutputs.some(
|
|
4286
4382
|
({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
|
|
@@ -4396,7 +4492,9 @@ ${text}`,
|
|
|
4396
4492
|
break;
|
|
4397
4493
|
case "json":
|
|
4398
4494
|
case "error-json":
|
|
4399
|
-
outputValue = convertScalarOutput(
|
|
4495
|
+
outputValue = convertScalarOutput(
|
|
4496
|
+
(0, import_provider_utils27.stringifyWithBigIntAndCycles)(output.value)
|
|
4497
|
+
);
|
|
4400
4498
|
break;
|
|
4401
4499
|
case "content":
|
|
4402
4500
|
outputValue = output.value.map((item) => {
|
|
@@ -5485,7 +5583,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5485
5583
|
);
|
|
5486
5584
|
|
|
5487
5585
|
// src/responses/openai-responses-prepare-tools.ts
|
|
5488
|
-
var
|
|
5586
|
+
var import_provider10 = require("@ai-sdk/provider");
|
|
5489
5587
|
var import_provider_utils35 = require("@ai-sdk/provider-utils");
|
|
5490
5588
|
|
|
5491
5589
|
// src/tool/code-interpreter.ts
|
|
@@ -5817,7 +5915,7 @@ async function prepareResponsesTools({
|
|
|
5817
5915
|
namespaceTools.set(namespace.name, namespaceTool);
|
|
5818
5916
|
openaiTools.push(namespaceTool);
|
|
5819
5917
|
} else if (namespaceTool.description !== namespace.description) {
|
|
5820
|
-
throw new
|
|
5918
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
5821
5919
|
functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
|
|
5822
5920
|
});
|
|
5823
5921
|
}
|
|
@@ -6071,7 +6169,7 @@ async function prepareResponsesTools({
|
|
|
6071
6169
|
allowedToolEntries.push(resolution.entry);
|
|
6072
6170
|
}
|
|
6073
6171
|
if (allowedToolEntries.length === 0) {
|
|
6074
|
-
throw new
|
|
6172
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
6075
6173
|
functionality: `allowedTools with only tools that cannot be allow-listed (${droppedToolNames.join(
|
|
6076
6174
|
", "
|
|
6077
6175
|
)})`
|
|
@@ -6106,7 +6204,7 @@ async function prepareResponsesTools({
|
|
|
6106
6204
|
}
|
|
6107
6205
|
default: {
|
|
6108
6206
|
const _exhaustiveCheck = type;
|
|
6109
|
-
throw new
|
|
6207
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
6110
6208
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
6111
6209
|
});
|
|
6112
6210
|
}
|
|
@@ -6414,7 +6512,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6414
6512
|
}
|
|
6415
6513
|
for (let i = 1; i < input.length; i++) {
|
|
6416
6514
|
if (input[i - 1].type === "configuration_update" && input[i].type === "configuration_update") {
|
|
6417
|
-
throw new
|
|
6515
|
+
throw new import_provider11.UnsupportedFunctionalityError({
|
|
6418
6516
|
functionality: "Adjacent reasoning effort configuration updates"
|
|
6419
6517
|
});
|
|
6420
6518
|
}
|
|
@@ -6643,7 +6741,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6643
6741
|
fetch: this.config.fetch
|
|
6644
6742
|
});
|
|
6645
6743
|
if (response.error) {
|
|
6646
|
-
throw new
|
|
6744
|
+
throw new import_provider11.APICallError({
|
|
6647
6745
|
message: response.error.message,
|
|
6648
6746
|
url,
|
|
6649
6747
|
requestBodyValues: body,
|
|
@@ -8163,7 +8261,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
|
|
|
8163
8261
|
requestBodyValues,
|
|
8164
8262
|
responseHeaders
|
|
8165
8263
|
}) {
|
|
8166
|
-
return new
|
|
8264
|
+
return new import_provider11.APICallError({
|
|
8167
8265
|
message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
|
|
8168
8266
|
url,
|
|
8169
8267
|
requestBodyValues,
|