@ai-sdk/openai 4.0.57 → 4.0.59
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 +14 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.js +97 -24
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +26 -12
- package/dist/internal/index.js +96 -23
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +33 -8
- package/package.json +1 -1
- package/src/chat/openai-chat-language-model-options.ts +3 -1
- package/src/responses/openai-responses-api.ts +9 -2
- package/src/responses/openai-responses-language-model-options.ts +4 -1
- package/src/responses/openai-responses-prepare-tools.ts +1 -0
- package/src/tool/image-generation.ts +16 -6
- 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,19 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.59
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4af00d1: feat(openai): add support for the gpt-6-astra
|
|
8
|
+
- abb9ebf: feat(openai): support `gpt-4o-transcribe-diarize`, including chunking and diarized speaker metadata
|
|
9
|
+
|
|
10
|
+
## 4.0.58
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- b54e551: fix(openai): support documented Responses image generation options
|
|
15
|
+
- 17d3436: feat(openai): add support for ultrafast service tier
|
|
16
|
+
|
|
3
17
|
## 4.0.57
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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;
|
|
@@ -15,7 +15,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
|
|
|
15
15
|
store?: boolean | undefined;
|
|
16
16
|
metadata?: Record<string, string> | undefined;
|
|
17
17
|
prediction?: Record<string, any> | undefined;
|
|
18
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
|
|
18
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
|
|
19
19
|
strictJsonSchema?: boolean | undefined;
|
|
20
20
|
textVerbosity?: "low" | "medium" | "high" | undefined;
|
|
21
21
|
promptCacheKey?: string | undefined;
|
|
@@ -1128,6 +1128,7 @@ declare const openaiTools: {
|
|
|
1128
1128
|
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
1129
1129
|
*/
|
|
1130
1130
|
imageGeneration: (args?: {
|
|
1131
|
+
action?: "generate" | "edit" | "auto";
|
|
1131
1132
|
background?: "auto" | "opaque" | "transparent";
|
|
1132
1133
|
inputFidelity?: "low" | "high";
|
|
1133
1134
|
inputImageMask?: {
|
|
@@ -1135,12 +1136,12 @@ declare const openaiTools: {
|
|
|
1135
1136
|
imageUrl?: string;
|
|
1136
1137
|
};
|
|
1137
1138
|
model?: string;
|
|
1138
|
-
moderation?: "auto";
|
|
1139
|
+
moderation?: "auto" | "low";
|
|
1139
1140
|
outputCompression?: number;
|
|
1140
1141
|
outputFormat?: "png" | "jpeg" | "webp";
|
|
1141
1142
|
partialImages?: number;
|
|
1142
1143
|
quality?: "auto" | "low" | "medium" | "high";
|
|
1143
|
-
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024";
|
|
1144
|
+
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | (string & {});
|
|
1144
1145
|
}) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
1145
1146
|
result: string;
|
|
1146
1147
|
}, {}>;
|
|
@@ -1364,7 +1365,7 @@ declare const openaiTools: {
|
|
|
1364
1365
|
}, {}>;
|
|
1365
1366
|
};
|
|
1366
1367
|
|
|
1367
|
-
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 & {});
|
|
1368
1369
|
declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
1369
1370
|
conversation?: string | null | undefined;
|
|
1370
1371
|
include?: ("web_search_call.results" | "file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
|
|
@@ -1385,7 +1386,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1385
1386
|
reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
|
|
1386
1387
|
reasoningSummary?: string | null | undefined;
|
|
1387
1388
|
safetyIdentifier?: string | null | undefined;
|
|
1388
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
|
|
1389
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | null | undefined;
|
|
1389
1390
|
store?: boolean | null | undefined;
|
|
1390
1391
|
passThroughUnsupportedFiles?: boolean | undefined;
|
|
1391
1392
|
strictJsonSchema?: boolean | null | undefined;
|
|
@@ -1420,6 +1421,13 @@ declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema
|
|
|
1420
1421
|
prompt?: string | undefined;
|
|
1421
1422
|
temperature?: number | undefined;
|
|
1422
1423
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
|
1424
|
+
responseFormat?: "json" | "verbose_json" | "diarized_json" | undefined;
|
|
1425
|
+
chunkingStrategy?: "auto" | {
|
|
1426
|
+
type: "server_vad";
|
|
1427
|
+
threshold?: number | undefined;
|
|
1428
|
+
prefixPaddingMs?: number | undefined;
|
|
1429
|
+
silenceDurationMs?: number | undefined;
|
|
1430
|
+
} | undefined;
|
|
1423
1431
|
streaming?: {
|
|
1424
1432
|
delay?: "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
|
|
1425
1433
|
include?: string[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -837,11 +837,12 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
837
837
|
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
838
838
|
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
839
839
|
* - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
|
|
840
|
+
* - 'ultrafast': Access-controlled Ultrafast processing. Only available for gpt-5.6-sol.
|
|
840
841
|
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
841
842
|
*
|
|
842
843
|
* @default 'auto'
|
|
843
844
|
*/
|
|
844
|
-
serviceTier: z3.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
845
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).optional(),
|
|
845
846
|
/**
|
|
846
847
|
* Whether to use strict JSON schema validation.
|
|
847
848
|
*
|
|
@@ -2957,6 +2958,7 @@ import { z as z17 } from "zod/v4";
|
|
|
2957
2958
|
var imageGenerationArgsSchema = lazySchema16(
|
|
2958
2959
|
() => zodSchema16(
|
|
2959
2960
|
z17.object({
|
|
2961
|
+
action: z17.enum(["generate", "edit", "auto"]).optional(),
|
|
2960
2962
|
background: z17.enum(["auto", "opaque", "transparent"]).optional(),
|
|
2961
2963
|
inputFidelity: z17.enum(["low", "high"]).optional(),
|
|
2962
2964
|
inputImageMask: z17.object({
|
|
@@ -2964,12 +2966,15 @@ var imageGenerationArgsSchema = lazySchema16(
|
|
|
2964
2966
|
imageUrl: z17.string().optional()
|
|
2965
2967
|
}).optional(),
|
|
2966
2968
|
model: z17.string().optional(),
|
|
2967
|
-
moderation: z17.enum(["auto"]).optional(),
|
|
2969
|
+
moderation: z17.enum(["auto", "low"]).optional(),
|
|
2968
2970
|
outputCompression: z17.number().int().min(0).max(100).optional(),
|
|
2969
2971
|
outputFormat: z17.enum(["png", "jpeg", "webp"]).optional(),
|
|
2970
2972
|
partialImages: z17.number().int().min(0).max(3).optional(),
|
|
2971
2973
|
quality: z17.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2972
|
-
size: z17.
|
|
2974
|
+
size: z17.union([
|
|
2975
|
+
z17.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
|
|
2976
|
+
z17.string().regex(/^\d+x\d+$/)
|
|
2977
|
+
]).optional()
|
|
2973
2978
|
}).strict()
|
|
2974
2979
|
)
|
|
2975
2980
|
);
|
|
@@ -5945,7 +5950,8 @@ var openaiResponsesReasoningModelIds = [
|
|
|
5945
5950
|
"gpt-5.6",
|
|
5946
5951
|
"gpt-5.6-luna",
|
|
5947
5952
|
"gpt-5.6-sol",
|
|
5948
|
-
"gpt-5.6-terra"
|
|
5953
|
+
"gpt-5.6-terra",
|
|
5954
|
+
"gpt-6-astra"
|
|
5949
5955
|
];
|
|
5950
5956
|
var openaiResponsesModelIds = [
|
|
5951
5957
|
"gpt-4.1",
|
|
@@ -6093,10 +6099,11 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
|
|
|
6093
6099
|
* Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
|
|
6094
6100
|
* Set to 'priority' for faster processing with Enterprise access (available for gpt-4, gpt-5, gpt-5-mini, o3, o4-mini; gpt-5-nano is not supported).
|
|
6095
6101
|
* Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
|
|
6102
|
+
* Set to 'ultrafast' for access-controlled Ultrafast processing (available only for gpt-5.6-sol).
|
|
6096
6103
|
*
|
|
6097
6104
|
* Defaults to 'auto'.
|
|
6098
6105
|
*/
|
|
6099
|
-
serviceTier: z27.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
6106
|
+
serviceTier: z27.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).nullish(),
|
|
6100
6107
|
/**
|
|
6101
6108
|
* Whether to store the generation. Defaults to `true`.
|
|
6102
6109
|
*/
|
|
@@ -6368,6 +6375,7 @@ async function prepareResponsesTools({
|
|
|
6368
6375
|
});
|
|
6369
6376
|
openaiTools2.push({
|
|
6370
6377
|
type: "image_generation",
|
|
6378
|
+
action: args.action,
|
|
6371
6379
|
background: args.background,
|
|
6372
6380
|
input_fidelity: args.inputFidelity,
|
|
6373
6381
|
input_image_mask: args.inputImageMask ? {
|
|
@@ -10090,18 +10098,28 @@ var openaiTranscriptionResponseSchema = lazySchema28(
|
|
|
10090
10098
|
})
|
|
10091
10099
|
).nullish(),
|
|
10092
10100
|
segments: z30.array(
|
|
10093
|
-
z30.
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10101
|
+
z30.union([
|
|
10102
|
+
z30.object({
|
|
10103
|
+
id: z30.number(),
|
|
10104
|
+
seek: z30.number(),
|
|
10105
|
+
start: z30.number(),
|
|
10106
|
+
end: z30.number(),
|
|
10107
|
+
text: z30.string(),
|
|
10108
|
+
tokens: z30.array(z30.number()),
|
|
10109
|
+
temperature: z30.number(),
|
|
10110
|
+
avg_logprob: z30.number(),
|
|
10111
|
+
compression_ratio: z30.number(),
|
|
10112
|
+
no_speech_prob: z30.number()
|
|
10113
|
+
}),
|
|
10114
|
+
z30.object({
|
|
10115
|
+
type: z30.literal("transcript.text.segment"),
|
|
10116
|
+
id: z30.string(),
|
|
10117
|
+
start: z30.number(),
|
|
10118
|
+
end: z30.number(),
|
|
10119
|
+
text: z30.string(),
|
|
10120
|
+
speaker: z30.string()
|
|
10121
|
+
})
|
|
10122
|
+
])
|
|
10105
10123
|
).nullish()
|
|
10106
10124
|
})
|
|
10107
10125
|
)
|
|
@@ -10138,6 +10156,22 @@ var openAITranscriptionModelOptions = lazySchema29(
|
|
|
10138
10156
|
* @default ['segment']
|
|
10139
10157
|
*/
|
|
10140
10158
|
timestampGranularities: z31.array(z31.enum(["word", "segment"])).default(["segment"]).optional(),
|
|
10159
|
+
/**
|
|
10160
|
+
* The format of the transcription response.
|
|
10161
|
+
*/
|
|
10162
|
+
responseFormat: z31.enum(["json", "verbose_json", "diarized_json"]).optional(),
|
|
10163
|
+
/**
|
|
10164
|
+
* Controls how the audio is split into chunks before transcription.
|
|
10165
|
+
*/
|
|
10166
|
+
chunkingStrategy: z31.union([
|
|
10167
|
+
z31.literal("auto"),
|
|
10168
|
+
z31.object({
|
|
10169
|
+
type: z31.literal("server_vad"),
|
|
10170
|
+
threshold: z31.number().min(0).max(1).optional(),
|
|
10171
|
+
prefixPaddingMs: z31.number().int().min(0).optional(),
|
|
10172
|
+
silenceDurationMs: z31.number().int().min(0).optional()
|
|
10173
|
+
})
|
|
10174
|
+
]).optional(),
|
|
10141
10175
|
/**
|
|
10142
10176
|
* Options for streaming transcription models such as `gpt-realtime-whisper`.
|
|
10143
10177
|
*/
|
|
@@ -10241,6 +10275,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10241
10275
|
mediaType,
|
|
10242
10276
|
providerOptions
|
|
10243
10277
|
}) {
|
|
10278
|
+
var _a2, _b;
|
|
10244
10279
|
const warnings = [];
|
|
10245
10280
|
const openAIOptions = await parseProviderOptions10({
|
|
10246
10281
|
provider: "openai",
|
|
@@ -10259,6 +10294,8 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10259
10294
|
if (this.modelId === "whisper-1") {
|
|
10260
10295
|
formData.append("response_format", "verbose_json");
|
|
10261
10296
|
}
|
|
10297
|
+
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
10298
|
+
const chunkingStrategy = (_a2 = openAIOptions == null ? void 0 : openAIOptions.chunkingStrategy) != null ? _a2 : isDiarizationModel ? "auto" : void 0;
|
|
10262
10299
|
if (openAIOptions) {
|
|
10263
10300
|
const isGpt4oTranscribeModel = [
|
|
10264
10301
|
"gpt-4o-transcribe",
|
|
@@ -10271,7 +10308,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10271
10308
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
10272
10309
|
// prefer verbose_json to get segments for models that support it
|
|
10273
10310
|
...this.modelId !== "whisper-1" && {
|
|
10274
|
-
response_format: isGpt4oTranscribeModel ? "json" : "verbose_json"
|
|
10311
|
+
response_format: (_b = openAIOptions.responseFormat) != null ? _b : isDiarizationModel ? "diarized_json" : isGpt4oTranscribeModel ? "json" : "verbose_json"
|
|
10275
10312
|
},
|
|
10276
10313
|
temperature: openAIOptions.temperature,
|
|
10277
10314
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
@@ -10287,6 +10324,25 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10287
10324
|
}
|
|
10288
10325
|
}
|
|
10289
10326
|
}
|
|
10327
|
+
} else if (isDiarizationModel) {
|
|
10328
|
+
formData.append("response_format", "diarized_json");
|
|
10329
|
+
}
|
|
10330
|
+
if (chunkingStrategy != null) {
|
|
10331
|
+
formData.append(
|
|
10332
|
+
"chunking_strategy",
|
|
10333
|
+
typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
10334
|
+
type: chunkingStrategy.type,
|
|
10335
|
+
...chunkingStrategy.threshold != null && {
|
|
10336
|
+
threshold: chunkingStrategy.threshold
|
|
10337
|
+
},
|
|
10338
|
+
...chunkingStrategy.prefixPaddingMs != null && {
|
|
10339
|
+
prefix_padding_ms: chunkingStrategy.prefixPaddingMs
|
|
10340
|
+
},
|
|
10341
|
+
...chunkingStrategy.silenceDurationMs != null && {
|
|
10342
|
+
silence_duration_ms: chunkingStrategy.silenceDurationMs
|
|
10343
|
+
}
|
|
10344
|
+
})
|
|
10345
|
+
);
|
|
10290
10346
|
}
|
|
10291
10347
|
return {
|
|
10292
10348
|
formData,
|
|
@@ -10294,7 +10350,7 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10294
10350
|
};
|
|
10295
10351
|
}
|
|
10296
10352
|
async doGenerate(options) {
|
|
10297
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10353
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
10298
10354
|
if (isRealtimeTranscriptionModelId(this.modelId)) {
|
|
10299
10355
|
throw new UnsupportedFunctionalityError6({
|
|
10300
10356
|
functionality: `non-streaming transcription with ${this.modelId}`
|
|
@@ -10321,25 +10377,42 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
|
|
|
10321
10377
|
fetch: this.config.fetch
|
|
10322
10378
|
});
|
|
10323
10379
|
const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
|
|
10380
|
+
const diarizedSegments = (_f = response.segments) == null ? void 0 : _f.flatMap(
|
|
10381
|
+
(segment) => "speaker" in segment ? [
|
|
10382
|
+
{
|
|
10383
|
+
text: segment.text,
|
|
10384
|
+
startSecond: segment.start,
|
|
10385
|
+
endSecond: segment.end,
|
|
10386
|
+
speaker: segment.speaker
|
|
10387
|
+
}
|
|
10388
|
+
] : []
|
|
10389
|
+
);
|
|
10324
10390
|
return {
|
|
10325
10391
|
text: response.text,
|
|
10326
|
-
segments: (
|
|
10392
|
+
segments: (_j = (_i = (_g = response.segments) == null ? void 0 : _g.map((segment) => ({
|
|
10327
10393
|
text: segment.text,
|
|
10328
10394
|
startSecond: segment.start,
|
|
10329
10395
|
endSecond: segment.end
|
|
10330
|
-
}))) != null ?
|
|
10396
|
+
}))) != null ? _i : (_h = response.words) == null ? void 0 : _h.map((word) => ({
|
|
10331
10397
|
text: word.word,
|
|
10332
10398
|
startSecond: word.start,
|
|
10333
10399
|
endSecond: word.end
|
|
10334
|
-
}))) != null ?
|
|
10400
|
+
}))) != null ? _j : [],
|
|
10335
10401
|
language,
|
|
10336
|
-
durationInSeconds: (
|
|
10402
|
+
durationInSeconds: (_k = response.duration) != null ? _k : void 0,
|
|
10337
10403
|
warnings,
|
|
10338
10404
|
response: {
|
|
10339
10405
|
timestamp: currentDate,
|
|
10340
10406
|
modelId: this.modelId,
|
|
10341
10407
|
headers: responseHeaders,
|
|
10342
10408
|
body: rawResponse
|
|
10409
|
+
},
|
|
10410
|
+
...diarizedSegments != null && diarizedSegments.length > 0 && {
|
|
10411
|
+
providerMetadata: {
|
|
10412
|
+
openai: {
|
|
10413
|
+
segments: diarizedSegments
|
|
10414
|
+
}
|
|
10415
|
+
}
|
|
10343
10416
|
}
|
|
10344
10417
|
};
|
|
10345
10418
|
}
|
|
@@ -10987,7 +11060,7 @@ var OpenAISkills = class {
|
|
|
10987
11060
|
};
|
|
10988
11061
|
|
|
10989
11062
|
// src/version.ts
|
|
10990
|
-
var VERSION = true ? "4.0.
|
|
11063
|
+
var VERSION = true ? "4.0.59" : "0.0.0-test";
|
|
10991
11064
|
|
|
10992
11065
|
// src/openai-provider.ts
|
|
10993
11066
|
function createOpenAI(options = {}) {
|