@ai-sdk/openai 4.0.102 → 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 +29 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -50
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +101 -5
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +74 -47
- 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/completion/convert-to-openai-completion-prompt.ts +1 -1
- package/src/internal/index.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 +18 -8
- package/src/responses/openai-responses-prepare-tools.ts +4 -3
- package/src/transcription/openai-transcription-model-options.ts +5 -6
- package/src/transcription/openai-transcription-model.ts +89 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.104
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 01d7a03: feat(openai): add GPT-6.1 Terra model support
|
|
8
|
+
- 599a97f: fix(openai): read transcription duration from `usage` for duration-billed `json` responses
|
|
9
|
+
|
|
10
|
+
`durationInSeconds` now falls back to `usage.seconds` when `usage.type` is `duration` and the response has no top-level `duration` (e.g. `gpt-transcribe` with the default `json` response format).
|
|
11
|
+
|
|
12
|
+
- 8375141: Support streaming transcription with `gpt-live-transcribe` and `gpt-transcribe`. For these models the `language` provider option is sent as a single-entry `languages` list. `gpt-transcribe` warns about and omits `streaming.delay`, which it does not support. `gpt-live-transcribe` rejects non-streaming transcription, since it has no REST endpoint.
|
|
13
|
+
- 7eac057: fix(openai): strip `propertyNames` schemas that omit `type: 'string'` (e.g. Zod 3 records with constrained keys) instead of throwing an unsupported functionality error
|
|
14
|
+
- 436374e: fix(openai): report unfinished web searches as tool errors
|
|
15
|
+
- 9026c7d: fix(openai): only send transcription response format and timestamp defaults when needed
|
|
16
|
+
|
|
17
|
+
Transcription requests no longer send `response_format=verbose_json` or `timestamp_granularities[]=segment` unless the caller sets them or the model needs them. Previously, any `providerOptions.openai` value (such as a `prompt`) caused `verbose_json` to be sent for models like `gpt-transcribe`, which rejected the request.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [57086ff]
|
|
20
|
+
- Updated dependencies [95348b3]
|
|
21
|
+
- @ai-sdk/provider-utils@5.0.70
|
|
22
|
+
|
|
23
|
+
## 4.0.103
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 02dbab1: add azure.tools.toolSearch and support azure provider options on responses function tools
|
|
28
|
+
- 27a53b4: Fix string interpolation in Amazon Bedrock unsupported provider tool warnings and OpenAI / OpenAI-compatible completion errors for unexpected system messages.
|
|
29
|
+
- Updated dependencies [e64ed82]
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.69
|
|
31
|
+
|
|
3
32
|
## 4.0.102
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ type OpenAIConfig = {
|
|
|
45
45
|
type OpenAIDecisionModelId = 'gpt-6-luna' | (string & {});
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/chat/openai-chat-language-model-options.d.ts
|
|
48
|
-
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 & {});
|
|
48
|
+
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 & {});
|
|
49
49
|
declare const openaiLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
50
50
|
logitBias?: Record<number, number> | undefined;
|
|
51
51
|
logprobs?: number | boolean | undefined;
|
|
@@ -177,7 +177,7 @@ declare const customToolFactory: import("@ai-sdk/provider-utils").ProviderDefine
|
|
|
177
177
|
}, {}>;
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/responses/openai-responses-language-model-options.d.ts
|
|
180
|
-
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 & {});
|
|
180
|
+
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 & {});
|
|
181
181
|
declare const openaiLanguageModelResponsesOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
182
182
|
conversation?: string | null | undefined;
|
|
183
183
|
include?: ("reasoning.encrypted_content" | "file_search_call.results" | "web_search_call.results" | "message.output_text.logprobs")[] | null | undefined;
|
|
@@ -1636,7 +1636,7 @@ declare const openaiSpeechModelOptionsSchema: import("@ai-sdk/provider-utils").L
|
|
|
1636
1636
|
type OpenAISpeechModelOptions = InferSchema<typeof openaiSpeechModelOptionsSchema>;
|
|
1637
1637
|
//#endregion
|
|
1638
1638
|
//#region src/transcription/openai-transcription-model-options.d.ts
|
|
1639
|
-
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 & {});
|
|
1639
|
+
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 & {});
|
|
1640
1640
|
declare const openAITranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
1641
1641
|
include?: string[] | undefined;
|
|
1642
1642
|
language?: string | undefined;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/openai-config.ts","../src/openai-decision-model.ts","../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-language-model-options.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/speech-translation/openai-speech-translation-model.ts","../src/files/openai-files-options.ts","../src/tool/computer.ts","../src/responses/openai-responses-provider-metadata.ts","../src/version.ts","../src/openai-decision-model-options.ts"],"mappings":";;;;KAKK,gBAAgB;KAMT;EACV;;EAEA;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;KCdU;;;KCrBA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/openai-config.ts","../src/openai-decision-model.ts","../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-language-model-options.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/speech-translation/openai-speech-translation-model.ts","../src/files/openai-files-options.ts","../src/tool/computer.ts","../src/responses/openai-responses-provider-metadata.ts","../src/version.ts","../src/openai-decision-model-options.ts"],"mappings":";;;;KAKK,gBAAgB;KAMT;EACV;;EAEA;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;KCdU;;;KCrBA;cAuEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;KAwJ/B,iCAAiC,mBAC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AwB;;;;KAczB,qBAAqB,mBAAmB;;;cCd9C,yBAAiB,EAAA;;;;GAKnB,EAAA,KAAA;cAEE,4BAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDtB,EAAA,KAAA;KAkCQ,uBAAuB,EAAE,MACnC,kBAAkB;KAER,4BAA4B,EAAE,MACxC,kBAAkB;;;KC9Ff,uBAAuB,mBAAmB;KAE1C,gDAAgD,QACnD;EACE;;KAGQ;EACV;EACA,WAAW,MAAM;EACjB;EACA;;KAGU;EACV;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;IACM;;IAEA;IACA;;;KAII;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV;EACA;EACA,cAAc,MAAM;;KAGV;EACV,QAAQ;;KAGE;EAEN;EACA;;EAGA;EACA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;EACA;;KAGM;EACV,QAAQ;;;;qBCzFG;;;cCKA,6DAA0B;EAAA;;KAS3B,6BAA6B,mBAChC"}
|
package/dist/index.js
CHANGED
|
@@ -268,17 +268,17 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
268
268
|
const isGptChatModel = gptVersion?.minor == null && (gptVersion?.variant?.startsWith("chat") ?? false);
|
|
269
269
|
const isGptNanoModel = gptVersion?.variant?.startsWith("nano") ?? false;
|
|
270
270
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
271
|
-
const
|
|
271
|
+
const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
|
|
272
272
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
273
273
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
274
274
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
275
|
-
const supportsNonReasoningParameters =
|
|
275
|
+
const supportsNonReasoningParameters = isGpt6OrLaterModelWithNoneEffort || !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1);
|
|
276
276
|
return {
|
|
277
277
|
supportsFlexProcessing,
|
|
278
278
|
supportsPriorityProcessing,
|
|
279
279
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
280
280
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
281
|
-
supportedReasoningEfforts:
|
|
281
|
+
supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? [
|
|
282
282
|
"none",
|
|
283
283
|
"low",
|
|
284
284
|
"medium",
|
|
@@ -1004,7 +1004,7 @@ function normalizeOpenAIJsonSchema(schema) {
|
|
|
1004
1004
|
function normalizeSchema(schema, isRoot = false) {
|
|
1005
1005
|
const propertyNames = schema.propertyNames;
|
|
1006
1006
|
if (propertyNames != null) {
|
|
1007
|
-
if (typeof propertyNames === "boolean" || propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
1007
|
+
if (typeof propertyNames === "boolean" || propertyNames.type != null && propertyNames.type !== "string") throw new UnsupportedFunctionalityError({ functionality: "JSON Schema propertyNames that does not use a string schema" });
|
|
1008
1008
|
removedPropertyNames = true;
|
|
1009
1009
|
}
|
|
1010
1010
|
const normalizedSchema = { ...schema };
|
|
@@ -1592,7 +1592,7 @@ function convertToOpenAICompletionPrompt({ prompt, user = "user", assistant = "a
|
|
|
1592
1592
|
}
|
|
1593
1593
|
for (const { role, content } of prompt) switch (role) {
|
|
1594
1594
|
case "system": throw new InvalidPromptError({
|
|
1595
|
-
message:
|
|
1595
|
+
message: `Unexpected system message in prompt: ${content}`,
|
|
1596
1596
|
prompt
|
|
1597
1597
|
});
|
|
1598
1598
|
case "user": {
|
|
@@ -5685,7 +5685,7 @@ function mapOpenAIResponsesCitations(annotations, providerOptionsName) {
|
|
|
5685
5685
|
}
|
|
5686
5686
|
//#endregion
|
|
5687
5687
|
//#region src/responses/openai-responses-prepare-tools.ts
|
|
5688
|
-
async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolNameMapping, customProviderToolNames, outputSchemaToolNames, supportsAsyncToolCalling = true }) {
|
|
5688
|
+
async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolNameMapping, customProviderToolNames, outputSchemaToolNames, supportsAsyncToolCalling = true, providerOptionsName = "openai" }) {
|
|
5689
5689
|
tools = tools?.length ? tools : void 0;
|
|
5690
5690
|
const toolWarnings = [];
|
|
5691
5691
|
if (tools == null) return {
|
|
@@ -5707,7 +5707,7 @@ async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolName
|
|
|
5707
5707
|
};
|
|
5708
5708
|
for (const tool of tools) switch (tool.type) {
|
|
5709
5709
|
case "function": {
|
|
5710
|
-
const openaiOptions = tool.providerOptions?.openai;
|
|
5710
|
+
const openaiOptions = tool.providerOptions?.[providerOptionsName] ?? tool.providerOptions?.openai;
|
|
5711
5711
|
if (openaiOptions?.outputSchema != null) outputSchemaToolNames?.add(tool.name);
|
|
5712
5712
|
if (openaiOptions?.omitFromRequestTools === true) {
|
|
5713
5713
|
recordAllowedTool(tool.name, {
|
|
@@ -6323,7 +6323,8 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6323
6323
|
toolNameMapping,
|
|
6324
6324
|
customProviderToolNames,
|
|
6325
6325
|
outputSchemaToolNames,
|
|
6326
|
-
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
6326
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
|
|
6327
|
+
providerOptionsName
|
|
6327
6328
|
});
|
|
6328
6329
|
const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
|
|
6329
6330
|
modelCapabilities,
|
|
@@ -6790,10 +6791,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6790
6791
|
type: "tool-result",
|
|
6791
6792
|
toolCallId: part.id,
|
|
6792
6793
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
6793
|
-
...part
|
|
6794
|
-
isError: true,
|
|
6795
|
-
result: { status: part.status }
|
|
6796
|
-
} : { result: mapWebSearchOutput(part.action) }
|
|
6794
|
+
...mapWebSearchResult(part)
|
|
6797
6795
|
});
|
|
6798
6796
|
if (part.action?.type === "search") {
|
|
6799
6797
|
for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
|
|
@@ -7404,10 +7402,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7404
7402
|
type: "tool-result",
|
|
7405
7403
|
toolCallId: value.item.id,
|
|
7406
7404
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
7407
|
-
...value.item
|
|
7408
|
-
isError: true,
|
|
7409
|
-
result: { status: value.item.status }
|
|
7410
|
-
} : { result: mapWebSearchOutput(value.item.action) }
|
|
7405
|
+
...mapWebSearchResult(value.item)
|
|
7411
7406
|
});
|
|
7412
7407
|
if (value.item.action?.type === "search") {
|
|
7413
7408
|
for (const source of value.item.action.sources ?? []) if (source.type === "url") {
|
|
@@ -8023,6 +8018,12 @@ function isResponseInProgressChunk(chunk) {
|
|
|
8023
8018
|
function isResponseOutputChunk(chunk) {
|
|
8024
8019
|
return !(chunk.type === "response.created" || chunk.type === "response.in_progress" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
|
|
8025
8020
|
}
|
|
8021
|
+
function mapWebSearchResult({ action, status }) {
|
|
8022
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : {
|
|
8023
|
+
isError: true,
|
|
8024
|
+
result: { status }
|
|
8025
|
+
};
|
|
8026
|
+
}
|
|
8026
8027
|
function mapWebSearchOutput(action) {
|
|
8027
8028
|
if (action == null) return {};
|
|
8028
8029
|
switch (action.type) {
|
|
@@ -8535,10 +8536,7 @@ async function convertOpenAIBatchResult(body) {
|
|
|
8535
8536
|
type: "tool-result",
|
|
8536
8537
|
toolCallId: part.id,
|
|
8537
8538
|
toolName: "web_search",
|
|
8538
|
-
...part
|
|
8539
|
-
isError: true,
|
|
8540
|
-
result: { status: part.status }
|
|
8541
|
-
} : { result: mapWebSearchOutput(part.action) },
|
|
8539
|
+
...mapWebSearchResult(part),
|
|
8542
8540
|
dynamic: true
|
|
8543
8541
|
});
|
|
8544
8542
|
break;
|
|
@@ -9544,9 +9542,9 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
9544
9542
|
temperature: z.number().min(0).max(1).default(0).optional(),
|
|
9545
9543
|
/**
|
|
9546
9544
|
* The timestamp granularities to populate for this transcription.
|
|
9547
|
-
*
|
|
9545
|
+
* Defaults to ['segment'] when the response format is verbose_json.
|
|
9548
9546
|
*/
|
|
9549
|
-
timestampGranularities: z.array(z.enum(["word", "segment"])).
|
|
9547
|
+
timestampGranularities: z.array(z.enum(["word", "segment"])).optional(),
|
|
9550
9548
|
/**
|
|
9551
9549
|
* The format of the transcription response.
|
|
9552
9550
|
*/
|
|
@@ -9565,7 +9563,7 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
9565
9563
|
silenceDurationMs: z.number().int().min(0).optional()
|
|
9566
9564
|
})]).optional(),
|
|
9567
9565
|
/**
|
|
9568
|
-
* Options for streaming transcription models such as `gpt-
|
|
9566
|
+
* Options for streaming transcription models such as `gpt-live-transcribe`.
|
|
9569
9567
|
*/
|
|
9570
9568
|
streaming: z.object({
|
|
9571
9569
|
/**
|
|
@@ -9587,12 +9585,32 @@ const openAITranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
9587
9585
|
//#endregion
|
|
9588
9586
|
//#region src/transcription/openai-transcription-model.ts
|
|
9589
9587
|
/**
|
|
9590
|
-
*
|
|
9591
|
-
*
|
|
9592
|
-
|
|
9588
|
+
* Whether `modelId` is `base` or one of its dated snapshots
|
|
9589
|
+
* (e.g. `gpt-realtime-whisper-2026-01-01`).
|
|
9590
|
+
*/
|
|
9591
|
+
function isModelOrSnapshot(modelId, base) {
|
|
9592
|
+
return modelId === base || modelId.startsWith(`${base}-`);
|
|
9593
|
+
}
|
|
9594
|
+
/**
|
|
9595
|
+
* Model IDs that stream over the realtime transcription WebSocket and do not
|
|
9596
|
+
* support the REST transcription endpoint.
|
|
9593
9597
|
*/
|
|
9594
9598
|
function isRealtimeTranscriptionModelId(modelId) {
|
|
9595
|
-
return modelId
|
|
9599
|
+
return isModelOrSnapshot(modelId, "gpt-realtime-whisper") || isModelOrSnapshot(modelId, "gpt-live-transcribe");
|
|
9600
|
+
}
|
|
9601
|
+
/**
|
|
9602
|
+
* Model IDs that support streaming transcription. `gpt-transcribe` also
|
|
9603
|
+
* supports the REST transcription endpoint.
|
|
9604
|
+
*/
|
|
9605
|
+
function supportsStreamingTranscription(modelId) {
|
|
9606
|
+
return isRealtimeTranscriptionModelId(modelId) || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
9607
|
+
}
|
|
9608
|
+
/**
|
|
9609
|
+
* Models whose realtime transcription session takes a `languages` list
|
|
9610
|
+
* instead of the singular `language` field.
|
|
9611
|
+
*/
|
|
9612
|
+
function usesLanguagesList(modelId) {
|
|
9613
|
+
return isModelOrSnapshot(modelId, "gpt-live-transcribe") || isModelOrSnapshot(modelId, "gpt-transcribe");
|
|
9596
9614
|
}
|
|
9597
9615
|
const languageMap = {
|
|
9598
9616
|
afrikaans: "af",
|
|
@@ -9686,24 +9704,22 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
9686
9704
|
formData.append("model", this.modelId);
|
|
9687
9705
|
const fileExtension = mediaTypeToExtension(mediaType);
|
|
9688
9706
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${fileExtension}`);
|
|
9689
|
-
if (this.modelId === "whisper-1") formData.append("response_format", "verbose_json");
|
|
9690
9707
|
const isDiarizationModel = this.modelId === "gpt-4o-transcribe-diarize";
|
|
9708
|
+
const responseFormat = openAIOptions?.responseFormat ?? (isDiarizationModel ? "diarized_json" : this.modelId === "whisper-1" ? "verbose_json" : void 0);
|
|
9709
|
+
const timestampGranularities = openAIOptions?.timestampGranularities ?? (responseFormat === "verbose_json" ? ["segment"] : void 0);
|
|
9691
9710
|
const chunkingStrategy = openAIOptions?.chunkingStrategy ?? (isDiarizationModel ? "auto" : void 0);
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
};
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
else formData.append(key, String(value));
|
|
9705
|
-
}
|
|
9706
|
-
} else if (isDiarizationModel) formData.append("response_format", "diarized_json");
|
|
9711
|
+
const transcriptionModelOptions = {
|
|
9712
|
+
response_format: responseFormat,
|
|
9713
|
+
include: openAIOptions?.include,
|
|
9714
|
+
language: openAIOptions?.language,
|
|
9715
|
+
prompt: openAIOptions?.prompt,
|
|
9716
|
+
temperature: openAIOptions?.temperature,
|
|
9717
|
+
timestamp_granularities: timestampGranularities
|
|
9718
|
+
};
|
|
9719
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) if (value != null) {
|
|
9720
|
+
if (Array.isArray(value)) for (const item of value) formData.append(`${key}[]`, String(item));
|
|
9721
|
+
else formData.append(key, String(value));
|
|
9722
|
+
}
|
|
9707
9723
|
if (chunkingStrategy != null) formData.append("chunking_strategy", typeof chunkingStrategy === "string" ? chunkingStrategy : JSON.stringify({
|
|
9708
9724
|
type: chunkingStrategy.type,
|
|
9709
9725
|
...chunkingStrategy.threshold != null && { threshold: chunkingStrategy.threshold },
|
|
@@ -9750,7 +9766,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
9750
9766
|
endSecond: word.end
|
|
9751
9767
|
})) ?? [],
|
|
9752
9768
|
language,
|
|
9753
|
-
durationInSeconds: response.duration ?? void 0,
|
|
9769
|
+
durationInSeconds: response.duration ?? (response.usage?.type === "duration" && typeof response.usage.seconds === "number" ? response.usage.seconds : void 0),
|
|
9754
9770
|
warnings,
|
|
9755
9771
|
...response.usage != null && { usage: response.usage },
|
|
9756
9772
|
response: {
|
|
@@ -9766,7 +9782,7 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
9766
9782
|
};
|
|
9767
9783
|
}
|
|
9768
9784
|
async doStream(options) {
|
|
9769
|
-
if (!
|
|
9785
|
+
if (!supportsStreamingTranscription(this.modelId)) throw new UnsupportedFunctionalityError({ functionality: `streaming transcription with ${this.modelId}` });
|
|
9770
9786
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
9771
9787
|
const openAIOptions = await parseProviderOptions({
|
|
9772
9788
|
provider: "openai",
|
|
@@ -9785,11 +9801,18 @@ var OpenAITranscriptionModel = class OpenAITranscriptionModel {
|
|
|
9785
9801
|
feature: `providerOptions.openai.${option}`,
|
|
9786
9802
|
details: `OpenAI streaming transcription does not support ${option}.`
|
|
9787
9803
|
});
|
|
9804
|
+
const supportsDelay = !isModelOrSnapshot(this.modelId, "gpt-transcribe");
|
|
9805
|
+
if (!supportsDelay && openAIOptions?.streaming?.delay != null) warnings.push({
|
|
9806
|
+
type: "unsupported",
|
|
9807
|
+
feature: "providerOptions.openai.streaming.delay",
|
|
9808
|
+
details: `OpenAI streaming transcription with ${this.modelId} does not support delay.`
|
|
9809
|
+
});
|
|
9788
9810
|
const headers = combineHeaders(this.config.headers?.(), options.headers);
|
|
9789
9811
|
const sessionUpdate = buildOpenAIRealtimeTranscriptionSession({
|
|
9790
9812
|
modelId: this.modelId,
|
|
9791
9813
|
inputAudioFormat: options.inputAudioFormat,
|
|
9792
|
-
providerOptions: openAIOptions
|
|
9814
|
+
providerOptions: openAIOptions,
|
|
9815
|
+
supportsDelay
|
|
9793
9816
|
});
|
|
9794
9817
|
return {
|
|
9795
9818
|
request: { body: sessionUpdate },
|
|
@@ -9924,7 +9947,7 @@ function createOpenAIRealtimeTranscriptionStream({ webSocket, url, headers, sess
|
|
|
9924
9947
|
}
|
|
9925
9948
|
});
|
|
9926
9949
|
}
|
|
9927
|
-
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions }) {
|
|
9950
|
+
function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, providerOptions, supportsDelay }) {
|
|
9928
9951
|
return {
|
|
9929
9952
|
type: "session.update",
|
|
9930
9953
|
session: {
|
|
@@ -9936,8 +9959,8 @@ function buildOpenAIRealtimeTranscriptionSession({ modelId, inputAudioFormat, pr
|
|
|
9936
9959
|
},
|
|
9937
9960
|
transcription: {
|
|
9938
9961
|
model: modelId,
|
|
9939
|
-
...providerOptions?.language != null ? { language: providerOptions.language } : {},
|
|
9940
|
-
...providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
9962
|
+
...providerOptions?.language != null ? usesLanguagesList(modelId) ? { languages: [providerOptions.language] } : { language: providerOptions.language } : {},
|
|
9963
|
+
...supportsDelay && providerOptions?.streaming?.delay != null ? { delay: providerOptions.streaming.delay } : {}
|
|
9941
9964
|
},
|
|
9942
9965
|
turn_detection: null
|
|
9943
9966
|
} },
|
|
@@ -10251,7 +10274,7 @@ var OpenAISkills = class {
|
|
|
10251
10274
|
};
|
|
10252
10275
|
//#endregion
|
|
10253
10276
|
//#region src/version.ts
|
|
10254
|
-
const VERSION = "4.0.
|
|
10277
|
+
const VERSION = "4.0.104";
|
|
10255
10278
|
//#endregion
|
|
10256
10279
|
//#region src/openai-provider.ts
|
|
10257
10280
|
/**
|