@ai-sdk/openai 4.0.34 → 4.0.36

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.
@@ -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;
@@ -1620,7 +1620,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1620
1620
  store: boolean | null | undefined;
1621
1621
  user: string | null | undefined;
1622
1622
  instructions: string | null | undefined;
1623
- service_tier: "default" | "auto" | "flex" | "priority" | null | undefined;
1623
+ service_tier: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
1624
1624
  include: OpenAIResponsesIncludeOptions;
1625
1625
  prompt_cache_key: string | null | undefined;
1626
1626
  prompt_cache_options: {
@@ -799,11 +799,12 @@ var openaiLanguageModelChatOptions = lazySchema2(
799
799
  * Project settings. Unless otherwise configured, the Project will use 'default'.
800
800
  * - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
801
801
  * - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
802
+ * - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
802
803
  * - 'default': The request will be processed with the standard pricing and performance for the selected model.
803
804
  *
804
805
  * @default 'auto'
805
806
  */
806
- serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
807
+ serviceTier: z3.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
807
808
  /**
808
809
  * Whether to use strict JSON schema validation.
809
810
  *
@@ -1116,7 +1117,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1116
1117
  });
1117
1118
  baseArgs.service_tier = void 0;
1118
1119
  }
1119
- if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
1120
+ if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
1120
1121
  warnings.push({
1121
1122
  type: "unsupported",
1122
1123
  feature: "serviceTier",
@@ -3466,7 +3467,8 @@ async function convertToOpenAIResponsesInput({
3466
3467
  hasShellTool = false,
3467
3468
  hasApplyPatchTool = false,
3468
3469
  hasComputerTool = false,
3469
- customProviderToolNames
3470
+ customProviderToolNames,
3471
+ outputSchemaToolNames
3470
3472
  }) {
3471
3473
  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;
3472
3474
  let input = [];
@@ -4230,14 +4232,17 @@ async function convertToOpenAIResponsesInput({
4230
4232
  continue;
4231
4233
  }
4232
4234
  let contentValue;
4235
+ const hasOutputSchema = outputSchemaToolNames == null ? void 0 : outputSchemaToolNames.has(part.toolName);
4233
4236
  switch (output.type) {
4234
4237
  case "text":
4235
4238
  case "error-text":
4236
- contentValue = output.value;
4239
+ contentValue = hasOutputSchema ? JSON.stringify(output.value) : output.value;
4237
4240
  break;
4238
- case "execution-denied":
4239
- contentValue = (_J = output.reason) != null ? _J : "Tool call execution denied.";
4241
+ case "execution-denied": {
4242
+ const reason = (_J = output.reason) != null ? _J : "Tool call execution denied.";
4243
+ contentValue = hasOutputSchema ? JSON.stringify(reason) : reason;
4240
4244
  break;
4245
+ }
4241
4246
  case "json":
4242
4247
  case "error-json":
4243
4248
  contentValue = JSON.stringify(output.value);
@@ -5575,10 +5580,11 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
5575
5580
  * Service tier for the request.
5576
5581
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
5577
5582
  * 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).
5583
+ * Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
5578
5584
  *
5579
5585
  * Defaults to 'auto'.
5580
5586
  */
5581
- serviceTier: z21.enum(["auto", "flex", "priority", "default"]).nullish(),
5587
+ serviceTier: z21.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
5582
5588
  /**
5583
5589
  * Whether to store the generation. Defaults to `true`.
5584
5590
  */
@@ -6024,7 +6030,8 @@ async function prepareResponsesTools({
6024
6030
  toolChoice,
6025
6031
  allowedTools,
6026
6032
  toolNameMapping,
6027
- customProviderToolNames
6033
+ customProviderToolNames,
6034
+ outputSchemaToolNames
6028
6035
  }) {
6029
6036
  var _a, _b, _c;
6030
6037
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -6039,6 +6046,9 @@ async function prepareResponsesTools({
6039
6046
  switch (tool.type) {
6040
6047
  case "function": {
6041
6048
  const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
6049
+ if ((openaiOptions == null ? void 0 : openaiOptions.outputSchema) != null) {
6050
+ outputSchemaToolNames == null ? void 0 : outputSchemaToolNames.add(tool.name);
6051
+ }
6042
6052
  const openaiFunctionTool = prepareFunctionTool({
6043
6053
  tool,
6044
6054
  options: openaiOptions
@@ -6541,6 +6551,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6541
6551
  }
6542
6552
  });
6543
6553
  const customProviderToolNames = /* @__PURE__ */ new Set();
6554
+ const outputSchemaToolNames = /* @__PURE__ */ new Set();
6544
6555
  const {
6545
6556
  tools: openaiTools,
6546
6557
  toolChoice: openaiToolChoice,
@@ -6550,7 +6561,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6550
6561
  toolChoice,
6551
6562
  allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
6552
6563
  toolNameMapping,
6553
- customProviderToolNames
6564
+ customProviderToolNames,
6565
+ outputSchemaToolNames
6554
6566
  });
6555
6567
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
6556
6568
  prompt,
@@ -6566,7 +6578,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6566
6578
  hasShellTool: hasOpenAITool("openai.shell"),
6567
6579
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
6568
6580
  hasComputerTool: hasOpenAITool("openai.computer"),
6569
- customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
6581
+ customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0,
6582
+ outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
6570
6583
  });
6571
6584
  warnings.push(...inputWarnings);
6572
6585
  const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
@@ -6719,7 +6732,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6719
6732
  });
6720
6733
  delete baseArgs.service_tier;
6721
6734
  }
6722
- if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
6735
+ if (((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
6723
6736
  warnings.push({
6724
6737
  type: "unsupported",
6725
6738
  feature: "serviceTier",