@ai-sdk/openai 4.0.83 → 4.0.85
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 +38 -0
- package/dist/index.d.ts +60 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +220 -20
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -0
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +48 -19
- package/package.json +5 -5
- package/src/chat/openai-chat-language-model.ts +11 -0
- package/src/files/openai-files.ts +1 -1
- package/src/index.ts +2 -0
- package/src/openai-batch.ts +2 -0
- package/src/openai-decision-model-options.ts +19 -0
- package/src/openai-decision-model.ts +285 -0
- package/src/openai-provider.ts +27 -8
- package/src/skills/openai-skills.ts +5 -1
- package/src/transcription/openai-transcription-model.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.85
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fc1e19e: fix: limit jsonl rows to 64mb during batch result downloads
|
|
8
|
+
- 99bdcd2: Replace the OpenAI structured-output wrapper for `decide` with the native Decisions API. Only `gpt-6-luna` is currently supported by this endpoint; other Responses models no longer work with `openai.decisionModel()` or its deprecated `evaluationModel()` alias.
|
|
9
|
+
|
|
10
|
+
Responses API options, such as `reasoningEffort`, are no longer applied and produce unsupported-option warnings. The Decisions API supports `providerOptions.openai.safetyIdentifier`. Native token usage and confidence values are preserved, and per-question refusals fail the decision call.
|
|
11
|
+
|
|
12
|
+
- 268225c: feat(provider): add a portable `max` reasoning level with native provider mappings, compatibility coercions, and budget-based fallback support.
|
|
13
|
+
|
|
14
|
+
Compatibility notes:
|
|
15
|
+
|
|
16
|
+
- **TypeScript source compatibility:** Adding `max` widens `LanguageModelV4CallOptions['reasoning']` and the derived `ReasoningLevel` type. Third-party providers and consumers with exhaustive switches or `Record<ReasoningLevel, ...>` mappings must handle `max` before upgrading. Ordinary calls using existing reasoning levels remain accepted.
|
|
17
|
+
- **Amazon Bedrock:** Existing Nova 2 calls using portable `reasoning: 'xhigh'` now send `maxReasoningEffort: 'high'` instead of the unsupported `'max'`, and return a compatibility warning. Anthropic and OpenAI Bedrock effort mappings retain their existing `xhigh` behavior. Partial Bedrock reasoning configurations continue to preserve explicit values and derive missing fields; explicit effort/budget overrides and disabled thinking no longer emit warnings for portable mappings that are not sent.
|
|
18
|
+
- **Fireworks:** Existing portable `minimal` and `xhigh` calls keep their request mappings to `low` and `high`, respectively, and now return compatibility warnings in generation and streaming results. Portable `max` maps to `high` with the same warning behavior.
|
|
19
|
+
|
|
20
|
+
**Release classification:** This remains a patch changeset under the repository's explicit release policy, which uses patch releases for both fixes and features. The TypeScript source-compatibility caveat for exhaustive consumers is disclosed above. Maintainers can override this classification with a `major` label if they decide to align the provider-spec addition with a future AI SDK major release.
|
|
21
|
+
|
|
22
|
+
- 0af2f7c: chore: upgrade to TypeScript 6
|
|
23
|
+
- Updated dependencies [fc1e19e]
|
|
24
|
+
- Updated dependencies [5094ebd]
|
|
25
|
+
- Updated dependencies [268225c]
|
|
26
|
+
- Updated dependencies [0af2f7c]
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.55
|
|
28
|
+
- @ai-sdk/provider@4.0.23
|
|
29
|
+
|
|
30
|
+
## 4.0.84
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 2959d35: feat: rename `evaluate` to `decide`
|
|
35
|
+
- 5b8e63b: feat(openai): warn when reasoningSummary is used with chat models
|
|
36
|
+
- Updated dependencies [2959d35]
|
|
37
|
+
- Updated dependencies [59116e6]
|
|
38
|
+
- @ai-sdk/provider@4.0.22
|
|
39
|
+
- @ai-sdk/provider-utils@5.0.54
|
|
40
|
+
|
|
3
41
|
## 4.0.83
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { FetchFunction, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { EmbeddingModelV4, Experimental_BatchV4,
|
|
2
|
+
import { EmbeddingModelV4, Experimental_BatchV4, Experimental_DecisionModelV4, Experimental_RealtimeFactoryV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_SpeechTranslationModelV4, Experimental_SpeechTranslationModelV4StreamOptions, FilesV4, ImageModelV4, JSONObject, JSONValue, LanguageModelV4, ProviderV4, SkillsV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
|
+
//#region src/openai-config.d.ts
|
|
5
|
+
type OpenAIHeaders = Record<string, string | undefined>;
|
|
6
|
+
type OpenAIConfig = {
|
|
7
|
+
provider: string;
|
|
8
|
+
baseURL?: string;
|
|
9
|
+
url: (options: {
|
|
10
|
+
modelId: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}) => string;
|
|
13
|
+
headers?: () => OpenAIHeaders;
|
|
14
|
+
fetch?: FetchFunction;
|
|
15
|
+
webSocket?: WebSocketConstructor;
|
|
16
|
+
generateId?: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether Responses API message input items must include an explicit
|
|
19
|
+
* `type: 'message'` discriminator.
|
|
20
|
+
*
|
|
21
|
+
* @see https://github.com/vercel/ai/issues/20180
|
|
22
|
+
*/
|
|
23
|
+
explicitMessageItemType?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the provider supports the
|
|
26
|
+
* `web_search_call.action.sources` Responses API include value.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `true`.
|
|
29
|
+
*/
|
|
30
|
+
supportsWebSearchSourcesInclude?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
|
|
33
|
+
* in file part data instead. File ID prefixes used to identify file IDs
|
|
34
|
+
* in Responses API. When undefined, all string file data is treated as
|
|
35
|
+
* base64 content.
|
|
36
|
+
*
|
|
37
|
+
* TODO: remove in v8
|
|
38
|
+
*/
|
|
39
|
+
fileIdPrefixes?: readonly string[];
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/openai-decision-model.d.ts
|
|
43
|
+
type OpenAIDecisionModelId = 'gpt-6-luna' | (string & {});
|
|
44
|
+
//#endregion
|
|
4
45
|
//#region src/chat/openai-chat-language-model-options.d.ts
|
|
5
46
|
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 & {});
|
|
6
47
|
declare const openaiLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
@@ -1594,8 +1635,12 @@ type OpenAISpeechTranslationModelOptions = InferSchema<typeof openAISpeechTransl
|
|
|
1594
1635
|
//#region src/openai-provider.d.ts
|
|
1595
1636
|
interface OpenAIProvider extends ProviderV4 {
|
|
1596
1637
|
(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
1597
|
-
/** Creates an experimental Choice/Score/Boolean
|
|
1598
|
-
|
|
1638
|
+
/** Creates an experimental Choice/Score/Boolean decision model using the Decisions API. */
|
|
1639
|
+
decisionModel(modelId: OpenAIDecisionModelId): Experimental_DecisionModelV4;
|
|
1640
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
1641
|
+
evaluationModel(modelId: OpenAIDecisionModelId): Experimental_DecisionModelV4 & {
|
|
1642
|
+
doEvaluate: Experimental_DecisionModelV4['doDecide'];
|
|
1643
|
+
};
|
|
1599
1644
|
/**
|
|
1600
1645
|
* Creates an OpenAI model for text generation.
|
|
1601
1646
|
*/
|
|
@@ -1677,6 +1722,11 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1677
1722
|
tools: typeof openaiTools;
|
|
1678
1723
|
}
|
|
1679
1724
|
interface OpenAIProviderSettings {
|
|
1725
|
+
/** Settings for downloading JSON Lines batch results. */
|
|
1726
|
+
batchResultDownloads?: {
|
|
1727
|
+
/** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
|
|
1728
|
+
maxLineBytes?: number;
|
|
1729
|
+
};
|
|
1680
1730
|
/**
|
|
1681
1731
|
* Base URL for the OpenAI API calls.
|
|
1682
1732
|
*/
|
|
@@ -1737,44 +1787,6 @@ type OpenAIToolOptions = {
|
|
|
1737
1787
|
};
|
|
1738
1788
|
};
|
|
1739
1789
|
//#endregion
|
|
1740
|
-
//#region src/openai-config.d.ts
|
|
1741
|
-
type OpenAIHeaders = Record<string, string | undefined>;
|
|
1742
|
-
type OpenAIConfig = {
|
|
1743
|
-
provider: string;
|
|
1744
|
-
baseURL?: string;
|
|
1745
|
-
url: (options: {
|
|
1746
|
-
modelId: string;
|
|
1747
|
-
path: string;
|
|
1748
|
-
}) => string;
|
|
1749
|
-
headers?: () => OpenAIHeaders;
|
|
1750
|
-
fetch?: FetchFunction;
|
|
1751
|
-
webSocket?: WebSocketConstructor;
|
|
1752
|
-
generateId?: () => string;
|
|
1753
|
-
/**
|
|
1754
|
-
* Whether Responses API message input items must include an explicit
|
|
1755
|
-
* `type: 'message'` discriminator.
|
|
1756
|
-
*
|
|
1757
|
-
* @see https://github.com/vercel/ai/issues/20180
|
|
1758
|
-
*/
|
|
1759
|
-
explicitMessageItemType?: boolean;
|
|
1760
|
-
/**
|
|
1761
|
-
* Whether the provider supports the
|
|
1762
|
-
* `web_search_call.action.sources` Responses API include value.
|
|
1763
|
-
*
|
|
1764
|
-
* Defaults to `true`.
|
|
1765
|
-
*/
|
|
1766
|
-
supportsWebSearchSourcesInclude?: boolean;
|
|
1767
|
-
/**
|
|
1768
|
-
* This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
|
|
1769
|
-
* in file part data instead. File ID prefixes used to identify file IDs
|
|
1770
|
-
* in Responses API. When undefined, all string file data is treated as
|
|
1771
|
-
* base64 content.
|
|
1772
|
-
*
|
|
1773
|
-
* TODO: remove in v8
|
|
1774
|
-
*/
|
|
1775
|
-
fileIdPrefixes?: readonly string[];
|
|
1776
|
-
};
|
|
1777
|
-
//#endregion
|
|
1778
1790
|
//#region src/speech-translation/openai-speech-translation-model.d.ts
|
|
1779
1791
|
interface OpenAISpeechTranslationModelConfig extends OpenAIConfig {
|
|
1780
1792
|
_internal?: {
|
|
@@ -1932,5 +1944,11 @@ type OpenaiResponsesSourceDocumentProviderMetadata = {
|
|
|
1932
1944
|
//#region src/version.d.ts
|
|
1933
1945
|
export declare const VERSION: string;
|
|
1934
1946
|
//#endregion
|
|
1935
|
-
|
|
1947
|
+
//#region src/openai-decision-model-options.d.ts
|
|
1948
|
+
declare const openaiDecisionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
1949
|
+
safetyIdentifier?: string | undefined;
|
|
1950
|
+
}>;
|
|
1951
|
+
type OpenAIDecisionModelOptions = InferSchema<typeof openaiDecisionModelOptions>;
|
|
1952
|
+
//#endregion
|
|
1953
|
+
export { type OpenAIRealtimeFactory as Experimental_OpenAIRealtimeFactory, OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, OpenAIRealtimeModelLive as Experimental_OpenAIRealtimeModelLive, type OpenAIRealtimeModelLiveConfig as Experimental_OpenAIRealtimeModelLiveConfig, type OpenAIRealtimeModelLiveId as Experimental_OpenAIRealtimeModelLiveId, type OpenAIRealtimeModelLiveOptions as Experimental_OpenAIRealtimeModelLiveOptions, type OpenAIRealtimeOptions as Experimental_OpenAIRealtimeOptions, OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel, OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAISpeechTranslationModelId, type OpenAISpeechTranslationModelId as Experimental_OpenAITranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAISpeechTranslationModelOptions, type OpenAISpeechTranslationModelOptions as Experimental_OpenAITranslationModelOptions, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAILanguageModelChatOptions, type OpenAIComputerAction, type OpenAIComputerSafetyCheck, type OpenAIDecisionModelId, type OpenAIDecisionModelOptions, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesSystemMessageOptions, type OpenAISpeechModelOptions, type OpenAIToolOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata };
|
|
1936
1954
|
//# sourceMappingURL=index.d.ts.map
|
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","
|
|
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-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/responses/openai-responses-language-model-options.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;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB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AQ;EAGrB,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;cC5DnB,2DAAwB;;;;KAczB,qBAAqB,mBAAmB;;;cCd9C,mBAAiB,EAAA;;;;GAIrB,EAAA,KAAA;cAEI,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CxB,EAAA,KAAA;KAkCU,uBAAuB,EAAE,aAAa;KACtC,4BAA4B,EAAE,aAAa;;;KCzFlD,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;EACA;;EAGA;EACA;EACA;;EAGA;EACA;EACA;;KAGM;EACV,QAAQ;;;;qBCrFG;;;cCKA,6DAA0B;EAAA;;KAS3B,6BAA6B,mBAChC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, downloadBlob, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mediaTypeToExtension, normalizeBatchRequestCounts, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postMultipartStreamToApi, postToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateBaseURL, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { Experimental_EvaluationLanguageModel } from "@ai-sdk/provider-utils/experimental-evaluation";
|
|
3
2
|
import { APICallError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError, isJSONObject } from "@ai-sdk/provider";
|
|
4
3
|
import { z } from "zod/v4";
|
|
4
|
+
//#region src/openai-config.ts
|
|
5
|
+
function prepareOpenAIConfigForWorkflowDeserialize(config) {
|
|
6
|
+
if (config.provider == null) throw new Error("OpenAI model is missing provider after workflow deserialization.");
|
|
7
|
+
return {
|
|
8
|
+
...config,
|
|
9
|
+
provider: config.provider,
|
|
10
|
+
url: typeof config.url === "function" ? config.url : ({ path }) => {
|
|
11
|
+
if (config.baseURL == null) throw new Error("OpenAI model is missing baseURL after workflow deserialization.");
|
|
12
|
+
return `${config.baseURL}${path}`;
|
|
13
|
+
},
|
|
14
|
+
headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
5
18
|
//#region src/openai-error.ts
|
|
6
19
|
const openaiErrorDataSchema = z.object({ error: z.object({
|
|
7
20
|
message: z.string(),
|
|
@@ -14,6 +27,197 @@ const openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
14
27
|
errorToMessage: (data) => data.error.message
|
|
15
28
|
});
|
|
16
29
|
//#endregion
|
|
30
|
+
//#region src/openai-decision-model-options.ts
|
|
31
|
+
const openaiDecisionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
32
|
+
/** An opaque end-user identifier for safety monitoring, up to 128 characters. */
|
|
33
|
+
safetyIdentifier: z.string().max(128).optional() })));
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/openai-decision-model.ts
|
|
36
|
+
const probability = z.number().min(0).max(1);
|
|
37
|
+
const responseSchema = z.object({
|
|
38
|
+
model: z.string().nullish(),
|
|
39
|
+
usage: z.object({
|
|
40
|
+
input_tokens: z.number().nullish(),
|
|
41
|
+
input_tokens_details: z.object({
|
|
42
|
+
cached_tokens: z.number().nullish(),
|
|
43
|
+
cache_write_tokens: z.number().nullish()
|
|
44
|
+
}).nullish(),
|
|
45
|
+
output_tokens: z.number().nullish(),
|
|
46
|
+
output_tokens_details: z.object({ reasoning_tokens: z.number().nullish() }).nullish(),
|
|
47
|
+
total_tokens: z.number().nullish()
|
|
48
|
+
}).nullish(),
|
|
49
|
+
answers: z.array(z.discriminatedUnion("type", [
|
|
50
|
+
z.object({
|
|
51
|
+
type: z.literal("refusal"),
|
|
52
|
+
name: z.string().nullable()
|
|
53
|
+
}),
|
|
54
|
+
z.object({
|
|
55
|
+
type: z.literal("predicate"),
|
|
56
|
+
name: z.string(),
|
|
57
|
+
probability
|
|
58
|
+
}),
|
|
59
|
+
z.object({
|
|
60
|
+
type: z.literal("choice"),
|
|
61
|
+
name: z.string(),
|
|
62
|
+
choice: z.string(),
|
|
63
|
+
confidence: probability.nullish(),
|
|
64
|
+
probabilities: z.array(z.object({
|
|
65
|
+
value: z.string(),
|
|
66
|
+
probability
|
|
67
|
+
}))
|
|
68
|
+
}),
|
|
69
|
+
z.object({
|
|
70
|
+
type: z.literal("score"),
|
|
71
|
+
name: z.string(),
|
|
72
|
+
score: z.number(),
|
|
73
|
+
confidence: probability.nullish(),
|
|
74
|
+
probabilities: z.array(z.object({
|
|
75
|
+
value: z.number().int().nonnegative(),
|
|
76
|
+
probability
|
|
77
|
+
}))
|
|
78
|
+
})
|
|
79
|
+
]))
|
|
80
|
+
});
|
|
81
|
+
function toText(input) {
|
|
82
|
+
return typeof input === "string" ? input : JSON.stringify(input);
|
|
83
|
+
}
|
|
84
|
+
var DecisionOpenAIModel = class DecisionOpenAIModel {
|
|
85
|
+
constructor(modelId, config) {
|
|
86
|
+
this.modelId = modelId;
|
|
87
|
+
this.config = config;
|
|
88
|
+
this.specificationVersion = "v4";
|
|
89
|
+
this.supportedQuestionTypes = [
|
|
90
|
+
"choice",
|
|
91
|
+
"score",
|
|
92
|
+
"boolean"
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
get provider() {
|
|
96
|
+
return this.config.provider;
|
|
97
|
+
}
|
|
98
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
99
|
+
return serializeModelOptions({
|
|
100
|
+
modelId: model.modelId,
|
|
101
|
+
config: model.config
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
105
|
+
return new DecisionOpenAIModel(options.modelId, prepareOpenAIConfigForWorkflowDeserialize(options.config));
|
|
106
|
+
}
|
|
107
|
+
/** @deprecated Use `doDecide` instead. */
|
|
108
|
+
doEvaluate(options) {
|
|
109
|
+
return this.doDecide(options);
|
|
110
|
+
}
|
|
111
|
+
async doDecide({ state, questions, headers, abortSignal, providerOptions }) {
|
|
112
|
+
const openaiOptions = await parseProviderOptions({
|
|
113
|
+
provider: "openai",
|
|
114
|
+
providerOptions,
|
|
115
|
+
schema: openaiDecisionModelOptions
|
|
116
|
+
});
|
|
117
|
+
const { value: response, rawValue, responseHeaders } = await postJsonToApi({
|
|
118
|
+
url: this.config.url({
|
|
119
|
+
path: "/decisions",
|
|
120
|
+
modelId: this.modelId
|
|
121
|
+
}),
|
|
122
|
+
headers: combineHeaders(this.config.headers?.(), headers),
|
|
123
|
+
body: {
|
|
124
|
+
model: this.modelId,
|
|
125
|
+
safety_identifier: openaiOptions?.safetyIdentifier,
|
|
126
|
+
input: toText(state),
|
|
127
|
+
questions: Object.entries(questions).map(([name, question]) => {
|
|
128
|
+
const instructions = toText(question.instructions);
|
|
129
|
+
switch (question.type) {
|
|
130
|
+
case "boolean": return {
|
|
131
|
+
type: "predicate",
|
|
132
|
+
name,
|
|
133
|
+
instructions: [
|
|
134
|
+
instructions,
|
|
135
|
+
question.criteria?.true == null ? void 0 : `Criteria for true:\n${toText(question.criteria.true)}`,
|
|
136
|
+
question.criteria?.false == null ? void 0 : `Criteria for false:\n${toText(question.criteria.false)}`
|
|
137
|
+
].filter((part) => part !== void 0).join("\n\n")
|
|
138
|
+
};
|
|
139
|
+
case "choice": return {
|
|
140
|
+
type: "choice",
|
|
141
|
+
name,
|
|
142
|
+
instructions,
|
|
143
|
+
choices: Object.entries(question.criteria).map(([value, description]) => ({
|
|
144
|
+
value,
|
|
145
|
+
...description == null ? {} : { description: toText(description) }
|
|
146
|
+
}))
|
|
147
|
+
};
|
|
148
|
+
case "score": return {
|
|
149
|
+
type: "score",
|
|
150
|
+
name,
|
|
151
|
+
instructions,
|
|
152
|
+
levels: question.criteria.map((description, index) => ({
|
|
153
|
+
label: String(index),
|
|
154
|
+
...description == null ? {} : { description: toText(description) }
|
|
155
|
+
}))
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
abortSignal,
|
|
161
|
+
fetch: this.config.fetch,
|
|
162
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
163
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema)
|
|
164
|
+
});
|
|
165
|
+
const answers = Object.fromEntries(response.answers.map((answer) => {
|
|
166
|
+
if (answer.type === "refusal") throw new InvalidResponseDataError({
|
|
167
|
+
data: rawValue,
|
|
168
|
+
message: answer.name === null ? "OpenAI Decisions refused an unnamed question." : `OpenAI Decisions refused question ${JSON.stringify(answer.name)}.`
|
|
169
|
+
});
|
|
170
|
+
if (answer.type === "predicate") return [answer.name, {
|
|
171
|
+
type: "boolean",
|
|
172
|
+
probability: answer.probability
|
|
173
|
+
}];
|
|
174
|
+
const probabilities = Object.fromEntries(answer.probabilities.map(({ value, probability }) => [value, probability]));
|
|
175
|
+
if (Object.keys(probabilities).length !== answer.probabilities.length) throw new InvalidResponseDataError({
|
|
176
|
+
data: rawValue,
|
|
177
|
+
message: "Decisions returned duplicate probability values."
|
|
178
|
+
});
|
|
179
|
+
return [answer.name, answer.type === "choice" ? {
|
|
180
|
+
type: "choice",
|
|
181
|
+
choice: answer.choice,
|
|
182
|
+
probabilities
|
|
183
|
+
} : {
|
|
184
|
+
type: "score",
|
|
185
|
+
score: answer.score,
|
|
186
|
+
probabilities
|
|
187
|
+
}];
|
|
188
|
+
}));
|
|
189
|
+
const names = response.answers.map((answer) => answer.name);
|
|
190
|
+
if (names.length !== Object.keys(questions).length || new Set(names).size !== names.length || names.some((name) => typeof name !== "string" || !Object.prototype.hasOwnProperty.call(questions, name))) throw new InvalidResponseDataError({
|
|
191
|
+
data: rawValue,
|
|
192
|
+
message: "Decisions must return exactly one answer for every question."
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
answers,
|
|
196
|
+
usage: response.usage == null ? void 0 : {
|
|
197
|
+
inputTokens: response.usage.input_tokens ?? void 0,
|
|
198
|
+
outputTokens: response.usage.output_tokens ?? void 0
|
|
199
|
+
},
|
|
200
|
+
rounding: {
|
|
201
|
+
probabilityDecimals: 2,
|
|
202
|
+
scoreDecimals: 2
|
|
203
|
+
},
|
|
204
|
+
warnings: Object.keys(providerOptions?.openai ?? {}).filter((option) => option !== "safetyIdentifier").map((option) => ({
|
|
205
|
+
type: "unsupported",
|
|
206
|
+
feature: `providerOptions.openai.${option}`
|
|
207
|
+
})),
|
|
208
|
+
providerMetadata: { openai: {
|
|
209
|
+
...response.usage == null ? {} : { usage: response.usage },
|
|
210
|
+
confidence: Object.fromEntries(response.answers.flatMap((answer) => (answer.type === "choice" || answer.type === "score") && answer.confidence != null ? [[answer.name, answer.confidence]] : []))
|
|
211
|
+
} },
|
|
212
|
+
response: {
|
|
213
|
+
modelId: response.model ?? this.modelId,
|
|
214
|
+
headers: responseHeaders,
|
|
215
|
+
body: rawValue
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
//#endregion
|
|
17
221
|
//#region src/openai-language-model-capabilities.ts
|
|
18
222
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
19
223
|
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
@@ -947,6 +1151,11 @@ var OpenAIChatLanguageModel = class OpenAIChatLanguageModel {
|
|
|
947
1151
|
type: "unsupported",
|
|
948
1152
|
feature: "topK"
|
|
949
1153
|
});
|
|
1154
|
+
if (providerOptions?.openai?.reasoningSummary != null) warnings.push({
|
|
1155
|
+
type: "unsupported",
|
|
1156
|
+
feature: "reasoningSummary",
|
|
1157
|
+
details: "reasoningSummary is only supported by the Responses API, not the Chat Completions API"
|
|
1158
|
+
});
|
|
950
1159
|
const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages({
|
|
951
1160
|
prompt,
|
|
952
1161
|
systemMessageMode: openaiOptions.systemMessageMode ?? (isReasoningModel ? "developer" : modelCapabilities.systemMessageMode)
|
|
@@ -4011,20 +4220,6 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4011
4220
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
4012
4221
|
usage: openaiResponsesUsageSchema.nullish()
|
|
4013
4222
|
})));
|
|
4014
|
-
//#endregion
|
|
4015
|
-
//#region src/openai-config.ts
|
|
4016
|
-
function prepareOpenAIConfigForWorkflowDeserialize(config) {
|
|
4017
|
-
if (config.provider == null) throw new Error("OpenAI model is missing provider after workflow deserialization.");
|
|
4018
|
-
return {
|
|
4019
|
-
...config,
|
|
4020
|
-
provider: config.provider,
|
|
4021
|
-
url: typeof config.url === "function" ? config.url : ({ path }) => {
|
|
4022
|
-
if (config.baseURL == null) throw new Error("OpenAI model is missing baseURL after workflow deserialization.");
|
|
4023
|
-
return `${config.baseURL}${path}`;
|
|
4024
|
-
},
|
|
4025
|
-
headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
|
|
4026
|
-
};
|
|
4027
|
-
}
|
|
4028
4223
|
const openaiLanguageModelResponsesOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
4029
4224
|
/**
|
|
4030
4225
|
* The ID of the OpenAI Conversation to continue.
|
|
@@ -7879,7 +8074,7 @@ var OpenAIBatch = class {
|
|
|
7879
8074
|
url: this.getUrl(`/files/${encodeURIComponent(fileId)}/content`),
|
|
7880
8075
|
headers: combineHeaders(this.options.config.headers?.(), options.headers),
|
|
7881
8076
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
7882
|
-
successfulResponseHandler: createJsonLinesResponseHandler(openaiBatchResultLineSchema),
|
|
8077
|
+
successfulResponseHandler: createJsonLinesResponseHandler(openaiBatchResultLineSchema, { maxLineBytes: this.options.maxLineBytes }),
|
|
7883
8078
|
abortSignal: options.abortSignal,
|
|
7884
8079
|
fetch: this.options.config.fetch,
|
|
7885
8080
|
validateUrl: false
|
|
@@ -9840,7 +10035,7 @@ var OpenAISkills = class {
|
|
|
9840
10035
|
};
|
|
9841
10036
|
//#endregion
|
|
9842
10037
|
//#region src/version.ts
|
|
9843
|
-
const VERSION = "4.0.
|
|
10038
|
+
const VERSION = "4.0.85";
|
|
9844
10039
|
//#endregion
|
|
9845
10040
|
//#region src/openai-provider.ts
|
|
9846
10041
|
/**
|
|
@@ -9934,6 +10129,7 @@ function createOpenAI(options = {}) {
|
|
|
9934
10129
|
};
|
|
9935
10130
|
const createBatch = () => new OpenAIBatch({
|
|
9936
10131
|
provider: `${providerName}.batch`,
|
|
10132
|
+
maxLineBytes: options.batchResultDownloads?.maxLineBytes,
|
|
9937
10133
|
config: {
|
|
9938
10134
|
provider: `${providerName}.responses`,
|
|
9939
10135
|
baseURL,
|
|
@@ -9951,10 +10147,14 @@ function createOpenAI(options = {}) {
|
|
|
9951
10147
|
provider.chat = createChatModel;
|
|
9952
10148
|
provider.completion = createCompletionModel;
|
|
9953
10149
|
provider.responses = createResponsesModel;
|
|
9954
|
-
provider.
|
|
9955
|
-
|
|
9956
|
-
|
|
10150
|
+
provider.decisionModel = (modelId) => new DecisionOpenAIModel(modelId, {
|
|
10151
|
+
baseURL,
|
|
10152
|
+
url: ({ path }) => `${baseURL}${path}`,
|
|
10153
|
+
headers: getHeaders,
|
|
10154
|
+
fetch: options.fetch,
|
|
10155
|
+
provider: `${providerName}.decision`
|
|
9957
10156
|
});
|
|
10157
|
+
provider.evaluationModel = provider.decisionModel;
|
|
9958
10158
|
provider.embedding = createEmbeddingModel;
|
|
9959
10159
|
provider.embeddingModel = createEmbeddingModel;
|
|
9960
10160
|
provider.textEmbedding = createEmbeddingModel;
|