@ai-sdk/openai 4.0.103 → 4.0.104
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 +20 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -46
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +14 -4
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +67 -42
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +10 -6
- package/package.json +2 -2
- package/src/chat/openai-chat-language-model-options.ts +1 -0
- package/src/normalize-openai-json-schema.ts +2 -1
- package/src/openai-batch.ts +2 -4
- package/src/openai-language-model-capabilities.ts +8 -5
- package/src/responses/openai-responses-language-model-options.ts +2 -0
- package/src/responses/openai-responses-language-model.ts +17 -8
- package/src/transcription/openai-transcription-model-options.ts +5 -6
- package/src/transcription/openai-transcription-model.ts +89 -48
package/dist/internal/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EmbeddingModelV4, Experimental_TranscriptionModelV4StreamOptions, Image
|
|
|
2
2
|
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, FetchFunction, FlexibleSchema, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/chat/openai-chat-language-model-options.d.ts
|
|
5
|
-
export 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' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
|
|
5
|
+
export 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' | 'gpt-6.1-sol' | 'gpt-6.1-terra' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
|
|
6
6
|
export declare const openaiLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
7
7
|
logitBias?: Record<number, number> | undefined;
|
|
8
8
|
logprobs?: number | boolean | undefined;
|
|
@@ -243,7 +243,7 @@ export declare class OpenAIImageModel implements ImageModelV4 {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/transcription/openai-transcription-model-options.d.ts
|
|
246
|
-
export type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-03-20' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-realtime-whisper' | (string & {});
|
|
246
|
+
export type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-03-20' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-live-transcribe' | 'gpt-realtime-whisper' | 'gpt-transcribe' | (string & {});
|
|
247
247
|
export declare const openAITranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
248
248
|
include?: string[] | undefined;
|
|
249
249
|
language?: string | undefined;
|
|
@@ -332,7 +332,7 @@ export declare class OpenAISpeechModel implements SpeechModelV4 {
|
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
334
|
//#region src/responses/openai-responses-language-model-options.d.ts
|
|
335
|
-
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-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | '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 & {});
|
|
335
|
+
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-6.1-sol' | 'gpt-6.1-terra' | 'gpt-6-luna' | 'gpt-6-sol' | '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 & {});
|
|
336
336
|
declare const openaiResponsesToolResultOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
337
337
|
additionalTools?: {
|
|
338
338
|
type: "function";
|
|
@@ -2004,7 +2004,17 @@ export declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
2004
2004
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
2005
2005
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
2006
2006
|
}
|
|
2007
|
-
export declare function
|
|
2007
|
+
export declare function mapWebSearchResult({ action, status }: {
|
|
2008
|
+
action?: OpenAIResponsesWebSearchAction | null;
|
|
2009
|
+
status: string;
|
|
2010
|
+
}): {
|
|
2011
|
+
isError: true;
|
|
2012
|
+
result: {
|
|
2013
|
+
status: string;
|
|
2014
|
+
};
|
|
2015
|
+
} | {
|
|
2016
|
+
result: InferSchema<typeof webSearchOutputSchema>;
|
|
2017
|
+
};
|
|
2008
2018
|
//#endregion
|
|
2009
2019
|
//#region src/responses/openai-responses-provider-metadata.d.ts
|
|
2010
2020
|
type OpenaiResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/tool-search.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/tool-search.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;qBAuEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;YAwJ/B,iCAAiC,mBACpC;;;KCpLJ;EACH;;EAEA;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,mCAAmC;WACrC;WAEA,SAAS;WAET;;;mBAIQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAIW,YAAA,SAAS,mBAAmB,QAAQ;MAK5C;UAIU;EA6SR,WACJ,SAAS,6BACR,QAAQ;EA+FL,SACJ,SAAS,6BACR,QAAQ;;;;YCveD;qBAKC,uEAAoC;;cAApC;;;;;YAiDD,uCAAuC,mBAC1C;;;KCpBJ;EACH;;EAEA;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,yCAAyC;WAC3C;WAEA,SAAS;mBAED;cAEL;UAIJ,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAKC,YAAA,SAAS,yBACT,QAAQ;MAMN;WAIK,eAAe,eAAe;UAIzB;EA2FR,WACJ,SAAS,6BACR,QAAQ;EAgDL,SACJ,SAAS,6BACR,QAAQ;;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IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;;KAKtB;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;KAGC;EACV;EACA;EACA,iBAEI;IAEM;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;IAG1B;IACA;IACA,0BAA0B;;EAGpC,SAAS;;KAGC;EACN;;EACA;EAAiB;;KAEX;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;;KAOU,8BAA8B,YACxC,kBAAkB;KAGR;EACV;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF,6BAA6B;IAC3B;IACA;IACA;;;KAIQ,gCAAgC,YAC1C,kBAAkB;KAGR;EACV;EACA;EACA;;;;;KAMU;EACV;EACA;EACA;EACA;EACA;IACE;IACA;IACA;;;KAIQ;EACV;EACA;EACA;EACA;EACA;EACA,QAAQ;IACN;IACA;IACA;MAAW;;MAAsB;MAAc;;;;KAIvC;EACV;EACA;EACA;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;;IAGA;IACA;IACA;;;KAII;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA,OAAO,MAAM;;KAGH;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;IACE;;;KAIQ;EACV;;;;;KAMU;;;;EAIV;;;;EAKA;;;;EAKA;;;;;KAMU;;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;;EAgBH,OAAA,MAAM;;;;qBC3DJ,6DAA0B;;;;;;;;;;qBAiB1B,8DAA2B,WAAA;qBA4B3B,mDAAgB;;;;;EAUrB;;;;IAIE;;;;IAKA;;;;;IAMA;;;;IAKA;;;;;IAMA;;;;IAKA;;;;IAKA;;;;;;;;;EAUc;;;;EAKL;;;;IAIb;;;;IAIA;;;;IAIA;;;;IAIA;;;;IAIA"}
|
package/dist/internal/index.js
CHANGED
|
@@ -21,17 +21,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
21
21
|
const isGptChatModel = gptVersion?.minor == null && (gptVersion?.variant?.startsWith("chat") ?? false);
|
|
22
22
|
const isGptNanoModel = gptVersion?.variant?.startsWith("nano") ?? false;
|
|
23
23
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
24
|
-
const
|
|
24
|
+
const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
|
|
25
25
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
26
26
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
27
27
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
28
|
-
const supportsNonReasoningParameters =
|
|
28
|
+
const supportsNonReasoningParameters = isGpt6OrLaterModelWithNoneEffort || !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1);
|
|
29
29
|
return {
|
|
30
30
|
supportsFlexProcessing,
|
|
31
31
|
supportsPriorityProcessing,
|
|
32
32
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
33
33
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
34
|
-
supportedReasoningEfforts:
|
|
34
|
+
supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? [
|
|
35
35
|
"none",
|
|
36
36
|
"low",
|
|
37
37
|
"medium",
|
|
@@ -757,7 +757,7 @@ function normalizeOpenAIJsonSchema(schema) {
|
|
|
757
757
|
function normalizeSchema(schema, isRoot = false) {
|
|
758
758
|
const propertyNames = schema.propertyNames;
|
|
759
759
|
if (propertyNames != null) {
|
|
760
|
-
if (typeof propertyNames === "boolean" || propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
760
|
+
if (typeof propertyNames === "boolean" || propertyNames.type != null && propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
761
761
|
removedPropertyNames = true;
|
|
762
762
|
}
|
|
763
763
|
const normalizedSchema = { ...schema };
|
|
@@ -2141,9 +2141,9 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2141
2141
|
temperature: z.number().min(0).max(1).default(0).optional(),
|
|
2142
2142
|
/**
|
|
2143
2143
|
* The timestamp granularities to populate for this transcription.
|
|
2144
|
-
*
|
|
2144
|
+
* Defaults to ['segment'] when the response format is verbose_json.
|
|
2145
2145
|
*/
|
|
2146
|
-
timestampGranularities: z.array(z.enum(["word", "segment"])).
|
|
2146
|
+
timestampGranularities: z.array(z.enum(["word", "segment"])).optional(),
|
|
2147
2147
|
/**
|
|
2148
2148
|
* The format of the transcription response.
|
|
2149
2149
|
*/
|
|
@@ -2162,7 +2162,7 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2162
2162
|
silenceDurationMs: z.number().int().min(0).optional()
|
|
2163
2163
|
})]).optional(),
|
|
2164
2164
|
/**
|
|
2165
|
-
* Options for streaming transcription models such as `gpt-
|
|
2165
|
+
* Options for streaming transcription models such as `gpt-live-transcribe`.
|
|
2166
2166
|
*/
|
|
2167
2167
|
streaming: z.object({
|
|
2168
2168
|
/**
|
|
@@ -2184,12 +2184,32 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/transcription/openai-transcription-model.ts
|
|
2186
2186
|
/**
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
|
|
2187
|
+
* Whether `modelId` is `base` or one of its dated snapshots
|
|
2188
|
+
* (e.g. `gpt-realtime-whisper-2026-01-01`).
|
|
2189
|
+
*/
|
|
2190
|
+
function isModelOrSnapshot(modelId, base) {
|
|
2191
|
+
return modelId === base || modelId.startsWith(`${base}-`);
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Model IDs that stream over the realtime transcription WebSocket and do not
|
|
2195
|
+
* support the REST transcription endpoint.
|
|
2190
2196
|
*/
|
|
2191
2197
|
function isRealtimeTranscriptionModelId(modelId) {
|
|
2192
|
-
return modelId
|
|
2198
|
+
return isModelOrSnapshot(modelId, "gpt-realtime-whisper") || isModelOrSnapshot(modelId, "gpt-live-transcribe");
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Model IDs that support streaming transcription. `gpt-transcribe` also
|
|
2202
|
+
* supports the REST transcription endpoint.
|
|
2203
|
+
*/
|
|
2204
|
+
function supportsStreamingTranscription(modelId) {
|
|
2205
|
+
return isRealtimeTranscriptionModelId(modelId) || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Models whose realtime transcription session takes a `languages` list
|
|
2209
|
+
* instead of the singular `language` field.
|
|
2210
|
+
*/
|
|
2211
|
+
function usesLanguagesList(modelId) {
|
|
2212
|
+
return isModelOrSnapshot(modelId, "gpt-live-transcribe") || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2193
2213
|
}
|
|
2194
2214
|
const languageMap = {
|
|
2195
2215
|
afrikaans: "af",
|
|
@@ -2283,24 +2303,22 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2283
2303
|
formData.append("model", this.modelId);
|
|
2284
2304
|
const fileExtension = mediaTypeToExtension(mediaType);
|
|
2285
2305
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${fileExtension}`);
|
|
2286
|
-
if (this.modelId === "whisper-1") formData.append("response_format", "verbose_json");
|
|
2287
2306
|
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
2307
|
+
const responseFormat = openAIOptions?.responseFormat ?? (isDiarizationModel ? "diarized_json" : this.modelId === "whisper-1" ? "verbose_json" : void 0);
|
|
2308
|
+
const timestampGranularities = openAIOptions?.timestampGranularities ?? (responseFormat === "verbose_json" ? ["segment"] : void 0);
|
|
2288
2309
|
const chunkingStrategy = openAIOptions?.chunkingStrategy ?? (isDiarizationModel ? "auto" : void 0);
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
};
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
else formData.append(key, String(value));
|
|
2302
|
-
}
|
|
2303
|
-
} else if (isDiarizationModel) formData.append("response_format", "diarized_json");
|
|
2310
|
+
const transcriptionModelOptions = {
|
|
2311
|
+
response_format: responseFormat,
|
|
2312
|
+
include: openAIOptions?.include,
|
|
2313
|
+
language: openAIOptions?.language,
|
|
2314
|
+
prompt: openAIOptions?.prompt,
|
|
2315
|
+
temperature: openAIOptions?.temperature,
|
|
2316
|
+
timestamp_granularities: timestampGranularities
|
|
2317
|
+
};
|
|
2318
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) if (value != null) {
|
|
2319
|
+
if (Array.isArray(value)) for (const item of value) formData.append(`${key}[]`, String(item));
|
|
2320
|
+
else formData.append(key, String(value));
|
|
2321
|
+
}
|
|
2304
2322
|
if (chunkingStrategy != null) formData.append("chunking_strategy", typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
2305
2323
|
type: chunkingStrategy.type,
|
|
2306
2324
|
...chunkingStrategy.threshold != null && { threshold: chunkingStrategy.threshold },
|
|
@@ -2347,7 +2365,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2347
2365
|
endSecond: word.end
|
|
2348
2366
|
})) ?? [],
|
|
2349
2367
|
language,
|
|
2350
|
-
durationInSeconds: response.duration ?? void 0,
|
|
2368
|
+
durationInSeconds: response.duration ?? (response.usage?.type === "duration" && typeof response.usage.seconds === "number" ? response.usage.seconds : void 0),
|
|
2351
2369
|
warnings,
|
|
2352
2370
|
...response.usage != null && { usage: response.usage },
|
|
2353
2371
|
response: {
|
|
@@ -2363,7 +2381,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2363
2381
|
};
|
|
2364
2382
|
}
|
|
2365
2383
|
async doStream(options) {
|
|
2366
|
-
if (!
|
|
2384
|
+
if (!supportsStreamingTranscription(this.modelId)) throw new UnsupportedFunctionalityError({ functionality: `streaming transcription with ${this.modelId}` });
|
|
2367
2385
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
2368
2386
|
const openAIOptions = await parseProviderOptions({
|
|
2369
2387
|
provider: "openai",
|
|
@@ -2382,11 +2400,18 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2382
2400
|
feature: `providerOptions.openai.${option}`,
|
|
2383
2401
|
details: `OpenAI streaming transcription does not support ${option}.`
|
|
2384
2402
|
});
|
|
2403
|
+
const supportsDelay = !isModelOrSnapshot(this.modelId, "gpt-transcribe");
|
|
2404
|
+
if (!supportsDelay && openAIOptions?.streaming?.delay != null) warnings.push({
|
|
2405
|
+
type: "unsupported",
|
|
2406
|
+
feature: "providerOptions.openai.streaming.delay",
|
|
2407
|
+
details: `OpenAI streaming transcription with ${this.modelId} does not support delay.`
|
|
2408
|
+
});
|
|
2385
2409
|
const headers = combineHeaders(this.config.headers?.(), options.headers);
|
|
2386
2410
|
const sessionUpdate = buildOpenAIRealtimeTranscriptionSession({
|
|
2387
2411
|
modelId: this.modelId,
|
|
2388
2412
|
inputAudioFormat: options.inputAudioFormat,
|
|
2389
|
-
providerOptions: openAIOptions
|
|
2413
|
+
providerOptions: openAIOptions,
|
|
2414
|
+
supportsDelay
|
|
2390
2415
|
});
|
|
2391
2416
|
return {
|
|
2392
2417
|
request: { body: sessionUpdate },
|
|
@@ -2521,7 +2546,7 @@ function createOpenAIRealtimeTranscriptionStream({ webSocket, url, headers, sess
|
|
|
2521
2546
|
}
|
|
2522
2547
|
});
|
|
2523
2548
|
}
|
|
2524
|
-
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions }) {
|
|
2549
|
+
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions, supportsDelay }) {
|
|
2525
2550
|
return {
|
|
2526
2551
|
type: "session.update",
|
|
2527
2552
|
session: {
|
|
@@ -2533,8 +2558,8 @@ function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, pr
|
|
|
2533
2558
|
},
|
|
2534
2559
|
transcription: {
|
|
2535
2560
|
model: modelId,
|
|
2536
|
-
...providerOptions?.language != null ? { language: providerOptions.language } : {},
|
|
2537
|
-
...providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2561
|
+
...providerOptions?.language != null ? usesLanguagesList(modelId) ? { languages: [providerOptions.language] } : { language: providerOptions.language } : {},
|
|
2562
|
+
...supportsDelay && providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2538
2563
|
},
|
|
2539
2564
|
turn_detection: null
|
|
2540
2565
|
} },
|
|
@@ -6821,10 +6846,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6821
6846
|
type: "tool-result",
|
|
6822
6847
|
toolCallId: part.id,
|
|
6823
6848
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
6824
|
-
...part
|
|
6825
|
-
isError: true,
|
|
6826
|
-
result: { status: part.status }
|
|
6827
|
-
} : { result: mapWebSearchOutput(part.action) }
|
|
6849
|
+
...mapWebSearchResult(part)
|
|
6828
6850
|
});
|
|
6829
6851
|
if (part.action?.type === "search") {
|
|
6830
6852
|
for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
|
|
@@ -7435,10 +7457,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7435
7457
|
type: "tool-result",
|
|
7436
7458
|
toolCallId: value.item.id,
|
|
7437
7459
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
7438
|
-
...value.item
|
|
7439
|
-
isError: true,
|
|
7440
|
-
result: { status: value.item.status }
|
|
7441
|
-
} : { result: mapWebSearchOutput(value.item.action) }
|
|
7460
|
+
...mapWebSearchResult(value.item)
|
|
7442
7461
|
});
|
|
7443
7462
|
if (value.item.action?.type === "search") {
|
|
7444
7463
|
for (const source of value.item.action.sources ?? []) if (source.type === "url") {
|
|
@@ -8054,6 +8073,12 @@ function isResponseInProgressChunk(chunk) {
|
|
|
8054
8073
|
function isResponseOutputChunk(chunk) {
|
|
8055
8074
|
return !(chunk.type === "response.created" || chunk.type === "response.in_progress" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
|
|
8056
8075
|
}
|
|
8076
|
+
function mapWebSearchResult({ action, status }) {
|
|
8077
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : {
|
|
8078
|
+
isError: true,
|
|
8079
|
+
result: { status }
|
|
8080
|
+
};
|
|
8081
|
+
}
|
|
8057
8082
|
function mapWebSearchOutput(action) {
|
|
8058
8083
|
if (action == null) return {};
|
|
8059
8084
|
switch (action.type) {
|
|
@@ -8080,6 +8105,6 @@ function escapeJSONDelta(delta) {
|
|
|
8080
8105
|
return JSON.stringify(delta).slice(1, -1);
|
|
8081
8106
|
}
|
|
8082
8107
|
//#endregion
|
|
8083
|
-
export { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema,
|
|
8108
|
+
export { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchResult, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiResponsesSupportedUrls, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, toolSearch, toolSearchArgsSchema, toolSearchInputSchema, toolSearchOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|
|
8084
8109
|
|
|
8085
8110
|
//# sourceMappingURL=index.js.map
|