@ai-sdk/openai 4.0.0-beta.12 → 4.0.0-beta.15

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.
@@ -2,7 +2,7 @@ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateRes
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | '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-pro' | 'gpt-5.4-pro-2026-03-05' | (string & {});
5
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | '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' | (string & {});
6
6
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
7
7
  logitBias?: Record<number, number> | undefined;
8
8
  logprobs?: number | boolean | undefined;
@@ -188,7 +188,7 @@ declare class OpenAISpeechModel implements SpeechModelV4 {
188
188
  doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>>;
189
189
  }
190
190
 
191
- type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
191
+ type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | '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-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
192
192
 
193
193
  declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
194
194
  readonly specificationVersion = "v4";
@@ -265,6 +265,28 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
265
265
  } | null | undefined;
266
266
  service_tier?: string | null | undefined;
267
267
  };
268
+ } | {
269
+ type: "response.failed";
270
+ response: {
271
+ error?: {
272
+ message: string;
273
+ code?: string | null | undefined;
274
+ } | null | undefined;
275
+ incomplete_details?: {
276
+ reason: string;
277
+ } | null | undefined;
278
+ usage?: {
279
+ input_tokens: number;
280
+ output_tokens: number;
281
+ input_tokens_details?: {
282
+ cached_tokens?: number | null | undefined;
283
+ } | null | undefined;
284
+ output_tokens_details?: {
285
+ reasoning_tokens?: number | null | undefined;
286
+ } | null | undefined;
287
+ } | null | undefined;
288
+ service_tier?: string | null | undefined;
289
+ };
268
290
  } | {
269
291
  type: "response.created";
270
292
  response: {
@@ -2,7 +2,7 @@ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateRes
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | '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-pro' | 'gpt-5.4-pro-2026-03-05' | (string & {});
5
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | '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' | (string & {});
6
6
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
7
7
  logitBias?: Record<number, number> | undefined;
8
8
  logprobs?: number | boolean | undefined;
@@ -188,7 +188,7 @@ declare class OpenAISpeechModel implements SpeechModelV4 {
188
188
  doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>>;
189
189
  }
190
190
 
191
- type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
191
+ type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | '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-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
192
192
 
193
193
  declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
194
194
  readonly specificationVersion = "v4";
@@ -265,6 +265,28 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
265
265
  } | null | undefined;
266
266
  service_tier?: string | null | undefined;
267
267
  };
268
+ } | {
269
+ type: "response.failed";
270
+ response: {
271
+ error?: {
272
+ message: string;
273
+ code?: string | null | undefined;
274
+ } | null | undefined;
275
+ incomplete_details?: {
276
+ reason: string;
277
+ } | null | undefined;
278
+ usage?: {
279
+ input_tokens: number;
280
+ output_tokens: number;
281
+ input_tokens_details?: {
282
+ cached_tokens?: number | null | undefined;
283
+ } | null | undefined;
284
+ output_tokens_details?: {
285
+ reasoning_tokens?: number | null | undefined;
286
+ } | null | undefined;
287
+ } | null | undefined;
288
+ service_tier?: string | null | undefined;
289
+ };
268
290
  } | {
269
291
  type: "response.created";
270
292
  response: {
@@ -82,7 +82,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
82
82
  // src/openai-language-model-capabilities.ts
83
83
  function getOpenAILanguageModelCapabilities(modelId) {
84
84
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
85
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
85
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
86
86
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
87
87
  const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
88
88
  const systemMessageMode = isReasoningModel ? "developer" : "system";
@@ -698,9 +698,10 @@ var OpenAIChatLanguageModel = class {
698
698
  seed,
699
699
  tools,
700
700
  toolChoice,
701
+ reasoning,
701
702
  providerOptions
702
703
  }) {
703
- var _a, _b, _c, _d, _e;
704
+ var _a, _b, _c, _d, _e, _f;
704
705
  const warnings = [];
705
706
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
706
707
  provider: "openai",
@@ -708,18 +709,19 @@ var OpenAIChatLanguageModel = class {
708
709
  schema: openaiLanguageModelChatOptions
709
710
  })) != null ? _a : {};
710
711
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
711
- const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
712
+ const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : (0, import_provider_utils5.isCustomReasoning)(reasoning) ? reasoning : void 0;
713
+ const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
712
714
  if (topK != null) {
713
715
  warnings.push({ type: "unsupported", feature: "topK" });
714
716
  }
715
717
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
716
718
  {
717
719
  prompt,
718
- systemMessageMode: (_c = openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
720
+ systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
719
721
  }
720
722
  );
721
723
  warnings.push(...messageWarnings);
722
- const strictJsonSchema = (_d = openaiOptions.strictJsonSchema) != null ? _d : true;
724
+ const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
723
725
  const baseArgs = {
724
726
  // model id:
725
727
  model: this.modelId,
@@ -740,7 +742,7 @@ var OpenAIChatLanguageModel = class {
740
742
  json_schema: {
741
743
  schema: responseFormat.schema,
742
744
  strict: strictJsonSchema,
743
- name: (_e = responseFormat.name) != null ? _e : "response",
745
+ name: (_f = responseFormat.name) != null ? _f : "response",
744
746
  description: responseFormat.description
745
747
  }
746
748
  } : { type: "json_object" } : void 0,
@@ -753,7 +755,7 @@ var OpenAIChatLanguageModel = class {
753
755
  store: openaiOptions.store,
754
756
  metadata: openaiOptions.metadata,
755
757
  prediction: openaiOptions.prediction,
756
- reasoning_effort: openaiOptions.reasoningEffort,
758
+ reasoning_effort: resolvedReasoningEffort,
757
759
  service_tier: openaiOptions.serviceTier,
758
760
  prompt_cache_key: openaiOptions.promptCacheKey,
759
761
  prompt_cache_retention: openaiOptions.promptCacheRetention,
@@ -762,7 +764,7 @@ var OpenAIChatLanguageModel = class {
762
764
  messages
763
765
  };
764
766
  if (isReasoningModel) {
765
- if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
767
+ if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
766
768
  if (baseArgs.temperature != null) {
767
769
  baseArgs.temperature = void 0;
768
770
  warnings.push({
@@ -3263,6 +3265,23 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
3263
3265
  service_tier: import_v417.z.string().nullish()
3264
3266
  })
3265
3267
  }),
3268
+ import_v417.z.object({
3269
+ type: import_v417.z.literal("response.failed"),
3270
+ response: import_v417.z.object({
3271
+ error: import_v417.z.object({
3272
+ code: import_v417.z.string().nullish(),
3273
+ message: import_v417.z.string()
3274
+ }).nullish(),
3275
+ incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
3276
+ usage: import_v417.z.object({
3277
+ input_tokens: import_v417.z.number(),
3278
+ input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
3279
+ output_tokens: import_v417.z.number(),
3280
+ output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3281
+ }).nullish(),
3282
+ service_tier: import_v417.z.string().nullish()
3283
+ })
3284
+ }),
3266
3285
  import_v417.z.object({
3267
3286
  type: import_v417.z.literal("response.created"),
3268
3287
  response: import_v417.z.object({
@@ -4095,6 +4114,10 @@ var openaiResponsesReasoningModelIds = [
4095
4114
  "gpt-5.3-codex",
4096
4115
  "gpt-5.4",
4097
4116
  "gpt-5.4-2026-03-05",
4117
+ "gpt-5.4-mini",
4118
+ "gpt-5.4-mini-2026-03-17",
4119
+ "gpt-5.4-nano",
4120
+ "gpt-5.4-nano-2026-03-17",
4098
4121
  "gpt-5.4-pro",
4099
4122
  "gpt-5.4-pro-2026-03-05"
4100
4123
  ];
@@ -4916,12 +4939,13 @@ var OpenAIResponsesLanguageModel = class {
4916
4939
  frequencyPenalty,
4917
4940
  seed,
4918
4941
  prompt,
4942
+ reasoning,
4919
4943
  providerOptions,
4920
4944
  tools,
4921
4945
  toolChoice,
4922
4946
  responseFormat
4923
4947
  }) {
4924
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4948
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4925
4949
  const warnings = [];
4926
4950
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4927
4951
  if (topK != null) {
@@ -4952,7 +4976,8 @@ var OpenAIResponsesLanguageModel = class {
4952
4976
  schema: openaiLanguageModelResponsesOptionsSchema
4953
4977
  });
4954
4978
  }
4955
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
4979
+ const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (0, import_provider_utils34.isCustomReasoning)(reasoning) ? reasoning : void 0;
4980
+ const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
4956
4981
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
4957
4982
  warnings.push({
4958
4983
  type: "unsupported",
@@ -4989,10 +5014,10 @@ var OpenAIResponsesLanguageModel = class {
4989
5014
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4990
5015
  prompt,
4991
5016
  toolNameMapping,
4992
- systemMessageMode: (_b = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5017
+ systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4993
5018
  providerOptionsName,
4994
5019
  fileIdPrefixes: this.config.fileIdPrefixes,
4995
- store: (_c = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c : true,
5020
+ store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4996
5021
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4997
5022
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4998
5023
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -5000,7 +5025,7 @@ var OpenAIResponsesLanguageModel = class {
5000
5025
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5001
5026
  });
5002
5027
  warnings.push(...inputWarnings);
5003
- const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
5028
+ const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
5004
5029
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
5005
5030
  function addInclude(key) {
5006
5031
  if (include == null) {
@@ -5016,9 +5041,9 @@ var OpenAIResponsesLanguageModel = class {
5016
5041
  if (topLogprobs) {
5017
5042
  addInclude("message.output_text.logprobs");
5018
5043
  }
5019
- const webSearchToolName = (_e = tools == null ? void 0 : tools.find(
5044
+ const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
5020
5045
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
5021
- )) == null ? void 0 : _e.name;
5046
+ )) == null ? void 0 : _f.name;
5022
5047
  if (webSearchToolName) {
5023
5048
  addInclude("web_search_call.action.sources");
5024
5049
  }
@@ -5041,7 +5066,7 @@ var OpenAIResponsesLanguageModel = class {
5041
5066
  format: responseFormat.schema != null ? {
5042
5067
  type: "json_schema",
5043
5068
  strict: strictJsonSchema,
5044
- name: (_f = responseFormat.name) != null ? _f : "response",
5069
+ name: (_g = responseFormat.name) != null ? _g : "response",
5045
5070
  description: responseFormat.description,
5046
5071
  schema: responseFormat.schema
5047
5072
  } : { type: "json_object" }
@@ -5075,10 +5100,10 @@ var OpenAIResponsesLanguageModel = class {
5075
5100
  }))
5076
5101
  },
5077
5102
  // model-specific settings:
5078
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5103
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5079
5104
  reasoning: {
5080
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
5081
- effort: openaiOptions.reasoningEffort
5105
+ ...resolvedReasoningEffort != null && {
5106
+ effort: resolvedReasoningEffort
5082
5107
  },
5083
5108
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
5084
5109
  summary: openaiOptions.reasoningSummary
@@ -5087,7 +5112,7 @@ var OpenAIResponsesLanguageModel = class {
5087
5112
  }
5088
5113
  };
5089
5114
  if (isReasoningModel) {
5090
- if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
5115
+ if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
5091
5116
  if (baseArgs.temperature != null) {
5092
5117
  baseArgs.temperature = void 0;
5093
5118
  warnings.push({
@@ -5137,9 +5162,9 @@ var OpenAIResponsesLanguageModel = class {
5137
5162
  });
5138
5163
  delete baseArgs.service_tier;
5139
5164
  }
5140
- const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
5165
+ const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
5141
5166
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
5142
- )) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
5167
+ )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
5143
5168
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
5144
5169
  return {
5145
5170
  webSearchToolName,
@@ -5695,7 +5720,7 @@ var OpenAIResponsesLanguageModel = class {
5695
5720
  controller.enqueue({ type: "stream-start", warnings });
5696
5721
  },
5697
5722
  transform(chunk, controller) {
5698
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
5723
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
5699
5724
  if (options.includeRawChunks) {
5700
5725
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5701
5726
  }
@@ -6432,13 +6457,23 @@ var OpenAIResponsesLanguageModel = class {
6432
6457
  if (typeof value.response.service_tier === "string") {
6433
6458
  serviceTier = value.response.service_tier;
6434
6459
  }
6460
+ } else if (isResponseFailedChunk(value)) {
6461
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6462
+ finishReason = {
6463
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6464
+ finishReason: incompleteReason,
6465
+ hasFunctionCall
6466
+ }) : "error",
6467
+ raw: incompleteReason != null ? incompleteReason : "error"
6468
+ };
6469
+ usage = (_z = value.response.usage) != null ? _z : void 0;
6435
6470
  } else if (isResponseAnnotationAddedChunk(value)) {
6436
6471
  ongoingAnnotations.push(value.annotation);
6437
6472
  if (value.annotation.type === "url_citation") {
6438
6473
  controller.enqueue({
6439
6474
  type: "source",
6440
6475
  sourceType: "url",
6441
- id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : (0, import_provider_utils34.generateId)(),
6476
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils34.generateId)(),
6442
6477
  url: value.annotation.url,
6443
6478
  title: value.annotation.title
6444
6479
  });
@@ -6446,7 +6481,7 @@ var OpenAIResponsesLanguageModel = class {
6446
6481
  controller.enqueue({
6447
6482
  type: "source",
6448
6483
  sourceType: "document",
6449
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : (0, import_provider_utils34.generateId)(),
6484
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0, import_provider_utils34.generateId)(),
6450
6485
  mediaType: "text/plain",
6451
6486
  title: value.annotation.filename,
6452
6487
  filename: value.annotation.filename,
@@ -6462,7 +6497,7 @@ var OpenAIResponsesLanguageModel = class {
6462
6497
  controller.enqueue({
6463
6498
  type: "source",
6464
6499
  sourceType: "document",
6465
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils34.generateId)(),
6500
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (0, import_provider_utils34.generateId)(),
6466
6501
  mediaType: "text/plain",
6467
6502
  title: value.annotation.filename,
6468
6503
  filename: value.annotation.filename,
@@ -6478,7 +6513,7 @@ var OpenAIResponsesLanguageModel = class {
6478
6513
  controller.enqueue({
6479
6514
  type: "source",
6480
6515
  sourceType: "document",
6481
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils34.generateId)(),
6516
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (0, import_provider_utils34.generateId)(),
6482
6517
  mediaType: "application/octet-stream",
6483
6518
  title: value.annotation.file_id,
6484
6519
  filename: value.annotation.file_id,
@@ -6526,6 +6561,9 @@ function isResponseOutputItemDoneChunk(chunk) {
6526
6561
  function isResponseFinishedChunk(chunk) {
6527
6562
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
6528
6563
  }
6564
+ function isResponseFailedChunk(chunk) {
6565
+ return chunk.type === "response.failed";
6566
+ }
6529
6567
  function isResponseCreatedChunk(chunk) {
6530
6568
  return chunk.type === "response.created";
6531
6569
  }