@ai-sdk/openai 2.0.0-alpha.10 → 2.0.0-alpha.11

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.
@@ -264,7 +264,14 @@ var openaiProviderOptions = z.object({
264
264
  *
265
265
  * @default true
266
266
  */
267
- structuredOutputs: z.boolean().optional()
267
+ structuredOutputs: z.boolean().optional(),
268
+ /**
269
+ * Service tier for the request. Set to 'flex' for 50% cheaper processing
270
+ * at the cost of increased latency. Only available for o3 and o4-mini models.
271
+ *
272
+ * @default 'auto'
273
+ */
274
+ serviceTier: z.enum(["auto", "flex"]).optional()
268
275
  });
269
276
 
270
277
  // src/openai-error.ts
@@ -437,6 +444,7 @@ var OpenAIChatLanguageModel = class {
437
444
  metadata: openaiOptions.metadata,
438
445
  prediction: openaiOptions.prediction,
439
446
  reasoning_effort: openaiOptions.reasoningEffort,
447
+ service_tier: openaiOptions.serviceTier,
440
448
  // messages:
441
449
  messages
442
450
  };
@@ -510,6 +518,14 @@ var OpenAIChatLanguageModel = class {
510
518
  });
511
519
  }
512
520
  }
521
+ if (openaiOptions.serviceTier === "flex" && !supportsFlexProcessing(this.modelId)) {
522
+ warnings.push({
523
+ type: "unsupported-setting",
524
+ setting: "serviceTier",
525
+ details: "flex processing is only available for o3 and o4-mini models"
526
+ });
527
+ baseArgs.service_tier = void 0;
528
+ }
513
529
  const {
514
530
  tools: openaiTools,
515
531
  toolChoice: openaiToolChoice,
@@ -881,6 +897,9 @@ var openaiChatChunkSchema = z3.union([
881
897
  function isReasoningModel(modelId) {
882
898
  return modelId.startsWith("o");
883
899
  }
900
+ function supportsFlexProcessing(modelId) {
901
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
902
+ }
884
903
  function getSystemMessageMode(modelId) {
885
904
  var _a, _b;
886
905
  if (!isReasoningModel(modelId)) {
@@ -2116,6 +2135,7 @@ var OpenAIResponsesLanguageModel = class {
2116
2135
  store: openaiOptions == null ? void 0 : openaiOptions.store,
2117
2136
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2118
2137
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2138
+ service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2119
2139
  // model-specific settings:
2120
2140
  ...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
2121
2141
  reasoning: {
@@ -2149,6 +2169,14 @@ var OpenAIResponsesLanguageModel = class {
2149
2169
  });
2150
2170
  }
2151
2171
  }
2172
+ if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !supportsFlexProcessing2(this.modelId)) {
2173
+ warnings.push({
2174
+ type: "unsupported-setting",
2175
+ setting: "serviceTier",
2176
+ details: "flex processing is only available for o3 and o4-mini models"
2177
+ });
2178
+ delete baseArgs.service_tier;
2179
+ }
2152
2180
  const {
2153
2181
  tools: openaiTools,
2154
2182
  toolChoice: openaiToolChoice,
@@ -2578,6 +2606,9 @@ function getResponsesModelConfig(modelId) {
2578
2606
  requiredAutoTruncation: false
2579
2607
  };
2580
2608
  }
2609
+ function supportsFlexProcessing2(modelId) {
2610
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
2611
+ }
2581
2612
  var openaiResponsesProviderOptionsSchema = z12.object({
2582
2613
  metadata: z12.any().nullish(),
2583
2614
  parallelToolCalls: z12.boolean().nullish(),
@@ -2587,7 +2618,8 @@ var openaiResponsesProviderOptionsSchema = z12.object({
2587
2618
  reasoningEffort: z12.string().nullish(),
2588
2619
  strictSchemas: z12.boolean().nullish(),
2589
2620
  instructions: z12.string().nullish(),
2590
- reasoningSummary: z12.string().nullish()
2621
+ reasoningSummary: z12.string().nullish(),
2622
+ serviceTier: z12.enum(["auto", "flex"]).nullish()
2591
2623
  });
2592
2624
  export {
2593
2625
  OpenAIChatLanguageModel,