@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.
@@ -13,7 +13,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
13
13
  store?: boolean | undefined;
14
14
  metadata?: Record<string, string> | undefined;
15
15
  prediction?: Record<string, any> | undefined;
16
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
16
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
17
17
  strictJsonSchema?: boolean | undefined;
18
18
  textVerbosity?: "low" | "medium" | "high" | undefined;
19
19
  promptCacheKey?: string | undefined;
@@ -13,7 +13,7 @@ declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<
13
13
  store?: boolean | undefined;
14
14
  metadata?: Record<string, string> | undefined;
15
15
  prediction?: Record<string, any> | undefined;
16
- serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | undefined;
16
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
17
17
  strictJsonSchema?: boolean | undefined;
18
18
  textVerbosity?: "low" | "medium" | "high" | undefined;
19
19
  promptCacheKey?: string | undefined;
@@ -128,6 +128,98 @@ function getGptVersion(modelId) {
128
128
  };
129
129
  }
130
130
 
131
+ // src/normalize-openai-json-schema.ts
132
+ function normalizeOpenAIJsonSchema(schema) {
133
+ const normalizedSchema = normalizeSchema(schema, true);
134
+ const reference = getSingletonReference(normalizedSchema);
135
+ if (reference == null) {
136
+ return normalizedSchema;
137
+ }
138
+ const { allOf: _allOf, ...schemaWithoutAllOf } = normalizedSchema;
139
+ const referencedSchema = getLocalReferenceSchema(reference, normalizedSchema);
140
+ return typeof referencedSchema !== "object" || referencedSchema == null ? normalizedSchema : { ...referencedSchema, ...schemaWithoutAllOf };
141
+ function normalizeSchema(schema2, isRoot = false) {
142
+ if (typeof schema2 !== "object" || schema2 == null) {
143
+ return schema2;
144
+ }
145
+ const normalizedSchema2 = { ...schema2 };
146
+ if (normalizedSchema2.properties != null) {
147
+ normalizedSchema2.properties = normalizeSchemaRecord(
148
+ normalizedSchema2.properties
149
+ );
150
+ }
151
+ if (normalizedSchema2.patternProperties != null) {
152
+ normalizedSchema2.patternProperties = normalizeSchemaRecord(
153
+ normalizedSchema2.patternProperties
154
+ );
155
+ }
156
+ if (normalizedSchema2.definitions != null) {
157
+ normalizedSchema2.definitions = normalizeSchemaRecord(
158
+ normalizedSchema2.definitions
159
+ );
160
+ }
161
+ if (normalizedSchema2.$defs != null) {
162
+ normalizedSchema2.$defs = normalizeSchemaRecord(normalizedSchema2.$defs);
163
+ }
164
+ if (normalizedSchema2.items != null) {
165
+ normalizedSchema2.items = Array.isArray(normalizedSchema2.items) ? normalizedSchema2.items.map((item) => normalizeSchema(item)) : normalizeSchema(normalizedSchema2.items);
166
+ }
167
+ if (normalizedSchema2.allOf != null) {
168
+ normalizedSchema2.allOf = normalizedSchema2.allOf.map(
169
+ (item) => normalizeSchema(item)
170
+ );
171
+ }
172
+ if (normalizedSchema2.anyOf != null) {
173
+ normalizedSchema2.anyOf = normalizedSchema2.anyOf.map(
174
+ (item) => normalizeSchema(item)
175
+ );
176
+ }
177
+ if (normalizedSchema2.oneOf != null) {
178
+ normalizedSchema2.oneOf = normalizedSchema2.oneOf.map(
179
+ (item) => normalizeSchema(item)
180
+ );
181
+ }
182
+ if (typeof normalizedSchema2.additionalProperties === "object" && normalizedSchema2.additionalProperties != null) {
183
+ normalizedSchema2.additionalProperties = normalizeSchema(
184
+ normalizedSchema2.additionalProperties
185
+ );
186
+ }
187
+ const reference2 = getSingletonReference(normalizedSchema2);
188
+ if (reference2 == null || isRoot) {
189
+ return normalizedSchema2;
190
+ }
191
+ const { allOf: _allOf2, ...schemaWithoutAllOf2 } = normalizedSchema2;
192
+ return { ...schemaWithoutAllOf2, $ref: reference2 };
193
+ }
194
+ function normalizeSchemaRecord(record) {
195
+ return Object.fromEntries(
196
+ Object.entries(record).map(([key, value]) => [
197
+ key,
198
+ normalizeSchema(value)
199
+ ])
200
+ );
201
+ }
202
+ function getSingletonReference(schema2) {
203
+ var _a2;
204
+ if (((_a2 = schema2.allOf) == null ? void 0 : _a2.length) !== 1) {
205
+ return void 0;
206
+ }
207
+ const [allOfSchema] = schema2.allOf;
208
+ return typeof allOfSchema === "object" && allOfSchema != null && Object.keys(allOfSchema).length === 1 && typeof allOfSchema.$ref === "string" ? allOfSchema.$ref : void 0;
209
+ }
210
+ function getLocalReferenceSchema(reference2, schema2) {
211
+ var _a2, _b;
212
+ const match = /^#\/(definitions|\$defs)\/(.+)$/.exec(reference2);
213
+ if (match == null) {
214
+ return void 0;
215
+ }
216
+ const [, keyword, encodedName] = match;
217
+ const name = encodedName.replace(/~1/g, "/").replace(/~0/g, "~");
218
+ const definition = keyword === "definitions" ? (_a2 = schema2.definitions) == null ? void 0 : _a2[name] : (_b = schema2.$defs) == null ? void 0 : _b[name];
219
+ return definition;
220
+ }
221
+ }
222
+
131
223
  // src/openai-stream-error.ts
132
224
  var import_provider = require("@ai-sdk/provider");
133
225
  function createOpenAIProviderStreamError(frame) {
@@ -810,11 +902,12 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
810
902
  * - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
811
903
  * - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
812
904
  * - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
905
+ * - 'ultrafast': Access-controlled Ultrafast processing. Only available for gpt-5.6-sol.
813
906
  * - 'default': The request will be processed with the standard pricing and performance for the selected model.
814
907
  *
815
908
  * @default 'auto'
816
909
  */
817
- serviceTier: import_v43.z.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
910
+ serviceTier: import_v43.z.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).optional(),
818
911
  /**
819
912
  * Whether to use strict JSON schema validation.
820
913
  *
@@ -1021,7 +1114,7 @@ var OpenAIChatLanguageModel = class {
1021
1114
  response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
1022
1115
  type: "json_schema",
1023
1116
  json_schema: {
1024
- schema: responseFormat.schema,
1117
+ schema: normalizeOpenAIJsonSchema(responseFormat.schema),
1025
1118
  strict: strictJsonSchema,
1026
1119
  name: (_e = responseFormat.name) != null ? _e : "response",
1027
1120
  description: responseFormat.description
@@ -2934,10 +3027,11 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils20.lazy
2934
3027
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
2935
3028
  * 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).
2936
3029
  * Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
3030
+ * Set to 'ultrafast' for access-controlled Ultrafast processing (available only for gpt-5.6-sol).
2937
3031
  *
2938
3032
  * Defaults to 'auto'.
2939
3033
  */
2940
- serviceTier: import_v413.z.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
3034
+ serviceTier: import_v413.z.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).nullish(),
2941
3035
  /**
2942
3036
  * Whether to store the generation. Defaults to `true`.
2943
3037
  */
@@ -6265,7 +6359,7 @@ var OpenAIResponsesLanguageModel = class {
6265
6359
  strict: strictJsonSchema,
6266
6360
  name: (_h = responseFormat.name) != null ? _h : "response",
6267
6361
  description: responseFormat.description,
6268
- schema: responseFormat.schema
6362
+ schema: normalizeOpenAIJsonSchema(responseFormat.schema)
6269
6363
  } : { type: "json_object" }
6270
6364
  },
6271
6365
  ...(openaiOptions == null ? void 0 : openaiOptions.textVerbosity) && {