@ai-sdk/openai 4.0.35 → 4.0.37
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 +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +24 -11
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +6 -2
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model-options.ts +4 -1
- package/src/chat/openai-chat-language-model.ts +2 -1
- package/src/responses/convert-to-openai-responses-input.ts +13 -3
- package/src/responses/openai-responses-language-model-options.ts +4 -1
- package/src/responses/openai-responses-language-model.ts +9 -1
- package/src/responses/openai-responses-prepare-tools.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [401a4ba]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.26
|
|
9
|
+
|
|
10
|
+
## 4.0.36
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6157098: fix(openai): serialize tool text outputs when an output schema is configured
|
|
15
|
+
- 4cd4548: Accept `serviceTier: 'fast'` on OpenAI chat and responses models. OpenAI renamed priority processing to Fast mode and accepts `service_tier: 'fast'` and `'priority'` interchangeably, so `'fast'` is now passed through verbatim and gated on the same model capability as `'priority'`.
|
|
16
|
+
- Updated dependencies [ad6a650]
|
|
17
|
+
- Updated dependencies [81cd026]
|
|
18
|
+
- @ai-sdk/provider@4.0.7
|
|
19
|
+
- @ai-sdk/provider-utils@5.0.25
|
|
20
|
+
|
|
3
21
|
## 4.0.35
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
|
|
|
15
15
|
store?: boolean | undefined;
|
|
16
16
|
metadata?: Record<string, string> | undefined;
|
|
17
17
|
prediction?: Record<string, any> | undefined;
|
|
18
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
18
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
|
|
19
19
|
strictJsonSchema?: boolean | undefined;
|
|
20
20
|
textVerbosity?: "low" | "medium" | "high" | undefined;
|
|
21
21
|
promptCacheKey?: string | undefined;
|
|
@@ -1366,7 +1366,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1366
1366
|
reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
|
|
1367
1367
|
reasoningSummary?: string | null | undefined;
|
|
1368
1368
|
safetyIdentifier?: string | null | undefined;
|
|
1369
|
-
serviceTier?: "default" | "auto" | "flex" | "priority" | null | undefined;
|
|
1369
|
+
serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
|
|
1370
1370
|
store?: boolean | null | undefined;
|
|
1371
1371
|
passThroughUnsupportedFiles?: boolean | undefined;
|
|
1372
1372
|
strictJsonSchema?: boolean | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -808,11 +808,12 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
808
808
|
* Project settings. Unless otherwise configured, the Project will use 'default'.
|
|
809
809
|
* - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
810
810
|
* - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
|
|
811
|
+
* - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
|
|
811
812
|
* - 'default': The request will be processed with the standard pricing and performance for the selected model.
|
|
812
813
|
*
|
|
813
814
|
* @default 'auto'
|
|
814
815
|
*/
|
|
815
|
-
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
816
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
816
817
|
/**
|
|
817
818
|
* Whether to use strict JSON schema validation.
|
|
818
819
|
*
|
|
@@ -1125,7 +1126,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
1125
1126
|
});
|
|
1126
1127
|
baseArgs.service_tier = void 0;
|
|
1127
1128
|
}
|
|
1128
|
-
if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
1129
|
+
if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
1129
1130
|
warnings.push({
|
|
1130
1131
|
type: "unsupported",
|
|
1131
1132
|
feature: "serviceTier",
|
|
@@ -4447,7 +4448,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
4447
4448
|
hasShellTool = false,
|
|
4448
4449
|
hasApplyPatchTool = false,
|
|
4449
4450
|
hasComputerTool = false,
|
|
4450
|
-
customProviderToolNames
|
|
4451
|
+
customProviderToolNames,
|
|
4452
|
+
outputSchemaToolNames
|
|
4451
4453
|
}) {
|
|
4452
4454
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
|
|
4453
4455
|
let input = [];
|
|
@@ -5211,14 +5213,17 @@ async function convertToOpenAIResponsesInput({
|
|
|
5211
5213
|
continue;
|
|
5212
5214
|
}
|
|
5213
5215
|
let contentValue;
|
|
5216
|
+
const hasOutputSchema = outputSchemaToolNames == null ? void 0 : outputSchemaToolNames.has(part.toolName);
|
|
5214
5217
|
switch (output.type) {
|
|
5215
5218
|
case "text":
|
|
5216
5219
|
case "error-text":
|
|
5217
|
-
contentValue = output.value;
|
|
5220
|
+
contentValue = hasOutputSchema ? JSON.stringify(output.value) : output.value;
|
|
5218
5221
|
break;
|
|
5219
|
-
case "execution-denied":
|
|
5220
|
-
|
|
5222
|
+
case "execution-denied": {
|
|
5223
|
+
const reason = (_J = output.reason) != null ? _J : "Tool call execution denied.";
|
|
5224
|
+
contentValue = hasOutputSchema ? JSON.stringify(reason) : reason;
|
|
5221
5225
|
break;
|
|
5226
|
+
}
|
|
5222
5227
|
case "json":
|
|
5223
5228
|
case "error-json":
|
|
5224
5229
|
contentValue = JSON.stringify(output.value);
|
|
@@ -5534,10 +5539,11 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
|
|
|
5534
5539
|
* Service tier for the request.
|
|
5535
5540
|
* Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
|
|
5536
5541
|
* Set to 'priority' for faster processing with Enterprise access (available for gpt-4, gpt-5, gpt-5-mini, o3, o4-mini; gpt-5-nano is not supported).
|
|
5542
|
+
* Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
|
|
5537
5543
|
*
|
|
5538
5544
|
* Defaults to 'auto'.
|
|
5539
5545
|
*/
|
|
5540
|
-
serviceTier: z27.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
5546
|
+
serviceTier: z27.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
5541
5547
|
/**
|
|
5542
5548
|
* Whether to store the generation. Defaults to `true`.
|
|
5543
5549
|
*/
|
|
@@ -5632,7 +5638,8 @@ async function prepareResponsesTools({
|
|
|
5632
5638
|
toolChoice,
|
|
5633
5639
|
allowedTools,
|
|
5634
5640
|
toolNameMapping,
|
|
5635
|
-
customProviderToolNames
|
|
5641
|
+
customProviderToolNames,
|
|
5642
|
+
outputSchemaToolNames
|
|
5636
5643
|
}) {
|
|
5637
5644
|
var _a, _b, _c;
|
|
5638
5645
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -5647,6 +5654,9 @@ async function prepareResponsesTools({
|
|
|
5647
5654
|
switch (tool.type) {
|
|
5648
5655
|
case "function": {
|
|
5649
5656
|
const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
|
|
5657
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.outputSchema) != null) {
|
|
5658
|
+
outputSchemaToolNames == null ? void 0 : outputSchemaToolNames.add(tool.name);
|
|
5659
|
+
}
|
|
5650
5660
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5651
5661
|
tool,
|
|
5652
5662
|
options: openaiOptions
|
|
@@ -6149,6 +6159,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6149
6159
|
}
|
|
6150
6160
|
});
|
|
6151
6161
|
const customProviderToolNames = /* @__PURE__ */ new Set();
|
|
6162
|
+
const outputSchemaToolNames = /* @__PURE__ */ new Set();
|
|
6152
6163
|
const {
|
|
6153
6164
|
tools: openaiTools2,
|
|
6154
6165
|
toolChoice: openaiToolChoice,
|
|
@@ -6158,7 +6169,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6158
6169
|
toolChoice,
|
|
6159
6170
|
allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
|
|
6160
6171
|
toolNameMapping,
|
|
6161
|
-
customProviderToolNames
|
|
6172
|
+
customProviderToolNames,
|
|
6173
|
+
outputSchemaToolNames
|
|
6162
6174
|
});
|
|
6163
6175
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
6164
6176
|
prompt,
|
|
@@ -6174,7 +6186,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6174
6186
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
6175
6187
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
6176
6188
|
hasComputerTool: hasOpenAITool("openai.computer"),
|
|
6177
|
-
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
6189
|
+
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0,
|
|
6190
|
+
outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
|
|
6178
6191
|
});
|
|
6179
6192
|
warnings.push(...inputWarnings);
|
|
6180
6193
|
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
@@ -6327,7 +6340,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6327
6340
|
});
|
|
6328
6341
|
delete baseArgs.service_tier;
|
|
6329
6342
|
}
|
|
6330
|
-
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
6343
|
+
if (((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
6331
6344
|
warnings.push({
|
|
6332
6345
|
type: "unsupported",
|
|
6333
6346
|
feature: "serviceTier",
|
|
@@ -10008,7 +10021,7 @@ var OpenAISkills = class {
|
|
|
10008
10021
|
};
|
|
10009
10022
|
|
|
10010
10023
|
// src/version.ts
|
|
10011
|
-
var VERSION = true ? "4.0.
|
|
10024
|
+
var VERSION = true ? "4.0.37" : "0.0.0-test";
|
|
10012
10025
|
|
|
10013
10026
|
// src/openai-provider.ts
|
|
10014
10027
|
function createOpenAI(options = {}) {
|