@ai-sdk/openai 4.0.58 → 4.0.60
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 +13 -0
- package/dist/index.d.ts +16 -8
- package/dist/index.js +166 -26
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +24 -11
- package/dist/internal/index.js +165 -25
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +95 -7
- package/package.json +1 -1
- package/src/chat/openai-chat-language-model-options.ts +1 -0
- package/src/chat/openai-chat-language-model.ts +29 -1
- package/src/openai-language-model-capabilities.ts +8 -0
- package/src/responses/openai-responses-api.ts +8 -0
- package/src/responses/openai-responses-language-model-options.ts +14 -0
- package/src/responses/openai-responses-language-model.ts +73 -1
- package/src/transcription/openai-transcription-api.ts +22 -12
- package/src/transcription/openai-transcription-model-options.ts +22 -0
- package/src/transcription/openai-transcription-model.ts +55 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 17e489e: feat(openai): add GPT-6 reasoning configuration updates
|
|
8
|
+
|
|
9
|
+
## 4.0.59
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4af00d1: feat(openai): add support for the gpt-6-astra
|
|
14
|
+
- abb9ebf: feat(openai): support `gpt-4o-transcribe-diarize`, including chunking and diarized speaker metadata
|
|
15
|
+
|
|
3
16
|
## 4.0.58
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
|
4
4
|
import { InferSchema, FetchFunction, WebSocketConstructor, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
|
|
7
|
-
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | (string & {});
|
|
7
|
+
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | (string & {});
|
|
8
8
|
declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
9
9
|
logitBias?: Record<number, number> | undefined;
|
|
10
10
|
logprobs?: number | boolean | undefined;
|
|
11
11
|
parallelToolCalls?: boolean | undefined;
|
|
12
12
|
user?: string | undefined;
|
|
13
|
-
reasoningEffort?: "
|
|
13
|
+
reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
|
|
14
14
|
maxCompletionTokens?: number | undefined;
|
|
15
15
|
store?: boolean | undefined;
|
|
16
16
|
metadata?: Record<string, string> | undefined;
|
|
@@ -49,7 +49,7 @@ type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOption
|
|
|
49
49
|
|
|
50
50
|
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
|
|
51
51
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
52
|
-
quality?: "
|
|
52
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
53
53
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
54
54
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
55
55
|
outputCompression?: number | undefined;
|
|
@@ -57,17 +57,17 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
57
57
|
}>;
|
|
58
58
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
59
59
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
60
|
-
quality?: "
|
|
60
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
61
61
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
62
62
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
63
63
|
outputCompression?: number | undefined;
|
|
64
64
|
user?: string | undefined;
|
|
65
65
|
style?: "vivid" | "natural" | undefined;
|
|
66
|
-
moderation?: "
|
|
66
|
+
moderation?: "low" | "auto" | undefined;
|
|
67
67
|
}>;
|
|
68
68
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
69
69
|
declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
70
|
-
quality?: "
|
|
70
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
71
71
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
72
72
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
73
73
|
outputCompression?: number | undefined;
|
|
@@ -1365,7 +1365,7 @@ declare const openaiTools: {
|
|
|
1365
1365
|
}, {}>;
|
|
1366
1366
|
};
|
|
1367
1367
|
|
|
1368
|
-
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
1368
|
+
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
1369
1369
|
declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
1370
1370
|
conversation?: string | null | undefined;
|
|
1371
1371
|
include?: ("web_search_call.results" | "file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
|
|
@@ -1382,6 +1382,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1382
1382
|
} | undefined;
|
|
1383
1383
|
promptCacheRetention?: "in_memory" | "24h" | null | undefined;
|
|
1384
1384
|
reasoningEffort?: string | null | undefined;
|
|
1385
|
+
reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
1385
1386
|
reasoningMode?: "standard" | "pro" | undefined;
|
|
1386
1387
|
reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
|
|
1387
1388
|
reasoningSummary?: string | null | undefined;
|
|
@@ -1421,8 +1422,15 @@ declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema
|
|
|
1421
1422
|
prompt?: string | undefined;
|
|
1422
1423
|
temperature?: number | undefined;
|
|
1423
1424
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
|
1425
|
+
responseFormat?: "json" | "verbose_json" | "diarized_json" | undefined;
|
|
1426
|
+
chunkingStrategy?: "auto" | {
|
|
1427
|
+
type: "server_vad";
|
|
1428
|
+
threshold?: number | undefined;
|
|
1429
|
+
prefixPaddingMs?: number | undefined;
|
|
1430
|
+
silenceDurationMs?: number | undefined;
|
|
1431
|
+
} | undefined;
|
|
1424
1432
|
streaming?: {
|
|
1425
|
-
delay?: "
|
|
1433
|
+
delay?: "low" | "medium" | "high" | "xhigh" | "minimal" | undefined;
|
|
1426
1434
|
include?: string[] | undefined;
|
|
1427
1435
|
} | undefined;
|
|
1428
1436
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -48,14 +48,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
48
48
|
const gptVersion = getGptVersion(modelId);
|
|
49
49
|
const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
|
|
50
50
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
51
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
51
52
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
52
53
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
53
54
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
54
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
55
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
55
56
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
56
57
|
return {
|
|
57
58
|
supportsFlexProcessing,
|
|
58
59
|
supportsPriorityProcessing,
|
|
60
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
61
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
59
62
|
isReasoningModel,
|
|
60
63
|
systemMessageMode,
|
|
61
64
|
supportsNonReasoningParameters
|
|
@@ -1020,7 +1023,17 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
1020
1023
|
schema: openaiLanguageModelChatOptions
|
|
1021
1024
|
})) != null ? _a2 : {};
|
|
1022
1025
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
1023
|
-
|
|
1026
|
+
let resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
|
|
1027
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
1028
|
+
resolvedReasoningEffort
|
|
1029
|
+
)) {
|
|
1030
|
+
warnings.push({
|
|
1031
|
+
type: "unsupported",
|
|
1032
|
+
feature: "reasoningEffort",
|
|
1033
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
1034
|
+
});
|
|
1035
|
+
resolvedReasoningEffort = void 0;
|
|
1036
|
+
}
|
|
1024
1037
|
const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
|
|
1025
1038
|
if (topK != null) {
|
|
1026
1039
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -1075,6 +1088,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
1075
1088
|
// messages:
|
|
1076
1089
|
messages
|
|
1077
1090
|
};
|
|
1091
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
1092
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
1093
|
+
warnings.push({
|
|
1094
|
+
type: "unsupported",
|
|
1095
|
+
feature: "promptCacheRetention",
|
|
1096
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1078
1099
|
if (isReasoningModel) {
|
|
1079
1100
|
if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
1080
1101
|
if (baseArgs.temperature != null) {
|
|
@@ -5950,7 +5971,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5950
5971
|
"gpt-5.6",
|
|
5951
5972
|
"gpt-5.6-luna",
|
|
5952
5973
|
"gpt-5.6-sol",
|
|
5953
|
-
"gpt-5.6-terra"
|
|
5974
|
+
"gpt-5.6-terra",
|
|
5975
|
+
"gpt-6-astra"
|
|
5954
5976
|
];
|
|
5955
5977
|
var openaiResponsesModelIds = [
|
|
5956
5978
|
"gpt-4.1",
|
|
@@ -6072,6 +6094,15 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
|
|
|
6072
6094
|
* Supported values vary by model.
|
|
6073
6095
|
*/
|
|
6074
6096
|
reasoningEffort: z27.string().nullish(),
|
|
6097
|
+
/**
|
|
6098
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
6099
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
6100
|
+
* request prefix for prompt caching.
|
|
6101
|
+
*
|
|
6102
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
6103
|
+
* combined with automatic compaction or automatic truncation.
|
|
6104
|
+
*/
|
|
6105
|
+
reasoningEffortUpdate: z27.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
6075
6106
|
/**
|
|
6076
6107
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
6077
6108
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -6797,7 +6828,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6797
6828
|
toolChoice,
|
|
6798
6829
|
responseFormat
|
|
6799
6830
|
}) {
|
|
6800
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6831
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
6801
6832
|
const warnings = [];
|
|
6802
6833
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
6803
6834
|
if (topK != null) {
|
|
@@ -6828,7 +6859,17 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6828
6859
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
6829
6860
|
});
|
|
6830
6861
|
}
|
|
6831
|
-
|
|
6862
|
+
let resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
|
|
6863
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
6864
|
+
resolvedReasoningEffort
|
|
6865
|
+
)) {
|
|
6866
|
+
warnings.push({
|
|
6867
|
+
type: "unsupported",
|
|
6868
|
+
feature: "reasoningEffort",
|
|
6869
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
6870
|
+
});
|
|
6871
|
+
resolvedReasoningEffort = void 0;
|
|
6872
|
+
}
|
|
6832
6873
|
const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
|
|
6833
6874
|
const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
6834
6875
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
@@ -6888,6 +6929,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6888
6929
|
outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
|
|
6889
6930
|
});
|
|
6890
6931
|
warnings.push(...inputWarnings);
|
|
6932
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
6933
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.contextManagement) == null && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
6934
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
6935
|
+
warnings.push({
|
|
6936
|
+
type: "unsupported",
|
|
6937
|
+
feature: "reasoningEffortUpdate",
|
|
6938
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic compaction or automatic truncation"
|
|
6939
|
+
});
|
|
6940
|
+
} else if (reasoningEffortUpdate != null) {
|
|
6941
|
+
input.unshift({
|
|
6942
|
+
type: "configuration_update",
|
|
6943
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
6944
|
+
});
|
|
6945
|
+
}
|
|
6891
6946
|
if (openaiOptions == null ? void 0 : openaiOptions.compactionTrigger) {
|
|
6892
6947
|
input.push({ type: "compaction_trigger" });
|
|
6893
6948
|
}
|
|
@@ -6988,6 +7043,14 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6988
7043
|
}
|
|
6989
7044
|
}
|
|
6990
7045
|
};
|
|
7046
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
7047
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
7048
|
+
warnings.push({
|
|
7049
|
+
type: "unsupported",
|
|
7050
|
+
feature: "promptCacheRetention",
|
|
7051
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
7052
|
+
});
|
|
7053
|
+
}
|
|
6991
7054
|
if (isReasoningModel) {
|
|
6992
7055
|
if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6993
7056
|
if (baseArgs.temperature != null) {
|
|
@@ -7006,6 +7069,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7006
7069
|
details: "topP is not supported for reasoning models"
|
|
7007
7070
|
});
|
|
7008
7071
|
}
|
|
7072
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_j = baseArgs.include) == null ? void 0 : _j.includes("message.output_text.logprobs")))) {
|
|
7073
|
+
baseArgs.top_logprobs = void 0;
|
|
7074
|
+
const filteredInclude = (_k = baseArgs.include) == null ? void 0 : _k.filter(
|
|
7075
|
+
(value) => value !== "message.output_text.logprobs"
|
|
7076
|
+
);
|
|
7077
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
7078
|
+
warnings.push({
|
|
7079
|
+
type: "unsupported",
|
|
7080
|
+
feature: "logprobs",
|
|
7081
|
+
details: "logprobs is not supported for reasoning models"
|
|
7082
|
+
});
|
|
7083
|
+
}
|
|
7009
7084
|
}
|
|
7010
7085
|
} else {
|
|
7011
7086
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
@@ -7053,9 +7128,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7053
7128
|
});
|
|
7054
7129
|
delete baseArgs.service_tier;
|
|
7055
7130
|
}
|
|
7056
|
-
const shellToolEnvType = (
|
|
7131
|
+
const shellToolEnvType = (_n = (_m = (_l = tools == null ? void 0 : tools.find(
|
|
7057
7132
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
7058
|
-
)) == null ? void 0 :
|
|
7133
|
+
)) == null ? void 0 : _l.args) == null ? void 0 : _m.environment) == null ? void 0 : _n.type;
|
|
7059
7134
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
7060
7135
|
return {
|
|
7061
7136
|
webSearchToolName,
|
|
@@ -10097,18 +10172,28 @@ var openaiTranscriptionResponseSchema = lazySchema28(
|
|
|
10097
10172
|
})
|
|
10098
10173
|
).nullish(),
|
|
10099
10174
|
segments: z30.array(
|
|
10100
|
-
z30.
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10175
|
+
z30.union([
|
|
10176
|
+
z30.object({
|
|
10177
|
+
id: z30.number(),
|
|
10178
|
+
seek: z30.number(),
|
|
10179
|
+
start: z30.number(),
|
|
10180
|
+
end: z30.number(),
|
|
10181
|
+
text: z30.string(),
|
|
10182
|
+
tokens: z30.array(z30.number()),
|
|
10183
|
+
temperature: z30.number(),
|
|
10184
|
+
avg_logprob: z30.number(),
|
|
10185
|
+
compression_ratio: z30.number(),
|
|
10186
|
+
no_speech_prob: z30.number()
|
|
10187
|
+
}),
|
|
10188
|
+
z30.object({
|
|
10189
|
+
type: z30.literal("transcript.text.segment"),
|
|
10190
|
+
id: z30.string(),
|
|
10191
|
+
start: z30.number(),
|
|
10192
|
+
end: z30.number(),
|
|
10193
|
+
text: z30.string(),
|
|
10194
|
+
speaker: z30.string()
|
|
10195
|
+
})
|
|
10196
|
+
])
|
|
10112
10197
|
).nullish()
|
|
10113
10198
|
})
|
|
10114
10199
|
)
|
|
@@ -10145,6 +10230,22 @@ var openAITranscriptionModelOptions = lazySchema29(
|
|
|
10145
10230
|
* @default ['segment']
|
|
10146
10231
|
*/
|
|
10147
10232
|
timestampGranularities: z31.array(z31.enum(["word", "segment"])).default(["segment"]).optional(),
|
|
10233
|
+
/**
|
|
10234
|
+
* The format of the transcription response.
|
|
10235
|
+
*/
|
|
10236
|
+
responseFormat: z31.enum(["json", "verbose_json", "diarized_json"]).optional(),
|
|
10237
|
+
/**
|
|
10238
|
+
* Controls how the audio is split into chunks before transcription.
|
|
10239
|
+
*/
|
|
10240
|
+
chunkingStrategy: z31.union([
|
|
10241
|
+
z31.literal("auto"),
|
|
10242
|
+
z31.object({
|
|
10243
|
+
type: z31.literal("server_vad"),
|
|
10244
|
+
threshold: z31.number().min(0).max(1).optional(),
|
|
10245
|
+
prefixPaddingMs: z31.number().int().min(0).optional(),
|
|
10246
|
+
silenceDurationMs: z31.number().int().min(0).optional()
|
|
10247
|
+
})
|
|
10248
|
+
]).optional(),
|
|
10148
10249
|
/**
|
|
10149
10250
|
* Options for streaming transcription models such as `gpt-realtime-whisper`.
|
|
10150
10251
|
*/
|
|
@@ -10248,6 +10349,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10248
10349
|
mediaType,
|
|
10249
10350
|
providerOptions
|
|
10250
10351
|
}) {
|
|
10352
|
+
var _a2, _b;
|
|
10251
10353
|
const warnings = [];
|
|
10252
10354
|
const openAIOptions = await parseProviderOptions10({
|
|
10253
10355
|
provider: "openai",
|
|
@@ -10266,6 +10368,8 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10266
10368
|
if (this.modelId === "whisper-1") {
|
|
10267
10369
|
formData.append("response_format", "verbose_json");
|
|
10268
10370
|
}
|
|
10371
|
+
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
10372
|
+
const chunkingStrategy = (_a2 = openAIOptions == null ? void 0 : openAIOptions.chunkingStrategy) != null ? _a2 : isDiarizationModel ? "auto" : void 0;
|
|
10269
10373
|
if (openAIOptions) {
|
|
10270
10374
|
const isGpt4oTranscribeModel = [
|
|
10271
10375
|
"gpt-4o-transcribe",
|
|
@@ -10278,7 +10382,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10278
10382
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
10279
10383
|
// prefer verbose_json to get segments for models that support it
|
|
10280
10384
|
...this.modelId !== "whisper-1" && {
|
|
10281
|
-
response_format: isGpt4oTranscribeModel ? "json" : "verbose_json"
|
|
10385
|
+
response_format: (_b = openAIOptions.responseFormat) != null ? _b : isDiarizationModel ? "diarized_json" : isGpt4oTranscribeModel ? "json" : "verbose_json"
|
|
10282
10386
|
},
|
|
10283
10387
|
temperature: openAIOptions.temperature,
|
|
10284
10388
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
@@ -10294,6 +10398,25 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10294
10398
|
}
|
|
10295
10399
|
}
|
|
10296
10400
|
}
|
|
10401
|
+
} else if (isDiarizationModel) {
|
|
10402
|
+
formData.append("response_format", "diarized_json");
|
|
10403
|
+
}
|
|
10404
|
+
if (chunkingStrategy != null) {
|
|
10405
|
+
formData.append(
|
|
10406
|
+
"chunking_strategy",
|
|
10407
|
+
typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
10408
|
+
type: chunkingStrategy.type,
|
|
10409
|
+
...chunkingStrategy.threshold != null && {
|
|
10410
|
+
threshold: chunkingStrategy.threshold
|
|
10411
|
+
},
|
|
10412
|
+
...chunkingStrategy.prefixPaddingMs != null && {
|
|
10413
|
+
prefix_padding_ms: chunkingStrategy.prefixPaddingMs
|
|
10414
|
+
},
|
|
10415
|
+
...chunkingStrategy.silenceDurationMs != null && {
|
|
10416
|
+
silence_duration_ms: chunkingStrategy.silenceDurationMs
|
|
10417
|
+
}
|
|
10418
|
+
})
|
|
10419
|
+
);
|
|
10297
10420
|
}
|
|
10298
10421
|
return {
|
|
10299
10422
|
formData,
|
|
@@ -10301,7 +10424,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10301
10424
|
};
|
|
10302
10425
|
}
|
|
10303
10426
|
async doGenerate(options) {
|
|
10304
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10427
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
10305
10428
|
if (isRealtimeTranscriptionModelId(this.modelId)) {
|
|
10306
10429
|
throw new UnsupportedFunctionalityError6({
|
|
10307
10430
|
functionality: `non-streaming transcription with ${this.modelId}`
|
|
@@ -10328,25 +10451,42 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10328
10451
|
fetch: this.config.fetch
|
|
10329
10452
|
});
|
|
10330
10453
|
const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
|
|
10454
|
+
const diarizedSegments = (_f = response.segments) == null ? void 0 : _f.flatMap(
|
|
10455
|
+
(segment) => "speaker" in segment ? [
|
|
10456
|
+
{
|
|
10457
|
+
text: segment.text,
|
|
10458
|
+
startSecond: segment.start,
|
|
10459
|
+
endSecond: segment.end,
|
|
10460
|
+
speaker: segment.speaker
|
|
10461
|
+
}
|
|
10462
|
+
] : []
|
|
10463
|
+
);
|
|
10331
10464
|
return {
|
|
10332
10465
|
text: response.text,
|
|
10333
|
-
segments: (
|
|
10466
|
+
segments: (_j = (_i = (_g = response.segments) == null ? void 0 : _g.map((segment) => ({
|
|
10334
10467
|
text: segment.text,
|
|
10335
10468
|
startSecond: segment.start,
|
|
10336
10469
|
endSecond: segment.end
|
|
10337
|
-
}))) != null ?
|
|
10470
|
+
}))) != null ? _i : (_h = response.words) == null ? void 0 : _h.map((word) => ({
|
|
10338
10471
|
text: word.word,
|
|
10339
10472
|
startSecond: word.start,
|
|
10340
10473
|
endSecond: word.end
|
|
10341
|
-
}))) != null ?
|
|
10474
|
+
}))) != null ? _j : [],
|
|
10342
10475
|
language,
|
|
10343
|
-
durationInSeconds: (
|
|
10476
|
+
durationInSeconds: (_k = response.duration) != null ? _k : void 0,
|
|
10344
10477
|
warnings,
|
|
10345
10478
|
response: {
|
|
10346
10479
|
timestamp: currentDate,
|
|
10347
10480
|
modelId: this.modelId,
|
|
10348
10481
|
headers: responseHeaders,
|
|
10349
10482
|
body: rawResponse
|
|
10483
|
+
},
|
|
10484
|
+
...diarizedSegments != null && diarizedSegments.length > 0 && {
|
|
10485
|
+
providerMetadata: {
|
|
10486
|
+
openai: {
|
|
10487
|
+
segments: diarizedSegments
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10350
10490
|
}
|
|
10351
10491
|
};
|
|
10352
10492
|
}
|
|
@@ -10994,7 +11134,7 @@ var OpenAISkills = class {
|
|
|
10994
11134
|
};
|
|
10995
11135
|
|
|
10996
11136
|
// src/version.ts
|
|
10997
|
-
var VERSION = true ? "4.0.
|
|
11137
|
+
var VERSION = true ? "4.0.60" : "0.0.0-test";
|
|
10998
11138
|
|
|
10999
11139
|
// src/openai-provider.ts
|
|
11000
11140
|
function createOpenAI(options = {}) {
|