@ai-sdk/openai 4.0.103 → 4.0.105
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 +39 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +181 -75
- 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 +148 -66
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +20 -10
- package/package.json +2 -2
- package/src/chat/openai-chat-language-model-options.ts +1 -0
- package/src/chat/openai-chat-language-model.ts +30 -15
- package/src/normalize-openai-json-schema.ts +2 -1
- package/src/openai-batch.ts +2 -4
- package/src/openai-decision-model-options.ts +1 -0
- package/src/openai-decision-model.ts +46 -5
- package/src/openai-language-model-capabilities.ts +105 -7
- package/src/responses/openai-responses-language-model-options.ts +2 -0
- package/src/responses/openai-responses-language-model.ts +34 -32
- 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;;;KCjLJ;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;EAyTR,WACJ,SAAS,6BACR,QAAQ;EA+FL,SACJ,SAAS,6BACR,QAAQ;;;;YCtfD;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,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,kBAEI;IACE;IACA;IACA,0BAA0B;;;KAItB;EACV;EACA;EACA,SAAS;IAEH;IACA;IACA,0BAA0B;;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;;K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AMD,aAAA;;qBAQJ,aACX,OAAM,kBAAkB,+DAA8B;;;;;EApDxC;;;;;EAMF;;;;;;;;;;;;;;;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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APICallError, InvalidPromptError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError, isJSONObject } from "@ai-sdk/provider";
|
|
2
|
-
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, downloadBlob, experimental_toolCaller, generateId, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, mediaTypeToExtension, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateTypes, waitForWebSocketBufferDrain, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, downloadBlob, experimental_toolCaller, generateId, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, mapReasoningToProviderEffort, mediaTypeToExtension, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateTypes, waitForWebSocketBufferDrain, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/openai-error.ts
|
|
5
5
|
const openaiErrorDataSchema = () => z.object({ error: z.object({
|
|
@@ -15,23 +15,34 @@ const openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
15
15
|
});
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/openai-language-model-capabilities.ts
|
|
18
|
+
const ALL_OPENAI_REASONING_EFFORTS = [
|
|
19
|
+
"none",
|
|
20
|
+
"minimal",
|
|
21
|
+
"low",
|
|
22
|
+
"medium",
|
|
23
|
+
"high",
|
|
24
|
+
"xhigh",
|
|
25
|
+
"max"
|
|
26
|
+
];
|
|
18
27
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
19
28
|
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
20
29
|
const gptVersion = getGptVersion(modelId);
|
|
21
30
|
const isGptChatModel = gptVersion?.minor == null && (gptVersion?.variant?.startsWith("chat") ?? false);
|
|
22
31
|
const isGptNanoModel = gptVersion?.variant?.startsWith("nano") ?? false;
|
|
23
32
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
24
|
-
const
|
|
33
|
+
const isStandardGpt5Model = gptVersion?.major === 5 && (gptVersion.variant == null || /^(?:(?:mini|nano|sol|luna|terra)(?:-\d{4}-\d{2}-\d{2})?|\d{4}-\d{2}-\d{2})$/.test(gptVersion.variant));
|
|
34
|
+
const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
|
|
25
35
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
26
36
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
27
37
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
28
|
-
const supportsNonReasoningParameters =
|
|
38
|
+
const supportsNonReasoningParameters = isGpt6OrLaterModelWithNoneEffort || !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1);
|
|
39
|
+
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
29
40
|
return {
|
|
30
41
|
supportsFlexProcessing,
|
|
31
42
|
supportsPriorityProcessing,
|
|
32
43
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
33
44
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
34
|
-
supportedReasoningEfforts:
|
|
45
|
+
supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? [
|
|
35
46
|
"none",
|
|
36
47
|
"low",
|
|
37
48
|
"medium",
|
|
@@ -44,12 +55,42 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
44
55
|
"high",
|
|
45
56
|
"xhigh",
|
|
46
57
|
"max"
|
|
47
|
-
] : void 0,
|
|
58
|
+
] : isStandardGpt5Model ? getGpt5ReasoningEfforts(gptVersion.minor ?? 0) : void 0,
|
|
59
|
+
supportsChatFunctionToolsWithReasoning: !(gptVersion?.major === 5 && (gptVersion.minor ?? 0) >= 6),
|
|
48
60
|
isReasoningModel,
|
|
49
|
-
systemMessageMode
|
|
61
|
+
systemMessageMode,
|
|
50
62
|
supportsNonReasoningParameters
|
|
51
63
|
};
|
|
52
64
|
}
|
|
65
|
+
function getGpt5ReasoningEfforts(minor) {
|
|
66
|
+
if (minor === 0) return [
|
|
67
|
+
"minimal",
|
|
68
|
+
"low",
|
|
69
|
+
"medium",
|
|
70
|
+
"high"
|
|
71
|
+
];
|
|
72
|
+
if (minor === 1) return [
|
|
73
|
+
"none",
|
|
74
|
+
"low",
|
|
75
|
+
"medium",
|
|
76
|
+
"high"
|
|
77
|
+
];
|
|
78
|
+
if (minor < 6) return [
|
|
79
|
+
"none",
|
|
80
|
+
"low",
|
|
81
|
+
"medium",
|
|
82
|
+
"high",
|
|
83
|
+
"xhigh"
|
|
84
|
+
];
|
|
85
|
+
return [
|
|
86
|
+
"none",
|
|
87
|
+
"low",
|
|
88
|
+
"medium",
|
|
89
|
+
"high",
|
|
90
|
+
"xhigh",
|
|
91
|
+
"max"
|
|
92
|
+
];
|
|
93
|
+
}
|
|
53
94
|
function getOSeriesVersion(modelId) {
|
|
54
95
|
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
55
96
|
return match == null ? void 0 : Number(match[1]);
|
|
@@ -63,6 +104,21 @@ function getGptVersion(modelId) {
|
|
|
63
104
|
variant: match[3]
|
|
64
105
|
};
|
|
65
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Resolves the reasoning effort to send to OpenAI.
|
|
109
|
+
*
|
|
110
|
+
* A reasoning effort from provider options is sent unchanged. Otherwise the
|
|
111
|
+
* top-level reasoning value is mapped to the closest effort that the model
|
|
112
|
+
* family supports, or sent directly when the supported efforts are not known.
|
|
113
|
+
*/
|
|
114
|
+
function resolveOpenAIReasoningEffort({ providerReasoningEffort, reasoning, supportedReasoningEfforts, warnings }) {
|
|
115
|
+
return mapReasoningToProviderEffort({
|
|
116
|
+
reasoning,
|
|
117
|
+
providerOptionsEffort: providerReasoningEffort,
|
|
118
|
+
effortMap: Object.fromEntries((supportedReasoningEfforts ?? ALL_OPENAI_REASONING_EFFORTS).map((effort) => [effort, effort])),
|
|
119
|
+
warnings
|
|
120
|
+
});
|
|
121
|
+
}
|
|
66
122
|
//#endregion
|
|
67
123
|
//#region src/openai-stream-error.ts
|
|
68
124
|
/**
|
|
@@ -757,7 +813,7 @@ function normalizeOpenAIJsonSchema(schema) {
|
|
|
757
813
|
function normalizeSchema(schema, isRoot = false) {
|
|
758
814
|
const propertyNames = schema.propertyNames;
|
|
759
815
|
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" });
|
|
816
|
+
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
817
|
removedPropertyNames = true;
|
|
762
818
|
}
|
|
763
819
|
const normalizedSchema = { ...schema };
|
|
@@ -935,15 +991,18 @@ var OpenAIChatLanguageModel = class OpenAIChatLanguageModel {
|
|
|
935
991
|
schema: openaiLanguageModelChatOptions
|
|
936
992
|
}) ?? {};
|
|
937
993
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
938
|
-
|
|
939
|
-
if (
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
994
|
+
const requiresNoReasoningEffort = !modelCapabilities.supportsChatFunctionToolsWithReasoning && openaiOptions.reasoningEffort == null && (tools?.some((tool) => tool.type === "function") ?? false);
|
|
995
|
+
if (requiresNoReasoningEffort && isCustomReasoning(reasoning) && reasoning !== "none") warnings.push({
|
|
996
|
+
type: "compatibility",
|
|
997
|
+
feature: "reasoning",
|
|
998
|
+
details: `${this.modelId} does not support function tools with reasoning in the Chat Completions API. reasoning effort set to "none". Use the Responses API to combine reasoning with function tools.`
|
|
999
|
+
});
|
|
1000
|
+
const resolvedReasoningEffort = requiresNoReasoningEffort ? "none" : resolveOpenAIReasoningEffort({
|
|
1001
|
+
providerReasoningEffort: openaiOptions.reasoningEffort,
|
|
1002
|
+
reasoning,
|
|
1003
|
+
supportedReasoningEfforts: modelCapabilities.supportedReasoningEfforts?.filter((effort) => effort !== "max"),
|
|
1004
|
+
warnings
|
|
1005
|
+
});
|
|
947
1006
|
const isReasoningModel = openaiOptions.forceReasoning ?? modelCapabilities.isReasoningModel;
|
|
948
1007
|
if (topK != null) warnings.push({
|
|
949
1008
|
type: "unsupported",
|
|
@@ -998,7 +1057,7 @@ var OpenAIChatLanguageModel = class OpenAIChatLanguageModel {
|
|
|
998
1057
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
999
1058
|
messages
|
|
1000
1059
|
};
|
|
1001
|
-
if (modelCapabilities.
|
|
1060
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
1002
1061
|
baseArgs.prompt_cache_retention = void 0;
|
|
1003
1062
|
warnings.push({
|
|
1004
1063
|
type: "unsupported",
|
|
@@ -2141,9 +2200,9 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2141
2200
|
temperature: z.number().min(0).max(1).default(0).optional(),
|
|
2142
2201
|
/**
|
|
2143
2202
|
* The timestamp granularities to populate for this transcription.
|
|
2144
|
-
*
|
|
2203
|
+
* Defaults to ['segment'] when the response format is verbose_json.
|
|
2145
2204
|
*/
|
|
2146
|
-
timestampGranularities: z.array(z.enum(["word", "segment"])).
|
|
2205
|
+
timestampGranularities: z.array(z.enum(["word", "segment"])).optional(),
|
|
2147
2206
|
/**
|
|
2148
2207
|
* The format of the transcription response.
|
|
2149
2208
|
*/
|
|
@@ -2162,7 +2221,7 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2162
2221
|
silenceDurationMs: z.number().int().min(0).optional()
|
|
2163
2222
|
})]).optional(),
|
|
2164
2223
|
/**
|
|
2165
|
-
* Options for streaming transcription models such as `gpt-
|
|
2224
|
+
* Options for streaming transcription models such as `gpt-live-transcribe`.
|
|
2166
2225
|
*/
|
|
2167
2226
|
streaming: z.object({
|
|
2168
2227
|
/**
|
|
@@ -2184,12 +2243,32 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
2184
2243
|
//#endregion
|
|
2185
2244
|
//#region src/transcription/openai-transcription-model.ts
|
|
2186
2245
|
/**
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2189
|
-
|
|
2246
|
+
* Whether `modelId` is `base` or one of its dated snapshots
|
|
2247
|
+
* (e.g. `gpt-realtime-whisper-2026-01-01`).
|
|
2248
|
+
*/
|
|
2249
|
+
function isModelOrSnapshot(modelId, base) {
|
|
2250
|
+
return modelId === base || modelId.startsWith(`${base}-`);
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Model IDs that stream over the realtime transcription WebSocket and do not
|
|
2254
|
+
* support the REST transcription endpoint.
|
|
2190
2255
|
*/
|
|
2191
2256
|
function isRealtimeTranscriptionModelId(modelId) {
|
|
2192
|
-
return modelId
|
|
2257
|
+
return isModelOrSnapshot(modelId, "gpt-realtime-whisper") || isModelOrSnapshot(modelId, "gpt-live-transcribe");
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Model IDs that support streaming transcription. `gpt-transcribe` also
|
|
2261
|
+
* supports the REST transcription endpoint.
|
|
2262
|
+
*/
|
|
2263
|
+
function supportsStreamingTranscription(modelId) {
|
|
2264
|
+
return isRealtimeTranscriptionModelId(modelId) || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2265
|
+
}
|
|
2266
|
+
/**
|
|
2267
|
+
* Models whose realtime transcription session takes a `languages` list
|
|
2268
|
+
* instead of the singular `language` field.
|
|
2269
|
+
*/
|
|
2270
|
+
function usesLanguagesList(modelId) {
|
|
2271
|
+
return isModelOrSnapshot(modelId, "gpt-live-transcribe") || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
2193
2272
|
}
|
|
2194
2273
|
const languageMap = {
|
|
2195
2274
|
afrikaans: "af",
|
|
@@ -2283,24 +2362,22 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2283
2362
|
formData.append("model", this.modelId);
|
|
2284
2363
|
const fileExtension = mediaTypeToExtension(mediaType);
|
|
2285
2364
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${fileExtension}`);
|
|
2286
|
-
if (this.modelId === "whisper-1") formData.append("response_format", "verbose_json");
|
|
2287
2365
|
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
2366
|
+
const responseFormat = openAIOptions?.responseFormat ?? (isDiarizationModel ? "diarized_json" : this.modelId === "whisper-1" ? "verbose_json" : void 0);
|
|
2367
|
+
const timestampGranularities = openAIOptions?.timestampGranularities ?? (responseFormat === "verbose_json" ? ["segment"] : void 0);
|
|
2288
2368
|
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");
|
|
2369
|
+
const transcriptionModelOptions = {
|
|
2370
|
+
response_format: responseFormat,
|
|
2371
|
+
include: openAIOptions?.include,
|
|
2372
|
+
language: openAIOptions?.language,
|
|
2373
|
+
prompt: openAIOptions?.prompt,
|
|
2374
|
+
temperature: openAIOptions?.temperature,
|
|
2375
|
+
timestamp_granularities: timestampGranularities
|
|
2376
|
+
};
|
|
2377
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) if (value != null) {
|
|
2378
|
+
if (Array.isArray(value)) for (const item of value) formData.append(`${key}[]`, String(item));
|
|
2379
|
+
else formData.append(key, String(value));
|
|
2380
|
+
}
|
|
2304
2381
|
if (chunkingStrategy != null) formData.append("chunking_strategy", typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
2305
2382
|
type: chunkingStrategy.type,
|
|
2306
2383
|
...chunkingStrategy.threshold != null && { threshold: chunkingStrategy.threshold },
|
|
@@ -2347,7 +2424,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2347
2424
|
endSecond: word.end
|
|
2348
2425
|
})) ?? [],
|
|
2349
2426
|
language,
|
|
2350
|
-
durationInSeconds: response.duration ?? void 0,
|
|
2427
|
+
durationInSeconds: response.duration ?? (response.usage?.type === "duration" && typeof response.usage.seconds === "number" ? response.usage.seconds : void 0),
|
|
2351
2428
|
warnings,
|
|
2352
2429
|
...response.usage != null && { usage: response.usage },
|
|
2353
2430
|
response: {
|
|
@@ -2363,7 +2440,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2363
2440
|
};
|
|
2364
2441
|
}
|
|
2365
2442
|
async doStream(options) {
|
|
2366
|
-
if (!
|
|
2443
|
+
if (!supportsStreamingTranscription(this.modelId)) throw new UnsupportedFunctionalityError({ functionality: `streaming transcription with ${this.modelId}` });
|
|
2367
2444
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
2368
2445
|
const openAIOptions = await parseProviderOptions({
|
|
2369
2446
|
provider: "openai",
|
|
@@ -2382,11 +2459,18 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
2382
2459
|
feature: `providerOptions.openai.${option}`,
|
|
2383
2460
|
details: `OpenAI streaming transcription does not support ${option}.`
|
|
2384
2461
|
});
|
|
2462
|
+
const supportsDelay = !isModelOrSnapshot(this.modelId, "gpt-transcribe");
|
|
2463
|
+
if (!supportsDelay && openAIOptions?.streaming?.delay != null) warnings.push({
|
|
2464
|
+
type: "unsupported",
|
|
2465
|
+
feature: "providerOptions.openai.streaming.delay",
|
|
2466
|
+
details: `OpenAI streaming transcription with ${this.modelId} does not support delay.`
|
|
2467
|
+
});
|
|
2385
2468
|
const headers = combineHeaders(this.config.headers?.(), options.headers);
|
|
2386
2469
|
const sessionUpdate = buildOpenAIRealtimeTranscriptionSession({
|
|
2387
2470
|
modelId: this.modelId,
|
|
2388
2471
|
inputAudioFormat: options.inputAudioFormat,
|
|
2389
|
-
providerOptions: openAIOptions
|
|
2472
|
+
providerOptions: openAIOptions,
|
|
2473
|
+
supportsDelay
|
|
2390
2474
|
});
|
|
2391
2475
|
return {
|
|
2392
2476
|
request: { body: sessionUpdate },
|
|
@@ -2521,7 +2605,7 @@ function createOpenAIRealtimeTranscriptionStream({ webSocket, url, headers, sess
|
|
|
2521
2605
|
}
|
|
2522
2606
|
});
|
|
2523
2607
|
}
|
|
2524
|
-
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions }) {
|
|
2608
|
+
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions, supportsDelay }) {
|
|
2525
2609
|
return {
|
|
2526
2610
|
type: "session.update",
|
|
2527
2611
|
session: {
|
|
@@ -2533,8 +2617,8 @@ function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, pr
|
|
|
2533
2617
|
},
|
|
2534
2618
|
transcription: {
|
|
2535
2619
|
model: modelId,
|
|
2536
|
-
...providerOptions?.language != null ? { language: providerOptions.language } : {},
|
|
2537
|
-
...providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2620
|
+
...providerOptions?.language != null ? usesLanguagesList(modelId) ? { languages: [providerOptions.language] } : { language: providerOptions.language } : {},
|
|
2621
|
+
...supportsDelay && providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
2538
2622
|
},
|
|
2539
2623
|
turn_detection: null
|
|
2540
2624
|
} },
|
|
@@ -6311,15 +6395,12 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6311
6395
|
providerOptions,
|
|
6312
6396
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
6313
6397
|
});
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
});
|
|
6321
|
-
resolvedReasoningEffort = void 0;
|
|
6322
|
-
}
|
|
6398
|
+
const resolvedReasoningEffort = resolveOpenAIReasoningEffort({
|
|
6399
|
+
providerReasoningEffort: openaiOptions?.reasoningEffort,
|
|
6400
|
+
reasoning,
|
|
6401
|
+
supportedReasoningEfforts: modelCapabilities.supportedReasoningEfforts,
|
|
6402
|
+
warnings
|
|
6403
|
+
});
|
|
6323
6404
|
const resolvedReasoningSummary = openaiOptions?.reasoningSummary !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
|
|
6324
6405
|
const isReasoningModel = openaiOptions?.forceReasoning ?? modelCapabilities.isReasoningModel;
|
|
6325
6406
|
if (openaiOptions?.conversation && openaiOptions?.previousResponseId) warnings.push({
|
|
@@ -6382,7 +6463,8 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6382
6463
|
outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
|
|
6383
6464
|
});
|
|
6384
6465
|
warnings.push(...inputWarnings);
|
|
6385
|
-
const
|
|
6466
|
+
const supportedReasoningEfforts = modelCapabilities.supportedReasoningEfforts;
|
|
6467
|
+
const getUpdateEffortUnsupportedReason = (effort) => effort != null && supportedReasoningEfforts?.includes(effort) === false ? `${modelId} only supports the following reasoning efforts: ${supportedReasoningEfforts.join(", ")}` : void 0;
|
|
6386
6468
|
for (const item of input) if (item.type === "configuration_update") {
|
|
6387
6469
|
const unsupportedReason = getUpdateEffortUnsupportedReason(item.reasoning.effort);
|
|
6388
6470
|
if (unsupportedReason != null) throw new UnsupportedFunctionalityError({
|
|
@@ -6498,7 +6580,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6498
6580
|
details: "topP is not supported for reasoning models"
|
|
6499
6581
|
});
|
|
6500
6582
|
}
|
|
6501
|
-
if (modelCapabilities.
|
|
6583
|
+
if (modelCapabilities.supportsConfigurationUpdate && (baseArgs.top_logprobs != null || baseArgs.include?.includes("message.output_text.logprobs"))) {
|
|
6502
6584
|
baseArgs.top_logprobs = void 0;
|
|
6503
6585
|
const filteredInclude = baseArgs.include?.filter((value) => value !== "message.output_text.logprobs");
|
|
6504
6586
|
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
@@ -6821,10 +6903,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6821
6903
|
type: "tool-result",
|
|
6822
6904
|
toolCallId: part.id,
|
|
6823
6905
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
6824
|
-
...part
|
|
6825
|
-
isError: true,
|
|
6826
|
-
result: { status: part.status }
|
|
6827
|
-
} : { result: mapWebSearchOutput(part.action) }
|
|
6906
|
+
...mapWebSearchResult(part)
|
|
6828
6907
|
});
|
|
6829
6908
|
if (part.action?.type === "search") {
|
|
6830
6909
|
for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
|
|
@@ -7435,10 +7514,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7435
7514
|
type: "tool-result",
|
|
7436
7515
|
toolCallId: value.item.id,
|
|
7437
7516
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
7438
|
-
...value.item
|
|
7439
|
-
isError: true,
|
|
7440
|
-
result: { status: value.item.status }
|
|
7441
|
-
} : { result: mapWebSearchOutput(value.item.action) }
|
|
7517
|
+
...mapWebSearchResult(value.item)
|
|
7442
7518
|
});
|
|
7443
7519
|
if (value.item.action?.type === "search") {
|
|
7444
7520
|
for (const source of value.item.action.sources ?? []) if (source.type === "url") {
|
|
@@ -8054,6 +8130,12 @@ function isResponseInProgressChunk(chunk) {
|
|
|
8054
8130
|
function isResponseOutputChunk(chunk) {
|
|
8055
8131
|
return !(chunk.type === "response.created" || chunk.type === "response.in_progress" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
|
|
8056
8132
|
}
|
|
8133
|
+
function mapWebSearchResult({ action, status }) {
|
|
8134
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : {
|
|
8135
|
+
isError: true,
|
|
8136
|
+
result: { status }
|
|
8137
|
+
};
|
|
8138
|
+
}
|
|
8057
8139
|
function mapWebSearchOutput(action) {
|
|
8058
8140
|
if (action == null) return {};
|
|
8059
8141
|
switch (action.type) {
|
|
@@ -8080,6 +8162,6 @@ function escapeJSONDelta(delta) {
|
|
|
8080
8162
|
return JSON.stringify(delta).slice(1, -1);
|
|
8081
8163
|
}
|
|
8082
8164
|
//#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,
|
|
8165
|
+
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
8166
|
|
|
8085
8167
|
//# sourceMappingURL=index.js.map
|