@ai-sdk/openai 2.0.141 → 2.0.143

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,18 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.143
4
+
5
+ ### Patch Changes
6
+
7
+ - 3f019a6: Support positioned Responses API format updates so changing structured output schemas can preserve earlier reasoning and prompt cache reuse. Add a stable request-level text format override and expose prompt cache comparison diagnostics for generation and streaming results.
8
+
9
+ ## 2.0.142
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [c31e0a2]
14
+ - @ai-sdk/provider-utils@3.0.46
15
+
3
16
  ## 2.0.141
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,8 @@
1
+ import * as _ai_sdk_provider from '@ai-sdk/provider';
1
2
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
2
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { InferValidator, FetchFunction } from '@ai-sdk/provider-utils';
5
+ import { z } from 'zod/v4';
4
6
 
5
7
  type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
6
8
  declare const openaiChatLanguageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
@@ -157,6 +159,13 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFa
157
159
  };
158
160
  }>;
159
161
 
162
+ declare const openaiResponsesPromptCacheDiagnosticsSchema: () => z.ZodObject<{
163
+ type: z.ZodString;
164
+ reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
165
+ cache_missed_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
166
+ comparison_reusable_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
167
+ }, z.core.$strip>;
168
+ type OpenAIResponsesPromptCacheDiagnostics = z.infer<ReturnType<typeof openaiResponsesPromptCacheDiagnosticsSchema>>;
160
169
  /**
161
170
  * A filter used to compare a specified attribute key to a given value using a defined comparison operation.
162
171
  */
@@ -231,6 +240,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
231
240
  orchestration_output_tokens?: number | null | undefined;
232
241
  } | null | undefined;
233
242
  };
243
+ prompt_cache_diagnostics?: {
244
+ type: string;
245
+ reason?: string | null | undefined;
246
+ cache_missed_tokens?: number | null | undefined;
247
+ comparison_reusable_tokens?: number | null | undefined;
248
+ } | null | undefined;
234
249
  incomplete_details?: {
235
250
  reason: string;
236
251
  } | null | undefined;
@@ -625,6 +640,7 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
625
640
  previousResponseId?: string | null | undefined;
626
641
  promptCacheKey?: string | null | undefined;
627
642
  promptCacheOptions?: {
643
+ comparisonResponseId?: string | undefined;
628
644
  mode?: "explicit" | "implicit" | undefined;
629
645
  ttl?: "30m" | undefined;
630
646
  } | undefined;
@@ -639,11 +655,29 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
639
655
  store?: boolean | null | undefined;
640
656
  strictJsonSchema?: boolean | null | undefined;
641
657
  textVerbosity?: "low" | "medium" | "high" | null | undefined;
658
+ textFormat?: {
659
+ type: "text";
660
+ } | {
661
+ type: "json_schema";
662
+ name: string;
663
+ schema: Record<string, _ai_sdk_provider.JSONValue>;
664
+ description?: string | undefined;
665
+ strict?: boolean | undefined;
666
+ } | undefined;
642
667
  truncation?: "auto" | "disabled" | null | undefined;
643
668
  user?: string | null | undefined;
644
669
  }>;
645
670
  type OpenAIResponsesProviderOptions = InferValidator<typeof openaiResponsesProviderOptionsSchema>;
646
671
  declare const openaiResponsesSystemMessageOptionsSchema: _ai_sdk_provider_utils.LazyValidator<{
672
+ textFormatUpdate?: {
673
+ type: "text";
674
+ } | {
675
+ type: "json_schema";
676
+ name: string;
677
+ schema: Record<string, _ai_sdk_provider.JSONValue>;
678
+ description?: string | undefined;
679
+ strict?: boolean | undefined;
680
+ } | undefined;
647
681
  reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
648
682
  }>;
649
683
  type OpenAIResponsesSystemMessageOptions = InferValidator<typeof openaiResponsesSystemMessageOptionsSchema>;
@@ -756,6 +790,7 @@ type ResponsesProviderMetadata = {
756
790
  logprobs?: Array<OpenAIResponsesLogprobs>;
757
791
  serviceTier?: string;
758
792
  reasoningContext?: string;
793
+ promptCacheDiagnostics?: OpenAIResponsesPromptCacheDiagnostics;
759
794
  /**
760
795
  * Provider-specific token usage details, including prompt cache writes and
761
796
  * orchestration usage. Surfaced here so downstream consumers can bill it.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import * as _ai_sdk_provider from '@ai-sdk/provider';
1
2
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
2
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { InferValidator, FetchFunction } from '@ai-sdk/provider-utils';
5
+ import { z } from 'zod/v4';
4
6
 
5
7
  type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
6
8
  declare const openaiChatLanguageModelOptions: _ai_sdk_provider_utils.LazyValidator<{
@@ -157,6 +159,13 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFa
157
159
  };
158
160
  }>;
159
161
 
162
+ declare const openaiResponsesPromptCacheDiagnosticsSchema: () => z.ZodObject<{
163
+ type: z.ZodString;
164
+ reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
165
+ cache_missed_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
166
+ comparison_reusable_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
167
+ }, z.core.$strip>;
168
+ type OpenAIResponsesPromptCacheDiagnostics = z.infer<ReturnType<typeof openaiResponsesPromptCacheDiagnosticsSchema>>;
160
169
  /**
161
170
  * A filter used to compare a specified attribute key to a given value using a defined comparison operation.
162
171
  */
@@ -231,6 +240,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
231
240
  orchestration_output_tokens?: number | null | undefined;
232
241
  } | null | undefined;
233
242
  };
243
+ prompt_cache_diagnostics?: {
244
+ type: string;
245
+ reason?: string | null | undefined;
246
+ cache_missed_tokens?: number | null | undefined;
247
+ comparison_reusable_tokens?: number | null | undefined;
248
+ } | null | undefined;
234
249
  incomplete_details?: {
235
250
  reason: string;
236
251
  } | null | undefined;
@@ -625,6 +640,7 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
625
640
  previousResponseId?: string | null | undefined;
626
641
  promptCacheKey?: string | null | undefined;
627
642
  promptCacheOptions?: {
643
+ comparisonResponseId?: string | undefined;
628
644
  mode?: "explicit" | "implicit" | undefined;
629
645
  ttl?: "30m" | undefined;
630
646
  } | undefined;
@@ -639,11 +655,29 @@ declare const openaiResponsesProviderOptionsSchema: _ai_sdk_provider_utils.LazyV
639
655
  store?: boolean | null | undefined;
640
656
  strictJsonSchema?: boolean | null | undefined;
641
657
  textVerbosity?: "low" | "medium" | "high" | null | undefined;
658
+ textFormat?: {
659
+ type: "text";
660
+ } | {
661
+ type: "json_schema";
662
+ name: string;
663
+ schema: Record<string, _ai_sdk_provider.JSONValue>;
664
+ description?: string | undefined;
665
+ strict?: boolean | undefined;
666
+ } | undefined;
642
667
  truncation?: "auto" | "disabled" | null | undefined;
643
668
  user?: string | null | undefined;
644
669
  }>;
645
670
  type OpenAIResponsesProviderOptions = InferValidator<typeof openaiResponsesProviderOptionsSchema>;
646
671
  declare const openaiResponsesSystemMessageOptionsSchema: _ai_sdk_provider_utils.LazyValidator<{
672
+ textFormatUpdate?: {
673
+ type: "text";
674
+ } | {
675
+ type: "json_schema";
676
+ name: string;
677
+ schema: Record<string, _ai_sdk_provider.JSONValue>;
678
+ description?: string | undefined;
679
+ strict?: boolean | undefined;
680
+ } | undefined;
647
681
  reasoningEffortUpdate?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
648
682
  }>;
649
683
  type OpenAIResponsesSystemMessageOptions = InferValidator<typeof openaiResponsesSystemMessageOptionsSchema>;
@@ -756,6 +790,7 @@ type ResponsesProviderMetadata = {
756
790
  logprobs?: Array<OpenAIResponsesLogprobs>;
757
791
  serviceTier?: string;
758
792
  reasoningContext?: string;
793
+ promptCacheDiagnostics?: OpenAIResponsesPromptCacheDiagnostics;
759
794
  /**
760
795
  * Provider-specific token usage details, including prompt cache writes and
761
796
  * orchestration usage. Surfaced here so downstream consumers can bill it.