@ai-sdk/openai 4.0.56 → 4.0.58

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" | "fast" | undefined;
18
+ serviceTier?: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | undefined;
19
19
  strictJsonSchema?: boolean | undefined;
20
20
  textVerbosity?: "low" | "medium" | "high" | undefined;
21
21
  promptCacheKey?: string | undefined;
@@ -763,6 +763,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
763
763
  filters: OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter | undefined;
764
764
  } | {
765
765
  type: 'image_generation';
766
+ action: 'generate' | 'edit' | 'auto' | undefined;
766
767
  background: 'auto' | 'opaque' | 'transparent' | undefined;
767
768
  input_fidelity: 'low' | 'high' | undefined;
768
769
  input_image_mask: {
@@ -770,12 +771,12 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
770
771
  image_url: string | undefined;
771
772
  } | undefined;
772
773
  model: string | undefined;
773
- moderation: 'auto' | undefined;
774
+ moderation: 'auto' | 'low' | undefined;
774
775
  output_compression: number | undefined;
775
776
  output_format: 'png' | 'jpeg' | 'webp' | undefined;
776
777
  partial_images: number | undefined;
777
778
  quality: 'auto' | 'low' | 'medium' | 'high' | undefined;
778
- size: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | undefined;
779
+ size: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {}) | undefined;
779
780
  }
780
781
  /**
781
782
  * Official OpenAI API Specifications: https://platform.openai.com/docs/api-reference/responses/create#responses_create-tools-mcp_tool
@@ -906,20 +907,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
906
907
  incomplete_details?: {
907
908
  reason: string;
908
909
  } | null | undefined;
909
- usage?: {
910
+ usage?: (Record<string, JSONValue | undefined> & {
910
911
  input_tokens: number;
911
912
  output_tokens: number;
912
- input_tokens_details?: {
913
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
913
914
  cached_tokens?: number | null | undefined;
914
915
  cache_write_tokens?: number | null | undefined;
915
916
  orchestration_input_tokens?: number | null | undefined;
916
917
  orchestration_input_cached_tokens?: number | null | undefined;
917
- } | null | undefined;
918
- output_tokens_details?: {
918
+ }) | null | undefined;
919
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
919
920
  reasoning_tokens?: number | null | undefined;
920
921
  orchestration_output_tokens?: number | null | undefined;
921
- } | null | undefined;
922
- } | null | undefined;
922
+ }) | null | undefined;
923
+ total_tokens?: number | undefined;
924
+ }) | null | undefined;
923
925
  reasoning?: {
924
926
  context?: string | null | undefined;
925
927
  } | null | undefined;
@@ -936,20 +938,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
936
938
  incomplete_details?: {
937
939
  reason: string;
938
940
  } | null | undefined;
939
- usage?: {
941
+ usage?: (Record<string, JSONValue | undefined> & {
940
942
  input_tokens: number;
941
943
  output_tokens: number;
942
- input_tokens_details?: {
944
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
943
945
  cached_tokens?: number | null | undefined;
944
946
  cache_write_tokens?: number | null | undefined;
945
947
  orchestration_input_tokens?: number | null | undefined;
946
948
  orchestration_input_cached_tokens?: number | null | undefined;
947
- } | null | undefined;
948
- output_tokens_details?: {
949
+ }) | null | undefined;
950
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
949
951
  reasoning_tokens?: number | null | undefined;
950
952
  orchestration_output_tokens?: number | null | undefined;
951
- } | null | undefined;
952
- } | null | undefined;
953
+ }) | null | undefined;
954
+ total_tokens?: number | undefined;
955
+ }) | null | undefined;
953
956
  reasoning?: {
954
957
  context?: string | null | undefined;
955
958
  } | null | undefined;
@@ -1868,7 +1871,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1868
1871
  store: boolean | null | undefined;
1869
1872
  user: string | null | undefined;
1870
1873
  instructions: string | null | undefined;
1871
- service_tier: "default" | "auto" | "flex" | "priority" | "fast" | null | undefined;
1874
+ service_tier: "default" | "auto" | "flex" | "priority" | "fast" | "ultrafast" | null | undefined;
1872
1875
  include: OpenAIResponsesIncludeOptions;
1873
1876
  prompt_cache_key: string | null | undefined;
1874
1877
  prompt_cache_options: {
@@ -2259,6 +2262,7 @@ declare const fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{},
2259
2262
  }, {}>;
2260
2263
 
2261
2264
  declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
2265
+ action?: "auto" | "generate" | "edit" | undefined;
2262
2266
  background?: "auto" | "transparent" | "opaque" | undefined;
2263
2267
  inputFidelity?: "low" | "high" | undefined;
2264
2268
  inputImageMask?: {
@@ -2266,17 +2270,21 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
2266
2270
  imageUrl?: string | undefined;
2267
2271
  } | undefined;
2268
2272
  model?: string | undefined;
2269
- moderation?: "auto" | undefined;
2273
+ moderation?: "auto" | "low" | undefined;
2270
2274
  outputCompression?: number | undefined;
2271
2275
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
2272
2276
  partialImages?: number | undefined;
2273
2277
  quality?: "auto" | "low" | "medium" | "high" | undefined;
2274
- size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | undefined;
2278
+ size?: string | undefined;
2275
2279
  }>;
2276
2280
  declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
2277
2281
  result: string;
2278
2282
  }>;
2279
2283
  type ImageGenerationArgs = {
2284
+ /**
2285
+ * Whether to generate a new image or edit an existing image. Default: auto.
2286
+ */
2287
+ action?: 'generate' | 'edit' | 'auto';
2280
2288
  /**
2281
2289
  * Background type for the generated image. Default is 'auto'.
2282
2290
  */
@@ -2304,9 +2312,9 @@ type ImageGenerationArgs = {
2304
2312
  */
2305
2313
  model?: string;
2306
2314
  /**
2307
- * Moderation level for the generated image. Default: auto.
2315
+ * Moderation level for the generated image. One of auto or low. Default: auto.
2308
2316
  */
2309
- moderation?: 'auto';
2317
+ moderation?: 'auto' | 'low';
2310
2318
  /**
2311
2319
  * Compression level for the output image. Default: 100.
2312
2320
  */
@@ -2327,10 +2335,11 @@ type ImageGenerationArgs = {
2327
2335
  quality?: 'auto' | 'low' | 'medium' | 'high';
2328
2336
  /**
2329
2337
  * The size of the generated image.
2330
- * One of 1024x1024, 1024x1536, 1536x1024, or auto.
2338
+ * One of 1024x1024, 1024x1536, 1536x1024, or auto. gpt-image-2 also accepts
2339
+ * arbitrary WIDTHxHEIGHT sizes where both are divisible by 16, e.g. 1536x864.
2331
2340
  * Default: auto.
2332
2341
  */
2333
- size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024';
2342
+ size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {});
2334
2343
  };
2335
2344
  declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
2336
2345
  /**
@@ -828,11 +828,12 @@ var openaiLanguageModelChatOptions = lazySchema2(
828
828
  * - 'flex': 50% cheaper processing at the cost of increased latency. Only available for o3 and o4-mini models.
829
829
  * - 'priority': Higher-speed processing with predictably low latency at premium cost. Available for Enterprise customers.
830
830
  * - 'fast': OpenAI's newer name for the 'priority' tier. Interchangeable with it.
831
+ * - 'ultrafast': Access-controlled Ultrafast processing. Only available for gpt-5.6-sol.
831
832
  * - 'default': The request will be processed with the standard pricing and performance for the selected model.
832
833
  *
833
834
  * @default 'auto'
834
835
  */
835
- serviceTier: z3.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
836
+ serviceTier: z3.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).optional(),
836
837
  /**
837
838
  * Whether to use strict JSON schema validation.
838
839
  *
@@ -4739,6 +4740,31 @@ var jsonValueSchema = z20.lazy(
4739
4740
  z20.record(z20.string(), jsonValueSchema.optional())
4740
4741
  ])
4741
4742
  );
4743
+ var jsonObjectSchema = z20.record(z20.string(), jsonValueSchema.optional());
4744
+ var openaiResponsesUsageSchema = z20.intersection(
4745
+ jsonObjectSchema,
4746
+ z20.object({
4747
+ input_tokens: z20.number(),
4748
+ input_tokens_details: z20.intersection(
4749
+ jsonObjectSchema,
4750
+ z20.object({
4751
+ cached_tokens: z20.number().nullish(),
4752
+ cache_write_tokens: z20.number().nullish(),
4753
+ orchestration_input_tokens: z20.number().nullish(),
4754
+ orchestration_input_cached_tokens: z20.number().nullish()
4755
+ })
4756
+ ).nullish(),
4757
+ output_tokens: z20.number(),
4758
+ output_tokens_details: z20.intersection(
4759
+ jsonObjectSchema,
4760
+ z20.object({
4761
+ reasoning_tokens: z20.number().nullish(),
4762
+ orchestration_output_tokens: z20.number().nullish()
4763
+ })
4764
+ ).nullish(),
4765
+ total_tokens: z20.number().optional()
4766
+ })
4767
+ );
4742
4768
  var openaiResponsesComputerSafetyCheckSchema = z20.object({
4743
4769
  id: z20.string(),
4744
4770
  code: z20.string().nullish(),
@@ -4935,20 +4961,7 @@ var openaiResponsesChunkSchema = lazySchema18(
4935
4961
  type: z20.enum(["response.completed", "response.incomplete"]),
4936
4962
  response: z20.object({
4937
4963
  incomplete_details: z20.object({ reason: z20.string() }).nullish(),
4938
- usage: z20.object({
4939
- input_tokens: z20.number(),
4940
- input_tokens_details: z20.object({
4941
- cached_tokens: z20.number().nullish(),
4942
- cache_write_tokens: z20.number().nullish(),
4943
- orchestration_input_tokens: z20.number().nullish(),
4944
- orchestration_input_cached_tokens: z20.number().nullish()
4945
- }).nullish(),
4946
- output_tokens: z20.number(),
4947
- output_tokens_details: z20.object({
4948
- reasoning_tokens: z20.number().nullish(),
4949
- orchestration_output_tokens: z20.number().nullish()
4950
- }).nullish()
4951
- }).nullish(),
4964
+ usage: openaiResponsesUsageSchema.nullish(),
4952
4965
  reasoning: z20.object({
4953
4966
  context: z20.string().nullish()
4954
4967
  }).nullish(),
@@ -4964,20 +4977,7 @@ var openaiResponsesChunkSchema = lazySchema18(
4964
4977
  message: z20.string()
4965
4978
  }).nullish(),
4966
4979
  incomplete_details: z20.object({ reason: z20.string() }).nullish(),
4967
- usage: z20.object({
4968
- input_tokens: z20.number(),
4969
- input_tokens_details: z20.object({
4970
- cached_tokens: z20.number().nullish(),
4971
- cache_write_tokens: z20.number().nullish(),
4972
- orchestration_input_tokens: z20.number().nullish(),
4973
- orchestration_input_cached_tokens: z20.number().nullish()
4974
- }).nullish(),
4975
- output_tokens: z20.number(),
4976
- output_tokens_details: z20.object({
4977
- reasoning_tokens: z20.number().nullish(),
4978
- orchestration_output_tokens: z20.number().nullish()
4979
- }).nullish()
4980
- }).nullish(),
4980
+ usage: openaiResponsesUsageSchema.nullish(),
4981
4981
  reasoning: z20.object({
4982
4982
  context: z20.string().nullish()
4983
4983
  }).nullish(),
@@ -5767,20 +5767,7 @@ var openaiResponsesResponseSchema = lazySchema18(
5767
5767
  context: z20.string().nullish()
5768
5768
  }).nullish(),
5769
5769
  incomplete_details: z20.object({ reason: z20.string() }).nullish(),
5770
- usage: z20.object({
5771
- input_tokens: z20.number(),
5772
- input_tokens_details: z20.object({
5773
- cached_tokens: z20.number().nullish(),
5774
- cache_write_tokens: z20.number().nullish(),
5775
- orchestration_input_tokens: z20.number().nullish(),
5776
- orchestration_input_cached_tokens: z20.number().nullish()
5777
- }).nullish(),
5778
- output_tokens: z20.number(),
5779
- output_tokens_details: z20.object({
5780
- reasoning_tokens: z20.number().nullish(),
5781
- orchestration_output_tokens: z20.number().nullish()
5782
- }).nullish()
5783
- }).nullish()
5770
+ usage: openaiResponsesUsageSchema.nullish()
5784
5771
  })
5785
5772
  )
5786
5773
  );
@@ -5982,10 +5969,11 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
5982
5969
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
5983
5970
  * 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).
5984
5971
  * Set to 'fast' for the same tier as 'priority' (OpenAI's newer name for it).
5972
+ * Set to 'ultrafast' for access-controlled Ultrafast processing (available only for gpt-5.6-sol).
5985
5973
  *
5986
5974
  * Defaults to 'auto'.
5987
5975
  */
5988
- serviceTier: z21.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
5976
+ serviceTier: z21.enum(["auto", "flex", "priority", "fast", "ultrafast", "default"]).nullish(),
5989
5977
  /**
5990
5978
  * Whether to store the generation. Defaults to `true`.
5991
5979
  */
@@ -6192,6 +6180,7 @@ import { z as z24 } from "zod/v4";
6192
6180
  var imageGenerationArgsSchema = lazySchema22(
6193
6181
  () => zodSchema22(
6194
6182
  z24.object({
6183
+ action: z24.enum(["generate", "edit", "auto"]).optional(),
6195
6184
  background: z24.enum(["auto", "opaque", "transparent"]).optional(),
6196
6185
  inputFidelity: z24.enum(["low", "high"]).optional(),
6197
6186
  inputImageMask: z24.object({
@@ -6199,12 +6188,15 @@ var imageGenerationArgsSchema = lazySchema22(
6199
6188
  imageUrl: z24.string().optional()
6200
6189
  }).optional(),
6201
6190
  model: z24.string().optional(),
6202
- moderation: z24.enum(["auto"]).optional(),
6191
+ moderation: z24.enum(["auto", "low"]).optional(),
6203
6192
  outputCompression: z24.number().int().min(0).max(100).optional(),
6204
6193
  outputFormat: z24.enum(["png", "jpeg", "webp"]).optional(),
6205
6194
  partialImages: z24.number().int().min(0).max(3).optional(),
6206
6195
  quality: z24.enum(["auto", "low", "medium", "high"]).optional(),
6207
- size: z24.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
6196
+ size: z24.union([
6197
+ z24.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
6198
+ z24.string().regex(/^\d+x\d+$/)
6199
+ ]).optional()
6208
6200
  }).strict()
6209
6201
  )
6210
6202
  );
@@ -6608,6 +6600,7 @@ async function prepareResponsesTools({
6608
6600
  });
6609
6601
  openaiTools.push({
6610
6602
  type: "image_generation",
6603
+ action: args.action,
6611
6604
  background: args.background,
6612
6605
  input_fidelity: args.inputFidelity,
6613
6606
  input_image_mask: args.inputImageMask ? {