@ai-sdk/openai 4.0.59 → 4.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/index.d.ts +47 -11
- package/dist/index.js +278 -138
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +45 -11
- package/dist/internal/index.js +188 -51
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +138 -10
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +29 -1
- package/src/index.ts +1 -0
- package/src/{openai-responses-batch.ts → openai-batch.ts} +71 -87
- package/src/openai-language-model-capabilities.ts +10 -0
- package/src/openai-provider.ts +27 -6
- package/src/openai-tools.ts +1 -0
- package/src/responses/convert-to-openai-responses-input.ts +13 -0
- package/src/responses/openai-responses-api.ts +18 -0
- package/src/responses/openai-responses-language-model-options.ts +12 -0
- package/src/responses/openai-responses-language-model.ts +137 -29
- package/src/responses/openai-responses-prepare-tools.ts +47 -0
- package/src/responses/openai-responses-provider-metadata.ts +16 -0
- package/src/tool/custom.ts +7 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
|
|
|
10
10
|
logprobs?: number | boolean | undefined;
|
|
11
11
|
parallelToolCalls?: boolean | undefined;
|
|
12
12
|
user?: string | undefined;
|
|
13
|
-
reasoningEffort?: "
|
|
13
|
+
reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
|
|
14
14
|
maxCompletionTokens?: number | undefined;
|
|
15
15
|
store?: boolean | undefined;
|
|
16
16
|
metadata?: Record<string, string> | undefined;
|
|
@@ -160,7 +160,7 @@ declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
|
|
|
160
160
|
declare function hasDefaultResponseFormat(modelId: string): boolean;
|
|
161
161
|
declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
|
|
162
162
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
163
|
-
quality?: "
|
|
163
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
164
164
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
165
165
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
166
166
|
outputCompression?: number | undefined;
|
|
@@ -168,17 +168,17 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
168
168
|
}>;
|
|
169
169
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
170
170
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
171
|
-
quality?: "
|
|
171
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
172
172
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
173
173
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
174
174
|
outputCompression?: number | undefined;
|
|
175
175
|
user?: string | undefined;
|
|
176
176
|
style?: "vivid" | "natural" | undefined;
|
|
177
|
-
moderation?: "
|
|
177
|
+
moderation?: "low" | "auto" | undefined;
|
|
178
178
|
}>;
|
|
179
179
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
180
180
|
declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
181
|
-
quality?: "
|
|
181
|
+
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
182
182
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
183
183
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
184
184
|
outputCompression?: number | undefined;
|
|
@@ -225,7 +225,7 @@ declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema
|
|
|
225
225
|
silenceDurationMs?: number | undefined;
|
|
226
226
|
} | undefined;
|
|
227
227
|
streaming?: {
|
|
228
|
-
delay?: "
|
|
228
|
+
delay?: "low" | "medium" | "high" | "xhigh" | "minimal" | undefined;
|
|
229
229
|
include?: string[] | undefined;
|
|
230
230
|
} | undefined;
|
|
231
231
|
}>;
|
|
@@ -418,7 +418,7 @@ declare const openaiResponsesLocalShellCallSchema: z.ZodObject<{
|
|
|
418
418
|
}, z.core.$strip>;
|
|
419
419
|
}, z.core.$strip>;
|
|
420
420
|
type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
421
|
-
type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUserMessage | OpenAIResponsesAssistantMessage | OpenAIResponsesFunctionCall | OpenAIResponsesFunctionCallOutput | OpenAIResponsesProgram | OpenAIResponsesProgramOutput | OpenAIResponsesCustomToolCall | OpenAIResponsesCustomToolCallOutput | OpenAIResponsesMcpApprovalResponse | OpenAIResponsesComputerCall | OpenAIResponsesComputerCallOutput | OpenAIResponsesLocalShellCall | OpenAIResponsesLocalShellCallOutput | OpenAIResponsesShellCall | OpenAIResponsesShellCallOutput | OpenAIResponsesApplyPatchCall | OpenAIResponsesApplyPatchCallOutput | OpenAIResponsesToolSearchCall | OpenAIResponsesToolSearchOutput | OpenAIResponsesReasoning | OpenAIResponsesItemReference | OpenAIResponsesCompactionItem | OpenAIResponsesCompactionTrigger;
|
|
421
|
+
type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUserMessage | OpenAIResponsesAssistantMessage | OpenAIResponsesFunctionCall | OpenAIResponsesFunctionCallOutput | OpenAIResponsesProgram | OpenAIResponsesProgramOutput | OpenAIResponsesCustomToolCall | OpenAIResponsesCustomToolCallOutput | OpenAIResponsesMcpApprovalResponse | OpenAIResponsesComputerCall | OpenAIResponsesComputerCallOutput | OpenAIResponsesLocalShellCall | OpenAIResponsesLocalShellCallOutput | OpenAIResponsesShellCall | OpenAIResponsesShellCallOutput | OpenAIResponsesApplyPatchCall | OpenAIResponsesApplyPatchCallOutput | OpenAIResponsesToolSearchCall | OpenAIResponsesToolSearchOutput | OpenAIResponsesReasoning | OpenAIResponsesItemReference | OpenAIResponsesCompactionItem | OpenAIResponsesConfigurationUpdate | OpenAIResponsesCompactionTrigger;
|
|
422
422
|
type OpenAIResponsesIncludeValue = 'web_search_call.action.sources' | 'web_search_call.results' | 'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content';
|
|
423
423
|
type OpenAIResponsesIncludeOptions = Array<OpenAIResponsesIncludeValue> | undefined | null;
|
|
424
424
|
type OpenAIResponsesSystemMessage = {
|
|
@@ -486,6 +486,7 @@ type OpenAIResponsesFunctionCall = {
|
|
|
486
486
|
call_id: string;
|
|
487
487
|
name: string;
|
|
488
488
|
arguments: string;
|
|
489
|
+
async?: boolean;
|
|
489
490
|
id?: string;
|
|
490
491
|
namespace?: string;
|
|
491
492
|
caller?: OpenAIResponsesToolCaller;
|
|
@@ -547,6 +548,7 @@ type OpenAIResponsesCustomToolCall = {
|
|
|
547
548
|
call_id: string;
|
|
548
549
|
name: string;
|
|
549
550
|
input: string;
|
|
551
|
+
async?: boolean;
|
|
550
552
|
};
|
|
551
553
|
type OpenAIResponsesCustomToolCallOutput = {
|
|
552
554
|
type: 'custom_tool_call_output';
|
|
@@ -660,6 +662,12 @@ type OpenAIResponsesCompactionItem = {
|
|
|
660
662
|
id: string;
|
|
661
663
|
encrypted_content: string;
|
|
662
664
|
};
|
|
665
|
+
type OpenAIResponsesConfigurationUpdate = {
|
|
666
|
+
type: 'configuration_update';
|
|
667
|
+
reasoning: {
|
|
668
|
+
effort: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
669
|
+
};
|
|
670
|
+
};
|
|
663
671
|
type OpenAIResponsesCompactionTrigger = {
|
|
664
672
|
type: 'compaction_trigger';
|
|
665
673
|
};
|
|
@@ -698,6 +706,7 @@ type OpenAIResponsesFunctionTool = {
|
|
|
698
706
|
name: string;
|
|
699
707
|
description: string | undefined;
|
|
700
708
|
parameters: JSONSchema7;
|
|
709
|
+
async?: boolean;
|
|
701
710
|
strict?: boolean;
|
|
702
711
|
defer_loading?: boolean;
|
|
703
712
|
allowed_callers?: Array<'direct' | 'programmatic'>;
|
|
@@ -809,6 +818,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
|
|
|
809
818
|
type: 'custom';
|
|
810
819
|
name: string;
|
|
811
820
|
description?: string;
|
|
821
|
+
async?: boolean;
|
|
812
822
|
format?: {
|
|
813
823
|
type: 'grammar';
|
|
814
824
|
syntax: 'regex' | 'lark';
|
|
@@ -1102,6 +1112,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1102
1112
|
call_id: string;
|
|
1103
1113
|
name: string;
|
|
1104
1114
|
arguments: string;
|
|
1115
|
+
async?: boolean | null | undefined;
|
|
1105
1116
|
namespace?: string | null | undefined;
|
|
1106
1117
|
caller?: {
|
|
1107
1118
|
type: "direct";
|
|
@@ -1178,6 +1189,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1178
1189
|
call_id: string;
|
|
1179
1190
|
name: string;
|
|
1180
1191
|
input: string;
|
|
1192
|
+
async?: boolean | null | undefined;
|
|
1181
1193
|
} | {
|
|
1182
1194
|
type: "shell_call";
|
|
1183
1195
|
id: string;
|
|
@@ -1354,6 +1366,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1354
1366
|
name: string;
|
|
1355
1367
|
arguments: string;
|
|
1356
1368
|
status: "completed" | "in_progress" | "incomplete";
|
|
1369
|
+
async?: boolean | null | undefined;
|
|
1357
1370
|
namespace?: string | null | undefined;
|
|
1358
1371
|
caller?: {
|
|
1359
1372
|
type: "direct";
|
|
@@ -1368,6 +1381,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1368
1381
|
name: string;
|
|
1369
1382
|
input: string;
|
|
1370
1383
|
status: "completed";
|
|
1384
|
+
async?: boolean | null | undefined;
|
|
1371
1385
|
} | {
|
|
1372
1386
|
type: "code_interpreter_call";
|
|
1373
1387
|
id: string;
|
|
@@ -1812,6 +1826,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
|
|
|
1812
1826
|
|
|
1813
1827
|
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
1814
1828
|
|
|
1829
|
+
declare const openaiResponsesSupportedUrls: Record<string, RegExp[]>;
|
|
1815
1830
|
declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
1816
1831
|
readonly specificationVersion = "v4";
|
|
1817
1832
|
readonly modelId: OpenAIResponsesModelId;
|
|
@@ -1827,7 +1842,11 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1827
1842
|
constructor(modelId: OpenAIResponsesModelId, config: OpenAIConfig);
|
|
1828
1843
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
1829
1844
|
get provider(): string;
|
|
1830
|
-
|
|
1845
|
+
static prepareRequest({ modelId, config, options: { maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, reasoning, providerOptions, tools, toolChoice, responseFormat, }, }: {
|
|
1846
|
+
modelId: OpenAIResponsesModelId;
|
|
1847
|
+
config: OpenAIConfig;
|
|
1848
|
+
options: LanguageModelV4CallOptions;
|
|
1849
|
+
}): Promise<{
|
|
1831
1850
|
webSearchToolName: string | undefined;
|
|
1832
1851
|
args: {
|
|
1833
1852
|
tools: OpenAIResponsesTool[] | undefined;
|
|
@@ -1917,6 +1936,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1917
1936
|
providerOptionsName: string;
|
|
1918
1937
|
isShellProviderExecuted: boolean;
|
|
1919
1938
|
}>;
|
|
1939
|
+
private getArgs;
|
|
1920
1940
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
1921
1941
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
1922
1942
|
}
|
|
@@ -1942,6 +1962,20 @@ type OpenaiResponsesReasoningProviderMetadata = {
|
|
|
1942
1962
|
type OpenaiResponsesProviderMetadata = {
|
|
1943
1963
|
openai: ResponsesProviderMetadata;
|
|
1944
1964
|
};
|
|
1965
|
+
type ResponsesToolCallProviderMetadata = {
|
|
1966
|
+
itemId: string;
|
|
1967
|
+
async?: boolean;
|
|
1968
|
+
namespace?: string;
|
|
1969
|
+
caller?: {
|
|
1970
|
+
type: 'direct';
|
|
1971
|
+
} | {
|
|
1972
|
+
type: 'program';
|
|
1973
|
+
callerId: string;
|
|
1974
|
+
};
|
|
1975
|
+
};
|
|
1976
|
+
type OpenaiResponsesToolCallProviderMetadata = {
|
|
1977
|
+
openai: ResponsesToolCallProviderMetadata;
|
|
1978
|
+
};
|
|
1945
1979
|
type ResponsesCompactionProviderMetadata = {
|
|
1946
1980
|
type: 'compaction';
|
|
1947
1981
|
itemId: string;
|
|
@@ -2277,11 +2311,11 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
2277
2311
|
imageUrl?: string | undefined;
|
|
2278
2312
|
} | undefined;
|
|
2279
2313
|
model?: string | undefined;
|
|
2280
|
-
moderation?: "
|
|
2314
|
+
moderation?: "low" | "auto" | undefined;
|
|
2281
2315
|
outputCompression?: number | undefined;
|
|
2282
2316
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
2283
2317
|
partialImages?: number | undefined;
|
|
2284
|
-
quality?: "
|
|
2318
|
+
quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
2285
2319
|
size?: string | undefined;
|
|
2286
2320
|
}>;
|
|
2287
2321
|
declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
@@ -2466,4 +2500,4 @@ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderExecutedToolFacto
|
|
|
2466
2500
|
};
|
|
2467
2501
|
}, {}>;
|
|
2468
2502
|
|
|
2469
|
-
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|
|
2503
|
+
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, type ResponsesToolCallProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiResponsesSupportedUrls, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|