@ai-sdk/openai 4.0.60 → 4.0.62
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 +45 -10
- package/dist/index.js +204 -137
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +38 -9
- package/dist/internal/index.js +113 -49
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +96 -10
- package/package.json +3 -3
- package/src/image/openai-image-model-options.ts +3 -2
- package/src/index.ts +1 -0
- package/src/{openai-responses-batch.ts → openai-batch.ts} +71 -87
- package/src/openai-language-model-capabilities.ts +2 -0
- package/src/openai-provider.ts +27 -6
- package/src/openai-tools.ts +2 -1
- package/src/responses/convert-to-openai-responses-input.ts +13 -0
- package/src/responses/openai-responses-api.ts +11 -1
- package/src/responses/openai-responses-language-model.ts +65 -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/src/tool/image-generation.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8487955: Add `xhigh` and `max` quality support for GPT Image 2.5 Flare and Sunburst in image generation, image editing, and the Responses API image generation tool.
|
|
8
|
+
|
|
9
|
+
## 4.0.61
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a4ba394: feat: support per-request models in batch
|
|
14
|
+
- 4a09793: feat(openai): add async tool calling
|
|
15
|
+
- 685ed8c: chore: fix failing CI
|
|
16
|
+
- Updated dependencies [a4ba394]
|
|
17
|
+
- Updated dependencies [45099da]
|
|
18
|
+
- Updated dependencies [9e1d1b2]
|
|
19
|
+
- Updated dependencies [a495511]
|
|
20
|
+
- @ai-sdk/provider@4.0.11
|
|
21
|
+
- @ai-sdk/provider-utils@5.0.37
|
|
22
|
+
|
|
3
23
|
## 4.0.60
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { JSONValue, ProviderV4,
|
|
2
|
+
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, Experimental_SpeechTranslationModelV4, SpeechModelV4, Experimental_RealtimeFactoryV4, FilesV4, SkillsV4, Experimental_BatchV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig, JSONObject, Experimental_SpeechTranslationModelV4StreamOptions } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { InferSchema, FetchFunction, WebSocketConstructor, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -49,7 +49,7 @@ type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOption
|
|
|
49
49
|
|
|
50
50
|
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
|
|
51
51
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
52
|
-
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
52
|
+
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
53
53
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
54
54
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
55
55
|
outputCompression?: number | undefined;
|
|
@@ -57,7 +57,7 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
57
57
|
}>;
|
|
58
58
|
type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
|
|
59
59
|
declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
60
|
-
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
60
|
+
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
61
61
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
62
62
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
63
63
|
outputCompression?: number | undefined;
|
|
@@ -67,7 +67,7 @@ declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySche
|
|
|
67
67
|
}>;
|
|
68
68
|
type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
|
|
69
69
|
declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
70
|
-
quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
|
|
70
|
+
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
71
71
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
72
72
|
outputFormat?: "png" | "jpeg" | "webp" | undefined;
|
|
73
73
|
outputCompression?: number | undefined;
|
|
@@ -443,6 +443,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
443
443
|
call_id: string;
|
|
444
444
|
name: string;
|
|
445
445
|
arguments: string;
|
|
446
|
+
async?: boolean | null | undefined;
|
|
446
447
|
namespace?: string | null | undefined;
|
|
447
448
|
caller?: {
|
|
448
449
|
type: "direct";
|
|
@@ -519,6 +520,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
519
520
|
call_id: string;
|
|
520
521
|
name: string;
|
|
521
522
|
input: string;
|
|
523
|
+
async?: boolean | null | undefined;
|
|
522
524
|
} | {
|
|
523
525
|
type: "shell_call";
|
|
524
526
|
id: string;
|
|
@@ -695,6 +697,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
695
697
|
name: string;
|
|
696
698
|
arguments: string;
|
|
697
699
|
status: "completed" | "in_progress" | "incomplete";
|
|
700
|
+
async?: boolean | null | undefined;
|
|
698
701
|
namespace?: string | null | undefined;
|
|
699
702
|
caller?: {
|
|
700
703
|
type: "direct";
|
|
@@ -709,6 +712,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
709
712
|
name: string;
|
|
710
713
|
input: string;
|
|
711
714
|
status: "completed";
|
|
715
|
+
async?: boolean | null | undefined;
|
|
712
716
|
} | {
|
|
713
717
|
type: "code_interpreter_call";
|
|
714
718
|
id: string;
|
|
@@ -949,6 +953,11 @@ declare const customToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFacto
|
|
|
949
953
|
* An optional description of what the tool does.
|
|
950
954
|
*/
|
|
951
955
|
description?: string;
|
|
956
|
+
/**
|
|
957
|
+
* Whether the model can continue generating after calling this tool
|
|
958
|
+
* without waiting for its result.
|
|
959
|
+
*/
|
|
960
|
+
async?: boolean;
|
|
952
961
|
/**
|
|
953
962
|
* The output format specification for the tool.
|
|
954
963
|
* Omit for unconstrained text output.
|
|
@@ -1014,6 +1023,7 @@ declare const openaiTools: {
|
|
|
1014
1023
|
* `input` field is a string matching the specified grammar.
|
|
1015
1024
|
*
|
|
1016
1025
|
* @param description - An optional description of the tool.
|
|
1026
|
+
* @param async - Whether the model can continue without waiting for the tool result.
|
|
1017
1027
|
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
1018
1028
|
*/
|
|
1019
1029
|
customTool: (args: Parameters<typeof customToolFactory>[0]) => _ai_sdk_provider_utils.ProviderDefinedTool<string, unknown, {}>;
|
|
@@ -1124,7 +1134,7 @@ declare const openaiTools: {
|
|
|
1124
1134
|
* @param outputCompression - Compression level for the output image (0-100).
|
|
1125
1135
|
* @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
|
|
1126
1136
|
* @param partialImages - Number of partial images to generate in streaming mode (0-3).
|
|
1127
|
-
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or '
|
|
1137
|
+
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', 'high', 'xhigh', or 'max'. 'xhigh' and 'max' require a GPT Image 2.5 model.
|
|
1128
1138
|
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
1129
1139
|
*/
|
|
1130
1140
|
imageGeneration: (args?: {
|
|
@@ -1140,7 +1150,7 @@ declare const openaiTools: {
|
|
|
1140
1150
|
outputCompression?: number;
|
|
1141
1151
|
outputFormat?: "png" | "jpeg" | "webp";
|
|
1142
1152
|
partialImages?: number;
|
|
1143
|
-
quality?: "auto" | "low" | "medium" | "high";
|
|
1153
|
+
quality?: "auto" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
1144
1154
|
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | (string & {});
|
|
1145
1155
|
}) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
1146
1156
|
result: string;
|
|
@@ -1441,11 +1451,11 @@ declare const openAISpeechTranslationModelOptions: _ai_sdk_provider_utils.LazySc
|
|
|
1441
1451
|
type OpenAISpeechTranslationModelOptions = InferSchema<typeof openAISpeechTranslationModelOptions>;
|
|
1442
1452
|
|
|
1443
1453
|
interface OpenAIProvider extends ProviderV4 {
|
|
1444
|
-
(modelId: OpenAIResponsesModelId):
|
|
1454
|
+
(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
1445
1455
|
/**
|
|
1446
1456
|
* Creates an OpenAI model for text generation.
|
|
1447
1457
|
*/
|
|
1448
|
-
languageModel(modelId: OpenAIResponsesModelId):
|
|
1458
|
+
languageModel(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
1449
1459
|
/**
|
|
1450
1460
|
* Creates an OpenAI chat model for text generation.
|
|
1451
1461
|
*/
|
|
@@ -1453,7 +1463,7 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1453
1463
|
/**
|
|
1454
1464
|
* Creates an OpenAI responses API model for text generation.
|
|
1455
1465
|
*/
|
|
1456
|
-
responses(modelId: OpenAIResponsesModelId):
|
|
1466
|
+
responses(modelId: OpenAIResponsesModelId): LanguageModelV4;
|
|
1457
1467
|
/**
|
|
1458
1468
|
* Creates an OpenAI completion model for text generation.
|
|
1459
1469
|
*/
|
|
@@ -1511,6 +1521,12 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1511
1521
|
* Returns a SkillsV4 interface for uploading skills to OpenAI.
|
|
1512
1522
|
*/
|
|
1513
1523
|
skills(): SkillsV4;
|
|
1524
|
+
/**
|
|
1525
|
+
* Returns a BatchV4 interface for processing batches with OpenAI.
|
|
1526
|
+
*/
|
|
1527
|
+
experimental_batch(): Experimental_BatchV4<{
|
|
1528
|
+
text: OpenAIResponsesModelId;
|
|
1529
|
+
}>;
|
|
1514
1530
|
/**
|
|
1515
1531
|
* OpenAI-specific tools.
|
|
1516
1532
|
*/
|
|
@@ -1588,6 +1604,11 @@ declare class OpenAIRealtimeModel implements Experimental_RealtimeModelV4 {
|
|
|
1588
1604
|
|
|
1589
1605
|
type OpenAIToolOptions = {
|
|
1590
1606
|
allowedCallers?: Array<'direct' | 'programmatic'>;
|
|
1607
|
+
/**
|
|
1608
|
+
* Whether the model can continue generating after calling this tool without
|
|
1609
|
+
* waiting for its result.
|
|
1610
|
+
*/
|
|
1611
|
+
async?: boolean;
|
|
1591
1612
|
deferLoading?: boolean;
|
|
1592
1613
|
outputSchema?: JSONObject;
|
|
1593
1614
|
namespace?: {
|
|
@@ -1722,6 +1743,20 @@ type OpenaiResponsesReasoningProviderMetadata = {
|
|
|
1722
1743
|
type OpenaiResponsesProviderMetadata = {
|
|
1723
1744
|
openai: ResponsesProviderMetadata;
|
|
1724
1745
|
};
|
|
1746
|
+
type ResponsesToolCallProviderMetadata = {
|
|
1747
|
+
itemId: string;
|
|
1748
|
+
async?: boolean;
|
|
1749
|
+
namespace?: string;
|
|
1750
|
+
caller?: {
|
|
1751
|
+
type: 'direct';
|
|
1752
|
+
} | {
|
|
1753
|
+
type: 'program';
|
|
1754
|
+
callerId: string;
|
|
1755
|
+
};
|
|
1756
|
+
};
|
|
1757
|
+
type OpenaiResponsesToolCallProviderMetadata = {
|
|
1758
|
+
openai: ResponsesToolCallProviderMetadata;
|
|
1759
|
+
};
|
|
1725
1760
|
type ResponsesCompactionProviderMetadata = {
|
|
1726
1761
|
type: 'compaction';
|
|
1727
1762
|
itemId: string;
|
|
@@ -1757,4 +1792,4 @@ type OpenaiResponsesSourceDocumentProviderMetadata = {
|
|
|
1757
1792
|
|
|
1758
1793
|
declare const VERSION: string;
|
|
1759
1794
|
|
|
1760
|
-
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAISpeechTranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAISpeechTranslationModelOptions, OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAITranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAITranslationModelOptions, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIComputerAction, type OpenAIComputerSafetyCheck, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAIToolOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };
|
|
1795
|
+
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAISpeechTranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAISpeechTranslationModelOptions, OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAITranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAITranslationModelOptions, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIComputerAction, type OpenAIComputerSafetyCheck, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAIToolOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, VERSION, createOpenAI, openai };
|