@ai-sdk/openai 2.0.0-canary.12 → 2.0.0-canary.14
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 +24 -0
- package/dist/index.d.mts +8 -26
- package/dist/index.d.ts +8 -26
- package/dist/index.js +200 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +200 -180
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +31 -47
- package/dist/internal/index.d.ts +31 -47
- package/dist/internal/index.js +196 -174
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +195 -174
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -254,7 +254,13 @@ var openaiProviderOptions = z.object({
|
|
|
254
254
|
/**
|
|
255
255
|
* Parameters for prediction mode.
|
|
256
256
|
*/
|
|
257
|
-
prediction: z.record(z.any()).optional()
|
|
257
|
+
prediction: z.record(z.any()).optional(),
|
|
258
|
+
/**
|
|
259
|
+
* Whether to use structured outputs.
|
|
260
|
+
*
|
|
261
|
+
* @default true
|
|
262
|
+
*/
|
|
263
|
+
structuredOutputs: z.boolean().optional()
|
|
258
264
|
});
|
|
259
265
|
|
|
260
266
|
// src/openai-error.ts
|
|
@@ -337,20 +343,17 @@ function prepareTools({
|
|
|
337
343
|
|
|
338
344
|
// src/openai-chat-language-model.ts
|
|
339
345
|
var OpenAIChatLanguageModel = class {
|
|
340
|
-
constructor(modelId,
|
|
346
|
+
constructor(modelId, config) {
|
|
341
347
|
this.specificationVersion = "v2";
|
|
348
|
+
this.supportedUrls = {
|
|
349
|
+
"image/*": [/^https?:\/\/.*$/]
|
|
350
|
+
};
|
|
342
351
|
this.modelId = modelId;
|
|
343
|
-
this.settings = settings;
|
|
344
352
|
this.config = config;
|
|
345
353
|
}
|
|
346
354
|
get provider() {
|
|
347
355
|
return this.config.provider;
|
|
348
356
|
}
|
|
349
|
-
async getSupportedUrls() {
|
|
350
|
-
return {
|
|
351
|
-
"image/*": [/^https?:\/\/.*$/]
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
357
|
async getArgs({
|
|
355
358
|
prompt,
|
|
356
359
|
maxOutputTokens,
|
|
@@ -373,13 +376,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
373
376
|
providerOptions,
|
|
374
377
|
schema: openaiProviderOptions
|
|
375
378
|
})) != null ? _a : {};
|
|
379
|
+
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
376
380
|
if (topK != null) {
|
|
377
381
|
warnings.push({
|
|
378
382
|
type: "unsupported-setting",
|
|
379
383
|
setting: "topK"
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
|
-
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !
|
|
386
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
|
|
383
387
|
warnings.push({
|
|
384
388
|
type: "unsupported-setting",
|
|
385
389
|
setting: "responseFormat",
|
|
@@ -408,12 +412,12 @@ var OpenAIChatLanguageModel = class {
|
|
|
408
412
|
presence_penalty: presencePenalty,
|
|
409
413
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
|
|
410
414
|
// TODO convert into provider option
|
|
411
|
-
|
|
415
|
+
structuredOutputs && responseFormat.schema != null ? {
|
|
412
416
|
type: "json_schema",
|
|
413
417
|
json_schema: {
|
|
414
418
|
schema: responseFormat.schema,
|
|
415
419
|
strict: true,
|
|
416
|
-
name: (
|
|
420
|
+
name: (_c = responseFormat.name) != null ? _c : "response",
|
|
417
421
|
description: responseFormat.description
|
|
418
422
|
}
|
|
419
423
|
} : { type: "json_object" }
|
|
@@ -493,7 +497,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
493
497
|
} = prepareTools({
|
|
494
498
|
tools,
|
|
495
499
|
toolChoice,
|
|
496
|
-
structuredOutputs
|
|
500
|
+
structuredOutputs
|
|
497
501
|
});
|
|
498
502
|
return {
|
|
499
503
|
args: {
|
|
@@ -853,11 +857,23 @@ var reasoningModels = {
|
|
|
853
857
|
"o1-preview-2024-09-12": {
|
|
854
858
|
systemMessageMode: "remove"
|
|
855
859
|
},
|
|
860
|
+
o3: {
|
|
861
|
+
systemMessageMode: "developer"
|
|
862
|
+
},
|
|
863
|
+
"o3-2025-04-16": {
|
|
864
|
+
systemMessageMode: "developer"
|
|
865
|
+
},
|
|
856
866
|
"o3-mini": {
|
|
857
867
|
systemMessageMode: "developer"
|
|
858
868
|
},
|
|
859
869
|
"o3-mini-2025-01-31": {
|
|
860
870
|
systemMessageMode: "developer"
|
|
871
|
+
},
|
|
872
|
+
"o4-mini": {
|
|
873
|
+
systemMessageMode: "developer"
|
|
874
|
+
},
|
|
875
|
+
"o4-mini-2025-04-16": {
|
|
876
|
+
systemMessageMode: "developer"
|
|
861
877
|
}
|
|
862
878
|
};
|
|
863
879
|
|
|
@@ -878,13 +894,9 @@ import {
|
|
|
878
894
|
} from "@ai-sdk/provider";
|
|
879
895
|
function convertToOpenAICompletionPrompt({
|
|
880
896
|
prompt,
|
|
881
|
-
inputFormat,
|
|
882
897
|
user = "user",
|
|
883
898
|
assistant = "assistant"
|
|
884
899
|
}) {
|
|
885
|
-
if (inputFormat === "prompt" && prompt.length === 1 && prompt[0].role === "user" && prompt[0].content.length === 1 && prompt[0].content[0].type === "text") {
|
|
886
|
-
return { prompt: prompt[0].content[0].text };
|
|
887
|
-
}
|
|
888
900
|
let text = "";
|
|
889
901
|
if (prompt[0].role === "system") {
|
|
890
902
|
text += `${prompt[0].content}
|
|
@@ -990,6 +1002,9 @@ var openaiCompletionProviderOptions = z4.object({
|
|
|
990
1002
|
var OpenAICompletionLanguageModel = class {
|
|
991
1003
|
constructor(modelId, config) {
|
|
992
1004
|
this.specificationVersion = "v2";
|
|
1005
|
+
this.supportedUrls = {
|
|
1006
|
+
// No URLs are supported for completion models.
|
|
1007
|
+
};
|
|
993
1008
|
this.modelId = modelId;
|
|
994
1009
|
this.config = config;
|
|
995
1010
|
}
|
|
@@ -999,13 +1014,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
999
1014
|
get provider() {
|
|
1000
1015
|
return this.config.provider;
|
|
1001
1016
|
}
|
|
1002
|
-
async getSupportedUrls() {
|
|
1003
|
-
return {
|
|
1004
|
-
// no supported urls for completion models
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
1017
|
async getArgs({
|
|
1008
|
-
inputFormat,
|
|
1009
1018
|
prompt,
|
|
1010
1019
|
maxOutputTokens,
|
|
1011
1020
|
temperature,
|
|
@@ -1049,7 +1058,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1049
1058
|
details: "JSON response format is not supported."
|
|
1050
1059
|
});
|
|
1051
1060
|
}
|
|
1052
|
-
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt
|
|
1061
|
+
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt });
|
|
1053
1062
|
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
1054
1063
|
return {
|
|
1055
1064
|
args: {
|
|
@@ -1258,23 +1267,16 @@ var openaiEmbeddingProviderOptions = z6.object({
|
|
|
1258
1267
|
|
|
1259
1268
|
// src/openai-embedding-model.ts
|
|
1260
1269
|
var OpenAIEmbeddingModel = class {
|
|
1261
|
-
constructor(modelId,
|
|
1270
|
+
constructor(modelId, config) {
|
|
1262
1271
|
this.specificationVersion = "v2";
|
|
1272
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
1273
|
+
this.supportsParallelCalls = true;
|
|
1263
1274
|
this.modelId = modelId;
|
|
1264
|
-
this.settings = settings;
|
|
1265
1275
|
this.config = config;
|
|
1266
1276
|
}
|
|
1267
1277
|
get provider() {
|
|
1268
1278
|
return this.config.provider;
|
|
1269
1279
|
}
|
|
1270
|
-
get maxEmbeddingsPerCall() {
|
|
1271
|
-
var _a;
|
|
1272
|
-
return (_a = this.settings.maxEmbeddingsPerCall) != null ? _a : 2048;
|
|
1273
|
-
}
|
|
1274
|
-
get supportsParallelCalls() {
|
|
1275
|
-
var _a;
|
|
1276
|
-
return (_a = this.settings.supportsParallelCalls) != null ? _a : true;
|
|
1277
|
-
}
|
|
1278
1280
|
async doEmbed({
|
|
1279
1281
|
values,
|
|
1280
1282
|
headers,
|
|
@@ -1353,7 +1355,7 @@ var OpenAIImageModel = class {
|
|
|
1353
1355
|
this.modelId = modelId;
|
|
1354
1356
|
this.settings = settings;
|
|
1355
1357
|
this.config = config;
|
|
1356
|
-
this.specificationVersion = "
|
|
1358
|
+
this.specificationVersion = "v2";
|
|
1357
1359
|
}
|
|
1358
1360
|
get maxImagesPerCall() {
|
|
1359
1361
|
var _a, _b;
|
|
@@ -1450,14 +1452,36 @@ import {
|
|
|
1450
1452
|
parseProviderOptions as parseProviderOptions4,
|
|
1451
1453
|
postFormDataToApi
|
|
1452
1454
|
} from "@ai-sdk/provider-utils";
|
|
1455
|
+
import { z as z11 } from "zod";
|
|
1456
|
+
|
|
1457
|
+
// src/openai-transcription-options.ts
|
|
1453
1458
|
import { z as z10 } from "zod";
|
|
1454
|
-
var
|
|
1459
|
+
var openAITranscriptionProviderOptions = z10.object({
|
|
1460
|
+
/**
|
|
1461
|
+
* Additional information to include in the transcription response.
|
|
1462
|
+
*/
|
|
1455
1463
|
include: z10.array(z10.string()).nullish(),
|
|
1464
|
+
/**
|
|
1465
|
+
* The language of the input audio in ISO-639-1 format.
|
|
1466
|
+
*/
|
|
1456
1467
|
language: z10.string().nullish(),
|
|
1468
|
+
/**
|
|
1469
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
1470
|
+
*/
|
|
1457
1471
|
prompt: z10.string().nullish(),
|
|
1458
|
-
|
|
1459
|
-
|
|
1472
|
+
/**
|
|
1473
|
+
* The sampling temperature, between 0 and 1.
|
|
1474
|
+
* @default 0
|
|
1475
|
+
*/
|
|
1476
|
+
temperature: z10.number().min(0).max(1).default(0).nullish(),
|
|
1477
|
+
/**
|
|
1478
|
+
* The timestamp granularities to populate for this transcription.
|
|
1479
|
+
* @default ['segment']
|
|
1480
|
+
*/
|
|
1481
|
+
timestampGranularities: z10.array(z10.enum(["word", "segment"])).default(["segment"]).nullish()
|
|
1460
1482
|
});
|
|
1483
|
+
|
|
1484
|
+
// src/openai-transcription-model.ts
|
|
1461
1485
|
var languageMap = {
|
|
1462
1486
|
afrikaans: "af",
|
|
1463
1487
|
arabic: "ar",
|
|
@@ -1531,12 +1555,11 @@ var OpenAITranscriptionModel = class {
|
|
|
1531
1555
|
mediaType,
|
|
1532
1556
|
providerOptions
|
|
1533
1557
|
}) {
|
|
1534
|
-
var _a, _b, _c, _d, _e;
|
|
1535
1558
|
const warnings = [];
|
|
1536
1559
|
const openAIOptions = await parseProviderOptions4({
|
|
1537
1560
|
provider: "openai",
|
|
1538
1561
|
providerOptions,
|
|
1539
|
-
schema:
|
|
1562
|
+
schema: openAITranscriptionProviderOptions
|
|
1540
1563
|
});
|
|
1541
1564
|
const formData = new FormData();
|
|
1542
1565
|
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
@@ -1544,15 +1567,14 @@ var OpenAITranscriptionModel = class {
|
|
|
1544
1567
|
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1545
1568
|
if (openAIOptions) {
|
|
1546
1569
|
const transcriptionModelOptions = {
|
|
1547
|
-
include:
|
|
1548
|
-
language:
|
|
1549
|
-
prompt:
|
|
1550
|
-
temperature:
|
|
1551
|
-
timestamp_granularities:
|
|
1570
|
+
include: openAIOptions.include,
|
|
1571
|
+
language: openAIOptions.language,
|
|
1572
|
+
prompt: openAIOptions.prompt,
|
|
1573
|
+
temperature: openAIOptions.temperature,
|
|
1574
|
+
timestamp_granularities: openAIOptions.timestampGranularities
|
|
1552
1575
|
};
|
|
1553
|
-
for (const key
|
|
1554
|
-
|
|
1555
|
-
if (value !== void 0) {
|
|
1576
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) {
|
|
1577
|
+
if (value != null) {
|
|
1556
1578
|
formData.append(key, String(value));
|
|
1557
1579
|
}
|
|
1558
1580
|
}
|
|
@@ -1604,15 +1626,15 @@ var OpenAITranscriptionModel = class {
|
|
|
1604
1626
|
};
|
|
1605
1627
|
}
|
|
1606
1628
|
};
|
|
1607
|
-
var openaiTranscriptionResponseSchema =
|
|
1608
|
-
text:
|
|
1609
|
-
language:
|
|
1610
|
-
duration:
|
|
1611
|
-
words:
|
|
1612
|
-
|
|
1613
|
-
word:
|
|
1614
|
-
start:
|
|
1615
|
-
end:
|
|
1629
|
+
var openaiTranscriptionResponseSchema = z11.object({
|
|
1630
|
+
text: z11.string(),
|
|
1631
|
+
language: z11.string().nullish(),
|
|
1632
|
+
duration: z11.number().nullish(),
|
|
1633
|
+
words: z11.array(
|
|
1634
|
+
z11.object({
|
|
1635
|
+
word: z11.string(),
|
|
1636
|
+
start: z11.number(),
|
|
1637
|
+
end: z11.number()
|
|
1616
1638
|
})
|
|
1617
1639
|
).nullish()
|
|
1618
1640
|
});
|
|
@@ -1626,7 +1648,7 @@ import {
|
|
|
1626
1648
|
parseProviderOptions as parseProviderOptions5,
|
|
1627
1649
|
postJsonToApi as postJsonToApi5
|
|
1628
1650
|
} from "@ai-sdk/provider-utils";
|
|
1629
|
-
import { z as
|
|
1651
|
+
import { z as z12 } from "zod";
|
|
1630
1652
|
|
|
1631
1653
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1632
1654
|
import {
|
|
@@ -1839,13 +1861,11 @@ function prepareResponsesTools({
|
|
|
1839
1861
|
var OpenAIResponsesLanguageModel = class {
|
|
1840
1862
|
constructor(modelId, config) {
|
|
1841
1863
|
this.specificationVersion = "v2";
|
|
1842
|
-
this.
|
|
1843
|
-
this.config = config;
|
|
1844
|
-
}
|
|
1845
|
-
async getSupportedUrls() {
|
|
1846
|
-
return {
|
|
1864
|
+
this.supportedUrls = {
|
|
1847
1865
|
"image/*": [/^https?:\/\/.*$/]
|
|
1848
1866
|
};
|
|
1867
|
+
this.modelId = modelId;
|
|
1868
|
+
this.config = config;
|
|
1849
1869
|
}
|
|
1850
1870
|
get provider() {
|
|
1851
1871
|
return this.config.provider;
|
|
@@ -1991,55 +2011,55 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1991
2011
|
body,
|
|
1992
2012
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1993
2013
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
1994
|
-
|
|
1995
|
-
id:
|
|
1996
|
-
created_at:
|
|
1997
|
-
model:
|
|
1998
|
-
output:
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
type:
|
|
2002
|
-
role:
|
|
2003
|
-
content:
|
|
2004
|
-
|
|
2005
|
-
type:
|
|
2006
|
-
text:
|
|
2007
|
-
annotations:
|
|
2008
|
-
|
|
2009
|
-
type:
|
|
2010
|
-
start_index:
|
|
2011
|
-
end_index:
|
|
2012
|
-
url:
|
|
2013
|
-
title:
|
|
2014
|
+
z12.object({
|
|
2015
|
+
id: z12.string(),
|
|
2016
|
+
created_at: z12.number(),
|
|
2017
|
+
model: z12.string(),
|
|
2018
|
+
output: z12.array(
|
|
2019
|
+
z12.discriminatedUnion("type", [
|
|
2020
|
+
z12.object({
|
|
2021
|
+
type: z12.literal("message"),
|
|
2022
|
+
role: z12.literal("assistant"),
|
|
2023
|
+
content: z12.array(
|
|
2024
|
+
z12.object({
|
|
2025
|
+
type: z12.literal("output_text"),
|
|
2026
|
+
text: z12.string(),
|
|
2027
|
+
annotations: z12.array(
|
|
2028
|
+
z12.object({
|
|
2029
|
+
type: z12.literal("url_citation"),
|
|
2030
|
+
start_index: z12.number(),
|
|
2031
|
+
end_index: z12.number(),
|
|
2032
|
+
url: z12.string(),
|
|
2033
|
+
title: z12.string()
|
|
2014
2034
|
})
|
|
2015
2035
|
)
|
|
2016
2036
|
})
|
|
2017
2037
|
)
|
|
2018
2038
|
}),
|
|
2019
|
-
|
|
2020
|
-
type:
|
|
2021
|
-
call_id:
|
|
2022
|
-
name:
|
|
2023
|
-
arguments:
|
|
2039
|
+
z12.object({
|
|
2040
|
+
type: z12.literal("function_call"),
|
|
2041
|
+
call_id: z12.string(),
|
|
2042
|
+
name: z12.string(),
|
|
2043
|
+
arguments: z12.string()
|
|
2024
2044
|
}),
|
|
2025
|
-
|
|
2026
|
-
type:
|
|
2045
|
+
z12.object({
|
|
2046
|
+
type: z12.literal("web_search_call")
|
|
2027
2047
|
}),
|
|
2028
|
-
|
|
2029
|
-
type:
|
|
2048
|
+
z12.object({
|
|
2049
|
+
type: z12.literal("computer_call")
|
|
2030
2050
|
}),
|
|
2031
|
-
|
|
2032
|
-
type:
|
|
2033
|
-
summary:
|
|
2034
|
-
|
|
2035
|
-
type:
|
|
2036
|
-
text:
|
|
2051
|
+
z12.object({
|
|
2052
|
+
type: z12.literal("reasoning"),
|
|
2053
|
+
summary: z12.array(
|
|
2054
|
+
z12.object({
|
|
2055
|
+
type: z12.literal("summary_text"),
|
|
2056
|
+
text: z12.string()
|
|
2037
2057
|
})
|
|
2038
2058
|
)
|
|
2039
2059
|
})
|
|
2040
2060
|
])
|
|
2041
2061
|
),
|
|
2042
|
-
incomplete_details:
|
|
2062
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullable(),
|
|
2043
2063
|
usage: usageSchema
|
|
2044
2064
|
})
|
|
2045
2065
|
),
|
|
@@ -2253,86 +2273,86 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2253
2273
|
};
|
|
2254
2274
|
}
|
|
2255
2275
|
};
|
|
2256
|
-
var usageSchema =
|
|
2257
|
-
input_tokens:
|
|
2258
|
-
input_tokens_details:
|
|
2259
|
-
output_tokens:
|
|
2260
|
-
output_tokens_details:
|
|
2276
|
+
var usageSchema = z12.object({
|
|
2277
|
+
input_tokens: z12.number(),
|
|
2278
|
+
input_tokens_details: z12.object({ cached_tokens: z12.number().nullish() }).nullish(),
|
|
2279
|
+
output_tokens: z12.number(),
|
|
2280
|
+
output_tokens_details: z12.object({ reasoning_tokens: z12.number().nullish() }).nullish()
|
|
2261
2281
|
});
|
|
2262
|
-
var textDeltaChunkSchema =
|
|
2263
|
-
type:
|
|
2264
|
-
delta:
|
|
2282
|
+
var textDeltaChunkSchema = z12.object({
|
|
2283
|
+
type: z12.literal("response.output_text.delta"),
|
|
2284
|
+
delta: z12.string()
|
|
2265
2285
|
});
|
|
2266
|
-
var responseFinishedChunkSchema =
|
|
2267
|
-
type:
|
|
2268
|
-
response:
|
|
2269
|
-
incomplete_details:
|
|
2286
|
+
var responseFinishedChunkSchema = z12.object({
|
|
2287
|
+
type: z12.enum(["response.completed", "response.incomplete"]),
|
|
2288
|
+
response: z12.object({
|
|
2289
|
+
incomplete_details: z12.object({ reason: z12.string() }).nullish(),
|
|
2270
2290
|
usage: usageSchema
|
|
2271
2291
|
})
|
|
2272
2292
|
});
|
|
2273
|
-
var responseCreatedChunkSchema =
|
|
2274
|
-
type:
|
|
2275
|
-
response:
|
|
2276
|
-
id:
|
|
2277
|
-
created_at:
|
|
2278
|
-
model:
|
|
2293
|
+
var responseCreatedChunkSchema = z12.object({
|
|
2294
|
+
type: z12.literal("response.created"),
|
|
2295
|
+
response: z12.object({
|
|
2296
|
+
id: z12.string(),
|
|
2297
|
+
created_at: z12.number(),
|
|
2298
|
+
model: z12.string()
|
|
2279
2299
|
})
|
|
2280
2300
|
});
|
|
2281
|
-
var responseOutputItemDoneSchema =
|
|
2282
|
-
type:
|
|
2283
|
-
output_index:
|
|
2284
|
-
item:
|
|
2285
|
-
|
|
2286
|
-
type:
|
|
2301
|
+
var responseOutputItemDoneSchema = z12.object({
|
|
2302
|
+
type: z12.literal("response.output_item.done"),
|
|
2303
|
+
output_index: z12.number(),
|
|
2304
|
+
item: z12.discriminatedUnion("type", [
|
|
2305
|
+
z12.object({
|
|
2306
|
+
type: z12.literal("message")
|
|
2287
2307
|
}),
|
|
2288
|
-
|
|
2289
|
-
type:
|
|
2290
|
-
id:
|
|
2291
|
-
call_id:
|
|
2292
|
-
name:
|
|
2293
|
-
arguments:
|
|
2294
|
-
status:
|
|
2308
|
+
z12.object({
|
|
2309
|
+
type: z12.literal("function_call"),
|
|
2310
|
+
id: z12.string(),
|
|
2311
|
+
call_id: z12.string(),
|
|
2312
|
+
name: z12.string(),
|
|
2313
|
+
arguments: z12.string(),
|
|
2314
|
+
status: z12.literal("completed")
|
|
2295
2315
|
})
|
|
2296
2316
|
])
|
|
2297
2317
|
});
|
|
2298
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2299
|
-
type:
|
|
2300
|
-
item_id:
|
|
2301
|
-
output_index:
|
|
2302
|
-
delta:
|
|
2318
|
+
var responseFunctionCallArgumentsDeltaSchema = z12.object({
|
|
2319
|
+
type: z12.literal("response.function_call_arguments.delta"),
|
|
2320
|
+
item_id: z12.string(),
|
|
2321
|
+
output_index: z12.number(),
|
|
2322
|
+
delta: z12.string()
|
|
2303
2323
|
});
|
|
2304
|
-
var responseOutputItemAddedSchema =
|
|
2305
|
-
type:
|
|
2306
|
-
output_index:
|
|
2307
|
-
item:
|
|
2308
|
-
|
|
2309
|
-
type:
|
|
2324
|
+
var responseOutputItemAddedSchema = z12.object({
|
|
2325
|
+
type: z12.literal("response.output_item.added"),
|
|
2326
|
+
output_index: z12.number(),
|
|
2327
|
+
item: z12.discriminatedUnion("type", [
|
|
2328
|
+
z12.object({
|
|
2329
|
+
type: z12.literal("message")
|
|
2310
2330
|
}),
|
|
2311
|
-
|
|
2312
|
-
type:
|
|
2313
|
-
id:
|
|
2314
|
-
call_id:
|
|
2315
|
-
name:
|
|
2316
|
-
arguments:
|
|
2331
|
+
z12.object({
|
|
2332
|
+
type: z12.literal("function_call"),
|
|
2333
|
+
id: z12.string(),
|
|
2334
|
+
call_id: z12.string(),
|
|
2335
|
+
name: z12.string(),
|
|
2336
|
+
arguments: z12.string()
|
|
2317
2337
|
})
|
|
2318
2338
|
])
|
|
2319
2339
|
});
|
|
2320
|
-
var responseAnnotationAddedSchema =
|
|
2321
|
-
type:
|
|
2322
|
-
annotation:
|
|
2323
|
-
type:
|
|
2324
|
-
url:
|
|
2325
|
-
title:
|
|
2340
|
+
var responseAnnotationAddedSchema = z12.object({
|
|
2341
|
+
type: z12.literal("response.output_text.annotation.added"),
|
|
2342
|
+
annotation: z12.object({
|
|
2343
|
+
type: z12.literal("url_citation"),
|
|
2344
|
+
url: z12.string(),
|
|
2345
|
+
title: z12.string()
|
|
2326
2346
|
})
|
|
2327
2347
|
});
|
|
2328
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
2329
|
-
type:
|
|
2330
|
-
item_id:
|
|
2331
|
-
output_index:
|
|
2332
|
-
summary_index:
|
|
2333
|
-
delta:
|
|
2348
|
+
var responseReasoningSummaryTextDeltaSchema = z12.object({
|
|
2349
|
+
type: z12.literal("response.reasoning_summary_text.delta"),
|
|
2350
|
+
item_id: z12.string(),
|
|
2351
|
+
output_index: z12.number(),
|
|
2352
|
+
summary_index: z12.number(),
|
|
2353
|
+
delta: z12.string()
|
|
2334
2354
|
});
|
|
2335
|
-
var openaiResponsesChunkSchema =
|
|
2355
|
+
var openaiResponsesChunkSchema = z12.union([
|
|
2336
2356
|
textDeltaChunkSchema,
|
|
2337
2357
|
responseFinishedChunkSchema,
|
|
2338
2358
|
responseCreatedChunkSchema,
|
|
@@ -2341,7 +2361,7 @@ var openaiResponsesChunkSchema = z11.union([
|
|
|
2341
2361
|
responseOutputItemAddedSchema,
|
|
2342
2362
|
responseAnnotationAddedSchema,
|
|
2343
2363
|
responseReasoningSummaryTextDeltaSchema,
|
|
2344
|
-
|
|
2364
|
+
z12.object({ type: z12.string() }).passthrough()
|
|
2345
2365
|
// fallback for unknown chunks
|
|
2346
2366
|
]);
|
|
2347
2367
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2389,16 +2409,16 @@ function getResponsesModelConfig(modelId) {
|
|
|
2389
2409
|
requiredAutoTruncation: false
|
|
2390
2410
|
};
|
|
2391
2411
|
}
|
|
2392
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2393
|
-
metadata:
|
|
2394
|
-
parallelToolCalls:
|
|
2395
|
-
previousResponseId:
|
|
2396
|
-
store:
|
|
2397
|
-
user:
|
|
2398
|
-
reasoningEffort:
|
|
2399
|
-
strictSchemas:
|
|
2400
|
-
instructions:
|
|
2401
|
-
reasoningSummary:
|
|
2412
|
+
var openaiResponsesProviderOptionsSchema = z12.object({
|
|
2413
|
+
metadata: z12.any().nullish(),
|
|
2414
|
+
parallelToolCalls: z12.boolean().nullish(),
|
|
2415
|
+
previousResponseId: z12.string().nullish(),
|
|
2416
|
+
store: z12.boolean().nullish(),
|
|
2417
|
+
user: z12.string().nullish(),
|
|
2418
|
+
reasoningEffort: z12.string().nullish(),
|
|
2419
|
+
strictSchemas: z12.boolean().nullish(),
|
|
2420
|
+
instructions: z12.string().nullish(),
|
|
2421
|
+
reasoningSummary: z12.string().nullish()
|
|
2402
2422
|
});
|
|
2403
2423
|
|
|
2404
2424
|
// src/openai-speech-model.ts
|
|
@@ -2408,10 +2428,10 @@ import {
|
|
|
2408
2428
|
parseProviderOptions as parseProviderOptions6,
|
|
2409
2429
|
postJsonToApi as postJsonToApi6
|
|
2410
2430
|
} from "@ai-sdk/provider-utils";
|
|
2411
|
-
import { z as
|
|
2412
|
-
var OpenAIProviderOptionsSchema =
|
|
2413
|
-
instructions:
|
|
2414
|
-
speed:
|
|
2431
|
+
import { z as z13 } from "zod";
|
|
2432
|
+
var OpenAIProviderOptionsSchema = z13.object({
|
|
2433
|
+
instructions: z13.string().nullish(),
|
|
2434
|
+
speed: z13.number().min(0.25).max(4).default(1).nullish()
|
|
2415
2435
|
});
|
|
2416
2436
|
var OpenAISpeechModel = class {
|
|
2417
2437
|
constructor(modelId, config) {
|
|
@@ -2521,7 +2541,7 @@ function createOpenAI(options = {}) {
|
|
|
2521
2541
|
"OpenAI-Project": options.project,
|
|
2522
2542
|
...options.headers
|
|
2523
2543
|
});
|
|
2524
|
-
const createChatModel = (modelId
|
|
2544
|
+
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
2525
2545
|
provider: `${providerName}.chat`,
|
|
2526
2546
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2527
2547
|
headers: getHeaders,
|
|
@@ -2535,7 +2555,7 @@ function createOpenAI(options = {}) {
|
|
|
2535
2555
|
compatibility,
|
|
2536
2556
|
fetch: options.fetch
|
|
2537
2557
|
});
|
|
2538
|
-
const createEmbeddingModel = (modelId
|
|
2558
|
+
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
2539
2559
|
provider: `${providerName}.embedding`,
|
|
2540
2560
|
url: ({ path }) => `${baseURL}${path}`,
|
|
2541
2561
|
headers: getHeaders,
|
|
@@ -2559,7 +2579,7 @@ function createOpenAI(options = {}) {
|
|
|
2559
2579
|
headers: getHeaders,
|
|
2560
2580
|
fetch: options.fetch
|
|
2561
2581
|
});
|
|
2562
|
-
const createLanguageModel = (modelId
|
|
2582
|
+
const createLanguageModel = (modelId) => {
|
|
2563
2583
|
if (new.target) {
|
|
2564
2584
|
throw new Error(
|
|
2565
2585
|
"The OpenAI model function cannot be called with the new keyword."
|
|
@@ -2568,7 +2588,7 @@ function createOpenAI(options = {}) {
|
|
|
2568
2588
|
if (modelId === "gpt-3.5-turbo-instruct") {
|
|
2569
2589
|
return createCompletionModel(modelId);
|
|
2570
2590
|
}
|
|
2571
|
-
return createChatModel(modelId
|
|
2591
|
+
return createChatModel(modelId);
|
|
2572
2592
|
};
|
|
2573
2593
|
const createResponsesModel = (modelId) => {
|
|
2574
2594
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
@@ -2578,8 +2598,8 @@ function createOpenAI(options = {}) {
|
|
|
2578
2598
|
fetch: options.fetch
|
|
2579
2599
|
});
|
|
2580
2600
|
};
|
|
2581
|
-
const provider = function(modelId
|
|
2582
|
-
return createLanguageModel(modelId
|
|
2601
|
+
const provider = function(modelId) {
|
|
2602
|
+
return createLanguageModel(modelId);
|
|
2583
2603
|
};
|
|
2584
2604
|
provider.languageModel = createLanguageModel;
|
|
2585
2605
|
provider.chat = createChatModel;
|