@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.137
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- afde897: feat(openai): support GPT Image 2.6 models with `complexity`, markup-guided edits (`markup`), animated GIF output (`outputFormat: 'gif'`, `frameCount`, `frameDurationMs`), and `safetyIdentifier` for image models
|
|
8
|
+
|
|
9
|
+
## 3.0.136
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d900e58: fix(openai): preserve valid JSON string tool arguments and serialize BigInt and cycles in tool calls and results, retaining malformed argument replay fallbacks
|
|
14
|
+
- d900e58: Forward `languages` and `keywords` transcription hints as repeated multipart fields instead of silently dropping them.
|
|
15
|
+
- Updated dependencies [d900e58]
|
|
16
|
+
- Updated dependencies [d900e58]
|
|
17
|
+
- Updated dependencies [d900e58]
|
|
18
|
+
- @ai-sdk/provider-utils@4.0.64
|
|
19
|
+
|
|
3
20
|
## 3.0.135
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -46,22 +46,28 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
46
46
|
}>;
|
|
47
47
|
type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
|
|
48
48
|
|
|
49
|
-
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 & {});
|
|
49
|
+
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 & {});
|
|
50
50
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
51
51
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
52
52
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
53
53
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
54
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
54
55
|
outputCompression?: number | undefined;
|
|
55
56
|
user?: string | undefined;
|
|
57
|
+
safetyIdentifier?: string | undefined;
|
|
56
58
|
}>;
|
|
57
59
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
58
60
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
59
61
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
60
62
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
61
|
-
|
|
63
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
62
64
|
outputCompression?: number | undefined;
|
|
63
65
|
user?: string | undefined;
|
|
66
|
+
safetyIdentifier?: string | undefined;
|
|
64
67
|
style?: "vivid" | "natural" | undefined;
|
|
68
|
+
outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
|
|
69
|
+
frameCount?: number | undefined;
|
|
70
|
+
frameDurationMs?: number | undefined;
|
|
65
71
|
moderation?: "low" | "auto" | undefined;
|
|
66
72
|
}>;
|
|
67
73
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
@@ -69,9 +75,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
69
75
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
70
76
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
71
77
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
78
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
72
79
|
outputCompression?: number | undefined;
|
|
73
80
|
user?: string | undefined;
|
|
81
|
+
safetyIdentifier?: string | undefined;
|
|
74
82
|
inputFidelity?: "low" | "high" | undefined;
|
|
83
|
+
markup?: string | undefined;
|
|
75
84
|
}>;
|
|
76
85
|
type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
|
|
77
86
|
|
|
@@ -1154,6 +1163,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
1154
1163
|
declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
1155
1164
|
include?: string[] | undefined;
|
|
1156
1165
|
language?: string | undefined;
|
|
1166
|
+
languages?: string[] | undefined;
|
|
1167
|
+
keywords?: string[] | undefined;
|
|
1157
1168
|
prompt?: string | undefined;
|
|
1158
1169
|
temperature?: number | undefined;
|
|
1159
1170
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -46,22 +46,28 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
46
46
|
}>;
|
|
47
47
|
type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
|
|
48
48
|
|
|
49
|
-
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 & {});
|
|
49
|
+
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 & {});
|
|
50
50
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
51
51
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
52
52
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
53
53
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
54
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
54
55
|
outputCompression?: number | undefined;
|
|
55
56
|
user?: string | undefined;
|
|
57
|
+
safetyIdentifier?: string | undefined;
|
|
56
58
|
}>;
|
|
57
59
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
58
60
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
59
61
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
60
62
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
61
|
-
|
|
63
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
62
64
|
outputCompression?: number | undefined;
|
|
63
65
|
user?: string | undefined;
|
|
66
|
+
safetyIdentifier?: string | undefined;
|
|
64
67
|
style?: "vivid" | "natural" | undefined;
|
|
68
|
+
outputFormat?: "png" | "jpeg" | "webp" | "gif" | undefined;
|
|
69
|
+
frameCount?: number | undefined;
|
|
70
|
+
frameDurationMs?: number | undefined;
|
|
65
71
|
moderation?: "low" | "auto" | undefined;
|
|
66
72
|
}>;
|
|
67
73
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
@@ -69,9 +75,12 @@ declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
69
75
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
70
76
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
71
77
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
78
|
+
complexity?: "low" | "medium" | "high" | undefined;
|
|
72
79
|
outputCompression?: number | undefined;
|
|
73
80
|
user?: string | undefined;
|
|
81
|
+
safetyIdentifier?: string | undefined;
|
|
74
82
|
inputFidelity?: "low" | "high" | undefined;
|
|
83
|
+
markup?: string | undefined;
|
|
75
84
|
}>;
|
|
76
85
|
type OpenAIImageModelEditOptions = InferSchema<typeof openaiImageModelEditOptions>;
|
|
77
86
|
|
|
@@ -1154,6 +1163,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
1154
1163
|
declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
1155
1164
|
include?: string[] | undefined;
|
|
1156
1165
|
language?: string | undefined;
|
|
1166
|
+
languages?: string[] | undefined;
|
|
1167
|
+
keywords?: string[] | undefined;
|
|
1157
1168
|
prompt?: string | undefined;
|
|
1158
1169
|
temperature?: number | undefined;
|
|
1159
1170
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -379,7 +379,18 @@ function convertOpenAIChatUsage(usage) {
|
|
|
379
379
|
var import_provider2 = require("@ai-sdk/provider");
|
|
380
380
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
381
381
|
function serializeToolCallArguments(input) {
|
|
382
|
-
|
|
382
|
+
if (typeof input === "string") {
|
|
383
|
+
try {
|
|
384
|
+
const parsed = (0, import_provider_utils2.secureJsonParse)(input);
|
|
385
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
386
|
+
return "{}";
|
|
387
|
+
}
|
|
388
|
+
return input;
|
|
389
|
+
} catch (e) {
|
|
390
|
+
return "{}";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return (0, import_provider_utils2.stringifyWithBigIntAndCycles)(
|
|
383
394
|
typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
384
395
|
);
|
|
385
396
|
}
|
|
@@ -607,7 +618,7 @@ function convertToOpenAIChatMessages({
|
|
|
607
618
|
case "content":
|
|
608
619
|
case "json":
|
|
609
620
|
case "error-json":
|
|
610
|
-
contentValue =
|
|
621
|
+
contentValue = (0, import_provider_utils2.stringifyWithBigIntAndCycles)(output.value);
|
|
611
622
|
break;
|
|
612
623
|
}
|
|
613
624
|
messages.push({
|
|
@@ -2054,6 +2065,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
2054
2065
|
};
|
|
2055
2066
|
|
|
2056
2067
|
// src/image/openai-image-model.ts
|
|
2068
|
+
var import_provider7 = require("@ai-sdk/provider");
|
|
2057
2069
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2058
2070
|
|
|
2059
2071
|
// src/image/openai-image-api.ts
|
|
@@ -2096,6 +2108,8 @@ var modelMaxImagesPerCall = {
|
|
|
2096
2108
|
"gpt-image-1-mini": 10,
|
|
2097
2109
|
"gpt-image-1.5": 10,
|
|
2098
2110
|
"gpt-image-2": 10,
|
|
2111
|
+
"gpt-image-2.6-flare": 10,
|
|
2112
|
+
"gpt-image-2.6-sunburst": 10,
|
|
2099
2113
|
"gpt-image-2.5-flare": 10,
|
|
2100
2114
|
"gpt-image-2.5-flare-2026-09-08": 10,
|
|
2101
2115
|
"gpt-image-2.5-sunburst": 10,
|
|
@@ -2131,6 +2145,11 @@ var baseImageModelOptionsObject = () => import_v49.z.object({
|
|
|
2131
2145
|
* Format in which the generated image(s) are returned.
|
|
2132
2146
|
*/
|
|
2133
2147
|
outputFormat: import_v49.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
2148
|
+
/**
|
|
2149
|
+
* How much detail the model puts into the image. Supported by GPT Image
|
|
2150
|
+
* 2.6 models. The API defaults to `high`.
|
|
2151
|
+
*/
|
|
2152
|
+
complexity: import_v49.z.enum(["low", "medium", "high"]).optional(),
|
|
2134
2153
|
/**
|
|
2135
2154
|
* Compression level (0-100) for the generated image(s). Applies to the
|
|
2136
2155
|
* `jpeg` and `webp` output formats.
|
|
@@ -2140,7 +2159,13 @@ var baseImageModelOptionsObject = () => import_v49.z.object({
|
|
|
2140
2159
|
* A unique identifier representing your end-user, which can help OpenAI
|
|
2141
2160
|
* to monitor and detect abuse.
|
|
2142
2161
|
*/
|
|
2143
|
-
user: import_v49.z.string().optional()
|
|
2162
|
+
user: import_v49.z.string().optional(),
|
|
2163
|
+
/**
|
|
2164
|
+
* A stable identifier used to help detect users of your application that
|
|
2165
|
+
* may be violating OpenAI's usage policies. Should be a hashed username
|
|
2166
|
+
* or email address.
|
|
2167
|
+
*/
|
|
2168
|
+
safetyIdentifier: import_v49.z.string().max(128).optional()
|
|
2144
2169
|
});
|
|
2145
2170
|
var openaiImageModelOptions = (0, import_provider_utils13.lazySchema)(
|
|
2146
2171
|
() => (0, import_provider_utils13.zodSchema)(baseImageModelOptionsObject())
|
|
@@ -2154,6 +2179,22 @@ var openaiImageModelGenerationOptions = (0, import_provider_utils13.lazySchema)(
|
|
|
2154
2179
|
* looking images.
|
|
2155
2180
|
*/
|
|
2156
2181
|
style: import_v49.z.enum(["vivid", "natural"]).optional(),
|
|
2182
|
+
/**
|
|
2183
|
+
* Format in which the generated image(s) are returned. `gif` produces
|
|
2184
|
+
* an animated GIF and is supported by GPT Image 2.6 models.
|
|
2185
|
+
*/
|
|
2186
|
+
outputFormat: import_v49.z.enum(["png", "jpeg", "webp", "gif"]).optional(),
|
|
2187
|
+
/**
|
|
2188
|
+
* Number of frames (2-64) of an animated GIF. Only applies to the `gif`
|
|
2189
|
+
* output format. The API defaults to 9.
|
|
2190
|
+
*/
|
|
2191
|
+
frameCount: import_v49.z.number().int().min(2).max(64).optional(),
|
|
2192
|
+
/**
|
|
2193
|
+
* Duration of each frame in milliseconds (20-2000) of an animated GIF.
|
|
2194
|
+
* The API rounds it to the nearest 10 ms. Only applies to the `gif`
|
|
2195
|
+
* output format. The API defaults to 200.
|
|
2196
|
+
*/
|
|
2197
|
+
frameDurationMs: import_v49.z.number().int().min(20).max(2e3).optional(),
|
|
2157
2198
|
/**
|
|
2158
2199
|
* Content moderation level for the generated image(s). `low` applies
|
|
2159
2200
|
* less restrictive filtering.
|
|
@@ -2168,7 +2209,14 @@ var openaiImageModelEditOptions = (0, import_provider_utils13.lazySchema)(
|
|
|
2168
2209
|
/**
|
|
2169
2210
|
* Fidelity of the output image(s) to the input image(s).
|
|
2170
2211
|
*/
|
|
2171
|
-
inputFidelity: import_v49.z.enum(["high", "low"]).optional()
|
|
2212
|
+
inputFidelity: import_v49.z.enum(["high", "low"]).optional(),
|
|
2213
|
+
/**
|
|
2214
|
+
* A transparent PNG overlaid on the first input image to mark up the
|
|
2215
|
+
* regions to change, as an HTTPS URL or a base64 data URL. It must match
|
|
2216
|
+
* the dimensions of the first image. Supported by GPT Image 2.5 and 2.6
|
|
2217
|
+
* models. Cannot be combined with a `mask`.
|
|
2218
|
+
*/
|
|
2219
|
+
markup: import_v49.z.string().optional()
|
|
2172
2220
|
})
|
|
2173
2221
|
)
|
|
2174
2222
|
);
|
|
@@ -2217,6 +2265,12 @@ var OpenAIImageModel = class {
|
|
|
2217
2265
|
providerOptions,
|
|
2218
2266
|
schema: openaiImageModelEditOptions
|
|
2219
2267
|
})) != null ? _d : {};
|
|
2268
|
+
if (mask != null && openaiOptions2.markup != null) {
|
|
2269
|
+
throw new import_provider7.InvalidArgumentError({
|
|
2270
|
+
argument: "providerOptions.openai.markup",
|
|
2271
|
+
message: "`markup` cannot be combined with `mask`."
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2220
2274
|
const { value: response2, responseHeaders: responseHeaders2 } = await (0, import_provider_utils14.postFormDataToApi)({
|
|
2221
2275
|
url: this.config.url({
|
|
2222
2276
|
path: "/images/edits",
|
|
@@ -2241,14 +2295,17 @@ var OpenAIImageModel = class {
|
|
|
2241
2295
|
)
|
|
2242
2296
|
),
|
|
2243
2297
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
2298
|
+
markup: openaiOptions2.markup != null ? await markupToBlob(openaiOptions2.markup) : void 0,
|
|
2244
2299
|
n,
|
|
2245
2300
|
size,
|
|
2246
2301
|
quality: openaiOptions2.quality,
|
|
2247
2302
|
background: openaiOptions2.background,
|
|
2248
2303
|
output_format: openaiOptions2.outputFormat,
|
|
2249
2304
|
output_compression: openaiOptions2.outputCompression,
|
|
2305
|
+
complexity: openaiOptions2.complexity,
|
|
2250
2306
|
input_fidelity: openaiOptions2.inputFidelity,
|
|
2251
|
-
user: openaiOptions2.user
|
|
2307
|
+
user: openaiOptions2.user,
|
|
2308
|
+
safety_identifier: openaiOptions2.safetyIdentifier
|
|
2252
2309
|
}),
|
|
2253
2310
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2254
2311
|
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
@@ -2314,7 +2371,11 @@ var OpenAIImageModel = class {
|
|
|
2314
2371
|
moderation: openaiOptions.moderation,
|
|
2315
2372
|
output_format: openaiOptions.outputFormat,
|
|
2316
2373
|
output_compression: openaiOptions.outputCompression,
|
|
2374
|
+
complexity: openaiOptions.complexity,
|
|
2375
|
+
frame_count: openaiOptions.frameCount,
|
|
2376
|
+
frame_duration_ms: openaiOptions.frameDurationMs,
|
|
2317
2377
|
user: openaiOptions.user,
|
|
2378
|
+
safety_identifier: openaiOptions.safetyIdentifier,
|
|
2318
2379
|
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
2319
2380
|
},
|
|
2320
2381
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -2377,6 +2438,21 @@ function distributeTokenDetails(details, index, total) {
|
|
|
2377
2438
|
}
|
|
2378
2439
|
return result;
|
|
2379
2440
|
}
|
|
2441
|
+
async function markupToBlob(markup) {
|
|
2442
|
+
const dataUrl = /^data:([^;,]*)(;base64)?,(.*)$/s.exec(markup);
|
|
2443
|
+
if (dataUrl == null) {
|
|
2444
|
+
return (0, import_provider_utils14.downloadBlob)(markup);
|
|
2445
|
+
}
|
|
2446
|
+
if (dataUrl[2] == null) {
|
|
2447
|
+
throw new import_provider7.InvalidArgumentError({
|
|
2448
|
+
argument: "providerOptions.openai.markup",
|
|
2449
|
+
message: "`markup` data URLs must be base64 encoded."
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
return new Blob([(0, import_provider_utils14.convertBase64ToUint8Array)(dataUrl[3])], {
|
|
2453
|
+
type: dataUrl[1] || "image/png"
|
|
2454
|
+
});
|
|
2455
|
+
}
|
|
2380
2456
|
async function fileToBlob(file) {
|
|
2381
2457
|
if (!file) return void 0;
|
|
2382
2458
|
if (file.type === "url") {
|
|
@@ -3032,7 +3108,7 @@ var openaiTools = {
|
|
|
3032
3108
|
};
|
|
3033
3109
|
|
|
3034
3110
|
// src/responses/openai-responses-language-model.ts
|
|
3035
|
-
var
|
|
3111
|
+
var import_provider11 = require("@ai-sdk/provider");
|
|
3036
3112
|
var import_provider_utils31 = require("@ai-sdk/provider-utils");
|
|
3037
3113
|
|
|
3038
3114
|
// src/responses/convert-openai-responses-usage.ts
|
|
@@ -3076,7 +3152,7 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
3076
3152
|
}
|
|
3077
3153
|
|
|
3078
3154
|
// src/responses/convert-to-openai-responses-input.ts
|
|
3079
|
-
var
|
|
3155
|
+
var import_provider9 = require("@ai-sdk/provider");
|
|
3080
3156
|
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
3081
3157
|
var import_v422 = require("zod/v4");
|
|
3082
3158
|
|
|
@@ -3384,7 +3460,7 @@ var openaiResponsesSystemMessageOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
3384
3460
|
);
|
|
3385
3461
|
|
|
3386
3462
|
// src/responses/expand-parallel-tool-call.ts
|
|
3387
|
-
var
|
|
3463
|
+
var import_provider8 = require("@ai-sdk/provider");
|
|
3388
3464
|
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
3389
3465
|
var parallelToolName = "parallel";
|
|
3390
3466
|
var recipientNamePrefix = "functions.";
|
|
@@ -3394,7 +3470,7 @@ function getParallelToolCallMetadata({
|
|
|
3394
3470
|
}) {
|
|
3395
3471
|
var _a2;
|
|
3396
3472
|
const metadata = (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.parallelToolCall;
|
|
3397
|
-
if (!(0,
|
|
3473
|
+
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) {
|
|
3398
3474
|
return void 0;
|
|
3399
3475
|
}
|
|
3400
3476
|
return metadata;
|
|
@@ -3415,7 +3491,7 @@ async function expandParallelToolCall({
|
|
|
3415
3491
|
return void 0;
|
|
3416
3492
|
}
|
|
3417
3493
|
const parsedInput = await (0, import_provider_utils27.safeParseJSON)({ text: toolCall.input });
|
|
3418
|
-
if (!parsedInput.success || !(0,
|
|
3494
|
+
if (!parsedInput.success || !(0, import_provider8.isJSONObject)(parsedInput.value)) {
|
|
3419
3495
|
return void 0;
|
|
3420
3496
|
}
|
|
3421
3497
|
const toolUses = parsedInput.value.tool_uses;
|
|
@@ -3425,12 +3501,12 @@ async function expandParallelToolCall({
|
|
|
3425
3501
|
const availableToolNames = new Set(tools.map((tool) => tool.name));
|
|
3426
3502
|
const expandedToolCalls = [];
|
|
3427
3503
|
for (const [index, toolUse] of toolUses.entries()) {
|
|
3428
|
-
if (!(0,
|
|
3504
|
+
if (!(0, import_provider8.isJSONObject)(toolUse)) {
|
|
3429
3505
|
return void 0;
|
|
3430
3506
|
}
|
|
3431
3507
|
const recipientName = toolUse.recipient_name;
|
|
3432
3508
|
const parameters = toolUse.parameters;
|
|
3433
|
-
if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0,
|
|
3509
|
+
if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0, import_provider8.isJSONObject)(parameters)) {
|
|
3434
3510
|
return void 0;
|
|
3435
3511
|
}
|
|
3436
3512
|
const toolName = recipientName.slice(recipientNamePrefix.length);
|
|
@@ -3461,7 +3537,15 @@ async function expandParallelToolCall({
|
|
|
3461
3537
|
|
|
3462
3538
|
// src/responses/convert-to-openai-responses-input.ts
|
|
3463
3539
|
function serializeToolCallArguments2(input) {
|
|
3464
|
-
|
|
3540
|
+
if (typeof input === "string") {
|
|
3541
|
+
try {
|
|
3542
|
+
(0, import_provider_utils28.secureJsonParse)(input);
|
|
3543
|
+
return input;
|
|
3544
|
+
} catch (e) {
|
|
3545
|
+
return (0, import_provider_utils28.stringifyWithBigIntAndCycles)(input);
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
return (0, import_provider_utils28.stringifyWithBigIntAndCycles)(input === void 0 ? {} : input);
|
|
3465
3549
|
}
|
|
3466
3550
|
async function convertWebSearchToolResultOutput({
|
|
3467
3551
|
output,
|
|
@@ -3539,7 +3623,7 @@ async function convertFunctionToolResultOutput({
|
|
|
3539
3623
|
}
|
|
3540
3624
|
case "json":
|
|
3541
3625
|
case "error-json":
|
|
3542
|
-
return convertScalarOutput(
|
|
3626
|
+
return convertScalarOutput((0, import_provider_utils28.stringifyWithBigIntAndCycles)(output.value));
|
|
3543
3627
|
case "content":
|
|
3544
3628
|
return output.value.map((item) => {
|
|
3545
3629
|
var _a3, _b, _c, _d, _e, _f, _g;
|
|
@@ -3750,7 +3834,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3750
3834
|
if (effort != null) {
|
|
3751
3835
|
const unsupportedReason = content !== "" ? "Message-level reasoningEffortUpdate requires empty system message content." : configurationUpdateUnsupportedReason;
|
|
3752
3836
|
if (unsupportedReason != null) {
|
|
3753
|
-
throw new
|
|
3837
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
3754
3838
|
functionality: "Message-level reasoningEffortUpdate",
|
|
3755
3839
|
message: unsupportedReason
|
|
3756
3840
|
});
|
|
@@ -3862,7 +3946,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3862
3946
|
};
|
|
3863
3947
|
}
|
|
3864
3948
|
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
3865
|
-
throw new
|
|
3949
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
3866
3950
|
functionality: `file part media type ${mediaType}`
|
|
3867
3951
|
});
|
|
3868
3952
|
}
|
|
@@ -4042,7 +4126,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4042
4126
|
type: "custom_tool_call",
|
|
4043
4127
|
call_id: part.toolCallId,
|
|
4044
4128
|
name: resolvedToolName,
|
|
4045
|
-
input: typeof part.input === "string" ? part.input :
|
|
4129
|
+
input: typeof part.input === "string" ? part.input : (0, import_provider_utils28.stringifyWithBigIntAndCycles)(part.input),
|
|
4046
4130
|
...isAsync != null && { async: isAsync },
|
|
4047
4131
|
id
|
|
4048
4132
|
});
|
|
@@ -4168,7 +4252,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4168
4252
|
} else if (reasoningMessage !== void 0) {
|
|
4169
4253
|
warnings.push({
|
|
4170
4254
|
type: "other",
|
|
4171
|
-
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${
|
|
4255
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${(0, import_provider_utils28.stringifyWithBigIntAndCycles)(part)}.`
|
|
4172
4256
|
});
|
|
4173
4257
|
}
|
|
4174
4258
|
if (reasoningMessage === void 0) {
|
|
@@ -4204,7 +4288,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4204
4288
|
} else {
|
|
4205
4289
|
warnings.push({
|
|
4206
4290
|
type: "other",
|
|
4207
|
-
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${
|
|
4291
|
+
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${(0, import_provider_utils28.stringifyWithBigIntAndCycles)(part)}.`
|
|
4208
4292
|
});
|
|
4209
4293
|
}
|
|
4210
4294
|
}
|
|
@@ -4270,7 +4354,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4270
4354
|
})
|
|
4271
4355
|
);
|
|
4272
4356
|
const serializedToolOutputs = toolOutputs.map(
|
|
4273
|
-
({ output: output2 }) => typeof output2 === "string" ? output2 :
|
|
4357
|
+
({ output: output2 }) => typeof output2 === "string" ? output2 : (0, import_provider_utils28.stringifyWithBigIntAndCycles)(output2)
|
|
4274
4358
|
);
|
|
4275
4359
|
const hasPromptCacheBreakpoint = toolOutputs.some(
|
|
4276
4360
|
({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
|
|
@@ -4386,7 +4470,9 @@ ${text}`,
|
|
|
4386
4470
|
break;
|
|
4387
4471
|
case "json":
|
|
4388
4472
|
case "error-json":
|
|
4389
|
-
outputValue = convertScalarOutput(
|
|
4473
|
+
outputValue = convertScalarOutput(
|
|
4474
|
+
(0, import_provider_utils28.stringifyWithBigIntAndCycles)(output.value)
|
|
4475
|
+
);
|
|
4390
4476
|
break;
|
|
4391
4477
|
case "content":
|
|
4392
4478
|
outputValue = output.value.map((item) => {
|
|
@@ -5475,7 +5561,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils29.lazySchema)(
|
|
|
5475
5561
|
);
|
|
5476
5562
|
|
|
5477
5563
|
// src/responses/openai-responses-prepare-tools.ts
|
|
5478
|
-
var
|
|
5564
|
+
var import_provider10 = require("@ai-sdk/provider");
|
|
5479
5565
|
var import_provider_utils30 = require("@ai-sdk/provider-utils");
|
|
5480
5566
|
async function prepareResponsesTools({
|
|
5481
5567
|
tools,
|
|
@@ -5538,7 +5624,7 @@ async function prepareResponsesTools({
|
|
|
5538
5624
|
namespaceTools.set(namespace.name, namespaceTool);
|
|
5539
5625
|
openaiTools2.push(namespaceTool);
|
|
5540
5626
|
} else if (namespaceTool.description !== namespace.description) {
|
|
5541
|
-
throw new
|
|
5627
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
5542
5628
|
functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
|
|
5543
5629
|
});
|
|
5544
5630
|
}
|
|
@@ -5792,7 +5878,7 @@ async function prepareResponsesTools({
|
|
|
5792
5878
|
allowedToolEntries.push(resolution.entry);
|
|
5793
5879
|
}
|
|
5794
5880
|
if (allowedToolEntries.length === 0) {
|
|
5795
|
-
throw new
|
|
5881
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
5796
5882
|
functionality: `allowedTools with only tools that cannot be allow-listed (${droppedToolNames.join(
|
|
5797
5883
|
", "
|
|
5798
5884
|
)})`
|
|
@@ -5827,7 +5913,7 @@ async function prepareResponsesTools({
|
|
|
5827
5913
|
}
|
|
5828
5914
|
default: {
|
|
5829
5915
|
const _exhaustiveCheck = type;
|
|
5830
|
-
throw new
|
|
5916
|
+
throw new import_provider10.UnsupportedFunctionalityError({
|
|
5831
5917
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
5832
5918
|
});
|
|
5833
5919
|
}
|
|
@@ -6135,7 +6221,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6135
6221
|
}
|
|
6136
6222
|
for (let i = 1; i < input.length; i++) {
|
|
6137
6223
|
if (input[i - 1].type === "configuration_update" && input[i].type === "configuration_update") {
|
|
6138
|
-
throw new
|
|
6224
|
+
throw new import_provider11.UnsupportedFunctionalityError({
|
|
6139
6225
|
functionality: "Adjacent reasoning effort configuration updates"
|
|
6140
6226
|
});
|
|
6141
6227
|
}
|
|
@@ -6364,7 +6450,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6364
6450
|
fetch: this.config.fetch
|
|
6365
6451
|
});
|
|
6366
6452
|
if (response.error) {
|
|
6367
|
-
throw new
|
|
6453
|
+
throw new import_provider11.APICallError({
|
|
6368
6454
|
message: response.error.message,
|
|
6369
6455
|
url,
|
|
6370
6456
|
requestBodyValues: body,
|
|
@@ -7884,7 +7970,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
|
|
|
7884
7970
|
requestBodyValues,
|
|
7885
7971
|
responseHeaders
|
|
7886
7972
|
}) {
|
|
7887
|
-
return new
|
|
7973
|
+
return new import_provider11.APICallError({
|
|
7888
7974
|
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.",
|
|
7889
7975
|
url,
|
|
7890
7976
|
requestBodyValues,
|
|
@@ -8153,6 +8239,16 @@ var openAITranscriptionModelOptions = (0, import_provider_utils35.lazySchema)(
|
|
|
8153
8239
|
* The language of the input audio in ISO-639-1 format.
|
|
8154
8240
|
*/
|
|
8155
8241
|
language: import_v426.z.string().optional(),
|
|
8242
|
+
/**
|
|
8243
|
+
* Expected languages for REST transcription, e.g. with gpt-transcribe.
|
|
8244
|
+
* Use this instead of language. The API validates model support.
|
|
8245
|
+
*/
|
|
8246
|
+
languages: import_v426.z.array(import_v426.z.string()).optional(),
|
|
8247
|
+
/**
|
|
8248
|
+
* Vocabulary hints for REST transcription, e.g. names or technical terms.
|
|
8249
|
+
* The API validates model support.
|
|
8250
|
+
*/
|
|
8251
|
+
keywords: import_v426.z.array(import_v426.z.string()).optional(),
|
|
8156
8252
|
/**
|
|
8157
8253
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
8158
8254
|
*/
|
|
@@ -8264,6 +8360,8 @@ var OpenAITranscriptionModel = class {
|
|
|
8264
8360
|
const transcriptionModelOptions = {
|
|
8265
8361
|
include: openAIOptions.include,
|
|
8266
8362
|
language: openAIOptions.language,
|
|
8363
|
+
languages: openAIOptions.languages,
|
|
8364
|
+
keywords: openAIOptions.keywords,
|
|
8267
8365
|
prompt: openAIOptions.prompt,
|
|
8268
8366
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
8269
8367
|
// prefer verbose_json to get segments for models that support it
|
|
@@ -8340,7 +8438,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8340
8438
|
};
|
|
8341
8439
|
|
|
8342
8440
|
// src/version.ts
|
|
8343
|
-
var VERSION = true ? "3.0.
|
|
8441
|
+
var VERSION = true ? "3.0.137" : "0.0.0-test";
|
|
8344
8442
|
|
|
8345
8443
|
// src/openai-provider.ts
|
|
8346
8444
|
function createOpenAI(options = {}) {
|