@ai-sdk/openai 3.0.122 → 3.0.124

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.124
4
+
5
+ ### Patch Changes
6
+
7
+ - d131a3b: fix(openai): rewrite recursive Zod schemas that use `allOf` wrappers
8
+
9
+ ## 3.0.123
10
+
11
+ ### Patch Changes
12
+
13
+ - f56545c: feat(openai): add support for ultrafast service tier
14
+
3
15
  ## 3.0.122
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -14,7 +14,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
14
14
  store?: boolean | undefined;
15
15
  metadata?: Record<string, string> | undefined;
16
16
  prediction?: Record<string, any> | undefined;
17
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
17
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
18
18
  strictJsonSchema?: boolean | undefined;
19
19
  textVerbosity?: "low" | "medium" | "high" | undefined;
20
20
  promptCacheKey?: string | undefined;
@@ -1114,7 +1114,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1114
1114
  reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
1115
1115
  reasoningSummary?: string | null | undefined;
1116
1116
  safetyIdentifier?: string | null | undefined;
1117
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
1117
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | null | undefined;
1118
1118
  store?: boolean | null | undefined;
1119
1119
  passThroughUnsupportedFiles?: boolean | undefined;
1120
1120
  strictJsonSchema?: boolean | null | undefined;
@@ -1125,7 +1125,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1125
1125
  forceReasoning?: boolean | undefined;
1126
1126
  allowedTools?: {
1127
1127
  toolNames: string[];
1128
- mode?: "auto" | "required" | undefined;
1128
+ mode?: "required" | "auto" | undefined;
1129
1129
  } | undefined;
1130
1130
  }>;
1131
1131
  type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
14
14
  store?: boolean | undefined;
15
15
  metadata?: Record<string, string> | undefined;
16
16
  prediction?: Record<string, any> | undefined;
17
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
17
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
18
18
  strictJsonSchema?: boolean | undefined;
19
19
  textVerbosity?: "low" | "medium" | "high" | undefined;
20
20
  promptCacheKey?: string | undefined;
@@ -1114,7 +1114,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1114
1114
  reasoningContext?: "auto" | "current_turn" | "all_turns" | undefined;
1115
1115
  reasoningSummary?: string | null | undefined;
1116
1116
  safetyIdentifier?: string | null | undefined;
1117
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
1117
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | null | undefined;
1118
1118
  store?: boolean | null | undefined;
1119
1119
  passThroughUnsupportedFiles?: boolean | undefined;
1120
1120
  strictJsonSchema?: boolean | null | undefined;
@@ -1125,7 +1125,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
1125
1125
  forceReasoning?: boolean | undefined;
1126
1126
  allowedTools?: {
1127
1127
  toolNames: string[];
1128
- mode?: "auto" | "required" | undefined;
1128
+ mode?: "required" | "auto" | undefined;
1129
1129
  } | undefined;
1130
1130
  }>;
1131
1131
  type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
package/dist/index.js CHANGED
@@ -93,6 +93,98 @@ function getGptVersion(modelId) {
93
93
  };
94
94
  }
95
95
 
96
+ // src/normalize-openai-json-schema.ts
97
+ function normalizeOpenAIJsonSchema(schema) {
98
+ const normalizedSchema = normalizeSchema(schema, true);
99
+ const reference = getSingletonReference(normalizedSchema);
100
+ if (reference == null) {
101
+ return normalizedSchema;
102
+ }
103
+ const { allOf: _allOf, ...schemaWithoutAllOf } = normalizedSchema;
104
+ const referencedSchema = getLocalReferenceSchema(reference, normalizedSchema);
105
+ return typeof referencedSchema !== "object" || referencedSchema == null ? normalizedSchema : { ...referencedSchema, ...schemaWithoutAllOf };
106
+ function normalizeSchema(schema2, isRoot = false) {
107
+ if (typeof schema2 !== "object" || schema2 == null) {
108
+ return schema2;
109
+ }
110
+ const normalizedSchema2 = { ...schema2 };
111
+ if (normalizedSchema2.properties != null) {
112
+ normalizedSchema2.properties = normalizeSchemaRecord(
113
+ normalizedSchema2.properties
114
+ );
115
+ }
116
+ if (normalizedSchema2.patternProperties != null) {
117
+ normalizedSchema2.patternProperties = normalizeSchemaRecord(
118
+ normalizedSchema2.patternProperties
119
+ );
120
+ }
121
+ if (normalizedSchema2.definitions != null) {
122
+ normalizedSchema2.definitions = normalizeSchemaRecord(
123
+ normalizedSchema2.definitions
124
+ );
125
+ }
126
+ if (normalizedSchema2.$defs != null) {
127
+ normalizedSchema2.$defs = normalizeSchemaRecord(normalizedSchema2.$defs);
128
+ }
129
+ if (normalizedSchema2.items != null) {
130
+ normalizedSchema2.items = Array.isArray(normalizedSchema2.items) ? normalizedSchema2.items.map((item) => normalizeSchema(item)) : normalizeSchema(normalizedSchema2.items);
131
+ }
132
+ if (normalizedSchema2.allOf != null) {
133
+ normalizedSchema2.allOf = normalizedSchema2.allOf.map(
134
+ (item) => normalizeSchema(item)
135
+ );
136
+ }
137
+ if (normalizedSchema2.anyOf != null) {
138
+ normalizedSchema2.anyOf = normalizedSchema2.anyOf.map(
139
+ (item) => normalizeSchema(item)
140
+ );
141
+ }
142
+ if (normalizedSchema2.oneOf != null) {
143
+ normalizedSchema2.oneOf = normalizedSchema2.oneOf.map(
144
+ (item) => normalizeSchema(item)
145
+ );
146
+ }
147
+ if (typeof normalizedSchema2.additionalProperties === "object" && normalizedSchema2.additionalProperties != null) {
148
+ normalizedSchema2.additionalProperties = normalizeSchema(
149
+ normalizedSchema2.additionalProperties
150
+ );
151
+ }
152
+ const reference2 = getSingletonReference(normalizedSchema2);
153
+ if (reference2 == null || isRoot) {
154
+ return normalizedSchema2;
155
+ }
156
+ const { allOf: _allOf2, ...schemaWithoutAllOf2 } = normalizedSchema2;
157
+ return { ...schemaWithoutAllOf2, $ref: reference2 };
158
+ }
159
+ function normalizeSchemaRecord(record) {
160
+ return Object.fromEntries(
161
+ Object.entries(record).map(([key, value]) => [
162
+ key,
163
+ normalizeSchema(value)
164
+ ])
165
+ );
166
+ }
167
+ function getSingletonReference(schema2) {
168
+ var _a2;
169
+ if (((_a2 = schema2.allOf) == null ? void 0 : _a2.length) !== 1) {
170
+ return void 0;
171
+ }
172
+ const [allOfSchema] = schema2.allOf;
173
+ return typeof allOfSchema === "object" && allOfSchema != null && Object.keys(allOfSchema).length === 1 && typeof allOfSchema.$ref === "string" ? allOfSchema.$ref : void 0;
174
+ }
175
+ function getLocalReferenceSchema(reference2, schema2) {
176
+ var _a2, _b;
177
+ const match = /^#\/(definitions|\$defs)\/(.+)$/.exec(reference2);
178
+ if (match == null) {
179
+ return void 0;
180
+ }
181
+ const [, keyword, encodedName] = match;
182
+ const name = encodedName.replace(/~1/g, "/").replace(/~0/g, "~");
183
+ const definition = keyword === "definitions" ? (_a2 = schema2.definitions) == null ? void 0 : _a2[name] : (_b = schema2.$defs) == null ? void 0 : _b[name];
184
+ return definition;
185
+ }
186
+ }
187
+
96
188
  // src/openai-stream-error.ts
97
189
  var import_provider = require("@ai-sdk/provider");
98
190
  function createOpenAIProviderStreamError(frame) {
@@ -775,11 +867,12 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
775
867
  * - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
776
868
  * - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
777
869
  * - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
870
+ * - 'ultrafast': Access-controlled Ultrafast processing. Only available for gpt-5.6-sol.
778
871
  * - 'default': The request will be processed with the standard pricing and performance for the selected model.
779
872
  *
780
873
  * @default 'auto'
781
874
  */
782
- serviceTier: import_v43.z.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
875
+ serviceTier: import_v43.z.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).optional(),
783
876
  /**
784
877
  * Whether to use strict JSON schema validation.
785
878
  *
@@ -986,7 +1079,7 @@ var OpenAIChatLanguageModel = class {
986
1079
  response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
987
1080
  type: "json_schema",
988
1081
  json_schema: {
989
- schema: responseFormat.schema,
1082
+ schema: normalizeOpenAIJsonSchema(responseFormat.schema),
990
1083
  strict: strictJsonSchema,
991
1084
  name: (_e = responseFormat.name) != null ? _e : "response",
992
1085
  description: responseFormat.description
@@ -3190,10 +3283,11 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
3190
3283
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
3191
3284
  * 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).
3192
3285
  * Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
3286
+ * Set to 'ultrafast' for access-controlled Ultrafast processing (available only for gpt-5.6-sol).
3193
3287
  *
3194
3288
  * Defaults to 'auto'.
3195
3289
  */
3196
- serviceTier: import_v421.z.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
3290
+ serviceTier: import_v421.z.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).nullish(),
3197
3291
  /**
3198
3292
  * Whether to store the generation. Defaults to `true`.
3199
3293
  */
@@ -5998,7 +6092,7 @@ var OpenAIResponsesLanguageModel = class {
5998
6092
  strict: strictJsonSchema,
5999
6093
  name: (_h = responseFormat.name) != null ? _h : "response",
6000
6094
  description: responseFormat.description,
6001
- schema: responseFormat.schema
6095
+ schema: normalizeOpenAIJsonSchema(responseFormat.schema)
6002
6096
  } : { type: "json_object" }
6003
6097
  },
6004
6098
  ...(openaiOptions == null ? void 0 : openaiOptions.textVerbosity) && {
@@ -8138,7 +8232,7 @@ var OpenAITranscriptionModel = class {
8138
8232
  };
8139
8233
 
8140
8234
  // src/version.ts
8141
- var VERSION = true ? "3.0.122" : "0.0.0-test";
8235
+ var VERSION = true ? "3.0.124" : "0.0.0-test";
8142
8236
 
8143
8237
  // src/openai-provider.ts
8144
8238
  function createOpenAI(options = {}) {