@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.0-beta.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 365da1a: Add `gpt-5.4-mini`, `gpt-5.4-mini-2026-03-17`, `gpt-5.4-nano`, and `gpt-5.4-nano-2026-03-17` models.
8
+
9
+ ## 4.0.0-beta.14
10
+
11
+ ### Patch Changes
12
+
13
+ - e6376c2: fix(openai): preserve raw finish reason for failed responses stream events
14
+
15
+ Handle `response.failed` chunks in Responses API streaming so `finishReason.raw` is preserved from `incomplete_details.reason` (e.g. `max_output_tokens`), and map failed-without-reason cases to unified `error` instead of `other`.
16
+
17
+ ## 4.0.0-beta.13
18
+
19
+ ### Patch Changes
20
+
21
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
22
+ - Updated dependencies [3887c70]
23
+ - @ai-sdk/provider-utils@5.0.0-beta.6
24
+ - @ai-sdk/provider@4.0.0-beta.4
25
+
3
26
  ## 4.0.0-beta.12
4
27
 
5
28
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4,
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- 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 & {});
6
+ 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 & {});
7
7
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
8
8
  logitBias?: Record<number, number> | undefined;
9
9
  logprobs?: number | boolean | undefined;
@@ -206,6 +206,28 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
206
206
  } | null | undefined;
207
207
  service_tier?: string | null | undefined;
208
208
  };
209
+ } | {
210
+ type: "response.failed";
211
+ response: {
212
+ error?: {
213
+ message: string;
214
+ code?: string | null | undefined;
215
+ } | null | undefined;
216
+ incomplete_details?: {
217
+ reason: string;
218
+ } | null | undefined;
219
+ usage?: {
220
+ input_tokens: number;
221
+ output_tokens: number;
222
+ input_tokens_details?: {
223
+ cached_tokens?: number | null | undefined;
224
+ } | null | undefined;
225
+ output_tokens_details?: {
226
+ reasoning_tokens?: number | null | undefined;
227
+ } | null | undefined;
228
+ } | null | undefined;
229
+ service_tier?: string | null | undefined;
230
+ };
209
231
  } | {
210
232
  type: "response.created";
211
233
  response: {
@@ -975,7 +997,7 @@ declare const openaiTools: {
975
997
  }>;
976
998
  };
977
999
 
978
- 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 & {});
1000
+ 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 & {});
979
1001
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
980
1002
  conversation?: string | null | undefined;
981
1003
  include?: ("file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4,
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- 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 & {});
6
+ 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 & {});
7
7
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
8
8
  logitBias?: Record<number, number> | undefined;
9
9
  logprobs?: number | boolean | undefined;
@@ -206,6 +206,28 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
206
206
  } | null | undefined;
207
207
  service_tier?: string | null | undefined;
208
208
  };
209
+ } | {
210
+ type: "response.failed";
211
+ response: {
212
+ error?: {
213
+ message: string;
214
+ code?: string | null | undefined;
215
+ } | null | undefined;
216
+ incomplete_details?: {
217
+ reason: string;
218
+ } | null | undefined;
219
+ usage?: {
220
+ input_tokens: number;
221
+ output_tokens: number;
222
+ input_tokens_details?: {
223
+ cached_tokens?: number | null | undefined;
224
+ } | null | undefined;
225
+ output_tokens_details?: {
226
+ reasoning_tokens?: number | null | undefined;
227
+ } | null | undefined;
228
+ } | null | undefined;
229
+ service_tier?: string | null | undefined;
230
+ };
209
231
  } | {
210
232
  type: "response.created";
211
233
  response: {
@@ -975,7 +997,7 @@ declare const openaiTools: {
975
997
  }>;
976
998
  };
977
999
 
978
- 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 & {});
1000
+ 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 & {});
979
1001
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
980
1002
  conversation?: string | null | undefined;
981
1003
  include?: ("file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
55
55
  // src/openai-language-model-capabilities.ts
56
56
  function getOpenAILanguageModelCapabilities(modelId) {
57
57
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
58
- 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");
58
+ 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");
59
59
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
60
60
  const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
61
61
  const systemMessageMode = isReasoningModel ? "developer" : "system";
@@ -671,9 +671,10 @@ var OpenAIChatLanguageModel = class {
671
671
  seed,
672
672
  tools,
673
673
  toolChoice,
674
+ reasoning,
674
675
  providerOptions
675
676
  }) {
676
- var _a, _b, _c, _d, _e;
677
+ var _a, _b, _c, _d, _e, _f;
677
678
  const warnings = [];
678
679
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
679
680
  provider: "openai",
@@ -681,18 +682,19 @@ var OpenAIChatLanguageModel = class {
681
682
  schema: openaiLanguageModelChatOptions
682
683
  })) != null ? _a : {};
683
684
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
684
- const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
685
+ const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : (0, import_provider_utils5.isCustomReasoning)(reasoning) ? reasoning : void 0;
686
+ const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
685
687
  if (topK != null) {
686
688
  warnings.push({ type: "unsupported", feature: "topK" });
687
689
  }
688
690
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
689
691
  {
690
692
  prompt,
691
- systemMessageMode: (_c = openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
693
+ systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
692
694
  }
693
695
  );
694
696
  warnings.push(...messageWarnings);
695
- const strictJsonSchema = (_d = openaiOptions.strictJsonSchema) != null ? _d : true;
697
+ const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
696
698
  const baseArgs = {
697
699
  // model id:
698
700
  model: this.modelId,
@@ -713,7 +715,7 @@ var OpenAIChatLanguageModel = class {
713
715
  json_schema: {
714
716
  schema: responseFormat.schema,
715
717
  strict: strictJsonSchema,
716
- name: (_e = responseFormat.name) != null ? _e : "response",
718
+ name: (_f = responseFormat.name) != null ? _f : "response",
717
719
  description: responseFormat.description
718
720
  }
719
721
  } : { type: "json_object" } : void 0,
@@ -726,7 +728,7 @@ var OpenAIChatLanguageModel = class {
726
728
  store: openaiOptions.store,
727
729
  metadata: openaiOptions.metadata,
728
730
  prediction: openaiOptions.prediction,
729
- reasoning_effort: openaiOptions.reasoningEffort,
731
+ reasoning_effort: resolvedReasoningEffort,
730
732
  service_tier: openaiOptions.serviceTier,
731
733
  prompt_cache_key: openaiOptions.promptCacheKey,
732
734
  prompt_cache_retention: openaiOptions.promptCacheRetention,
@@ -735,7 +737,7 @@ var OpenAIChatLanguageModel = class {
735
737
  messages
736
738
  };
737
739
  if (isReasoningModel) {
738
- if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
740
+ if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
739
741
  if (baseArgs.temperature != null) {
740
742
  baseArgs.temperature = void 0;
741
743
  warnings.push({
@@ -3319,6 +3321,23 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
3319
3321
  service_tier: import_v421.z.string().nullish()
3320
3322
  })
3321
3323
  }),
3324
+ import_v421.z.object({
3325
+ type: import_v421.z.literal("response.failed"),
3326
+ response: import_v421.z.object({
3327
+ error: import_v421.z.object({
3328
+ code: import_v421.z.string().nullish(),
3329
+ message: import_v421.z.string()
3330
+ }).nullish(),
3331
+ incomplete_details: import_v421.z.object({ reason: import_v421.z.string() }).nullish(),
3332
+ usage: import_v421.z.object({
3333
+ input_tokens: import_v421.z.number(),
3334
+ input_tokens_details: import_v421.z.object({ cached_tokens: import_v421.z.number().nullish() }).nullish(),
3335
+ output_tokens: import_v421.z.number(),
3336
+ output_tokens_details: import_v421.z.object({ reasoning_tokens: import_v421.z.number().nullish() }).nullish()
3337
+ }).nullish(),
3338
+ service_tier: import_v421.z.string().nullish()
3339
+ })
3340
+ }),
3322
3341
  import_v421.z.object({
3323
3342
  type: import_v421.z.literal("response.created"),
3324
3343
  response: import_v421.z.object({
@@ -4151,6 +4170,10 @@ var openaiResponsesReasoningModelIds = [
4151
4170
  "gpt-5.3-codex",
4152
4171
  "gpt-5.4",
4153
4172
  "gpt-5.4-2026-03-05",
4173
+ "gpt-5.4-mini",
4174
+ "gpt-5.4-mini-2026-03-17",
4175
+ "gpt-5.4-nano",
4176
+ "gpt-5.4-nano-2026-03-17",
4154
4177
  "gpt-5.4-pro",
4155
4178
  "gpt-5.4-pro-2026-03-05"
4156
4179
  ];
@@ -4654,12 +4677,13 @@ var OpenAIResponsesLanguageModel = class {
4654
4677
  frequencyPenalty,
4655
4678
  seed,
4656
4679
  prompt,
4680
+ reasoning,
4657
4681
  providerOptions,
4658
4682
  tools,
4659
4683
  toolChoice,
4660
4684
  responseFormat
4661
4685
  }) {
4662
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4686
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4663
4687
  const warnings = [];
4664
4688
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4665
4689
  if (topK != null) {
@@ -4690,7 +4714,8 @@ var OpenAIResponsesLanguageModel = class {
4690
4714
  schema: openaiLanguageModelResponsesOptionsSchema
4691
4715
  });
4692
4716
  }
4693
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
4717
+ const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (0, import_provider_utils29.isCustomReasoning)(reasoning) ? reasoning : void 0;
4718
+ const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
4694
4719
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
4695
4720
  warnings.push({
4696
4721
  type: "unsupported",
@@ -4727,10 +4752,10 @@ var OpenAIResponsesLanguageModel = class {
4727
4752
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4728
4753
  prompt,
4729
4754
  toolNameMapping,
4730
- systemMessageMode: (_b = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4755
+ systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4731
4756
  providerOptionsName,
4732
4757
  fileIdPrefixes: this.config.fileIdPrefixes,
4733
- store: (_c = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c : true,
4758
+ store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4734
4759
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4735
4760
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4736
4761
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -4738,7 +4763,7 @@ var OpenAIResponsesLanguageModel = class {
4738
4763
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
4739
4764
  });
4740
4765
  warnings.push(...inputWarnings);
4741
- const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
4766
+ const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4742
4767
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4743
4768
  function addInclude(key) {
4744
4769
  if (include == null) {
@@ -4754,9 +4779,9 @@ var OpenAIResponsesLanguageModel = class {
4754
4779
  if (topLogprobs) {
4755
4780
  addInclude("message.output_text.logprobs");
4756
4781
  }
4757
- const webSearchToolName = (_e = tools == null ? void 0 : tools.find(
4782
+ const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4758
4783
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4759
- )) == null ? void 0 : _e.name;
4784
+ )) == null ? void 0 : _f.name;
4760
4785
  if (webSearchToolName) {
4761
4786
  addInclude("web_search_call.action.sources");
4762
4787
  }
@@ -4779,7 +4804,7 @@ var OpenAIResponsesLanguageModel = class {
4779
4804
  format: responseFormat.schema != null ? {
4780
4805
  type: "json_schema",
4781
4806
  strict: strictJsonSchema,
4782
- name: (_f = responseFormat.name) != null ? _f : "response",
4807
+ name: (_g = responseFormat.name) != null ? _g : "response",
4783
4808
  description: responseFormat.description,
4784
4809
  schema: responseFormat.schema
4785
4810
  } : { type: "json_object" }
@@ -4813,10 +4838,10 @@ var OpenAIResponsesLanguageModel = class {
4813
4838
  }))
4814
4839
  },
4815
4840
  // model-specific settings:
4816
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4841
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4817
4842
  reasoning: {
4818
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
4819
- effort: openaiOptions.reasoningEffort
4843
+ ...resolvedReasoningEffort != null && {
4844
+ effort: resolvedReasoningEffort
4820
4845
  },
4821
4846
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
4822
4847
  summary: openaiOptions.reasoningSummary
@@ -4825,7 +4850,7 @@ var OpenAIResponsesLanguageModel = class {
4825
4850
  }
4826
4851
  };
4827
4852
  if (isReasoningModel) {
4828
- if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
4853
+ if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
4829
4854
  if (baseArgs.temperature != null) {
4830
4855
  baseArgs.temperature = void 0;
4831
4856
  warnings.push({
@@ -4875,9 +4900,9 @@ var OpenAIResponsesLanguageModel = class {
4875
4900
  });
4876
4901
  delete baseArgs.service_tier;
4877
4902
  }
4878
- const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
4903
+ const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
4879
4904
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
4880
- )) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
4905
+ )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
4881
4906
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
4882
4907
  return {
4883
4908
  webSearchToolName,
@@ -5433,7 +5458,7 @@ var OpenAIResponsesLanguageModel = class {
5433
5458
  controller.enqueue({ type: "stream-start", warnings });
5434
5459
  },
5435
5460
  transform(chunk, controller) {
5436
- 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;
5461
+ 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;
5437
5462
  if (options.includeRawChunks) {
5438
5463
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5439
5464
  }
@@ -6170,13 +6195,23 @@ var OpenAIResponsesLanguageModel = class {
6170
6195
  if (typeof value.response.service_tier === "string") {
6171
6196
  serviceTier = value.response.service_tier;
6172
6197
  }
6198
+ } else if (isResponseFailedChunk(value)) {
6199
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6200
+ finishReason = {
6201
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6202
+ finishReason: incompleteReason,
6203
+ hasFunctionCall
6204
+ }) : "error",
6205
+ raw: incompleteReason != null ? incompleteReason : "error"
6206
+ };
6207
+ usage = (_z = value.response.usage) != null ? _z : void 0;
6173
6208
  } else if (isResponseAnnotationAddedChunk(value)) {
6174
6209
  ongoingAnnotations.push(value.annotation);
6175
6210
  if (value.annotation.type === "url_citation") {
6176
6211
  controller.enqueue({
6177
6212
  type: "source",
6178
6213
  sourceType: "url",
6179
- id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : (0, import_provider_utils29.generateId)(),
6214
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils29.generateId)(),
6180
6215
  url: value.annotation.url,
6181
6216
  title: value.annotation.title
6182
6217
  });
@@ -6184,7 +6219,7 @@ var OpenAIResponsesLanguageModel = class {
6184
6219
  controller.enqueue({
6185
6220
  type: "source",
6186
6221
  sourceType: "document",
6187
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : (0, import_provider_utils29.generateId)(),
6222
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0, import_provider_utils29.generateId)(),
6188
6223
  mediaType: "text/plain",
6189
6224
  title: value.annotation.filename,
6190
6225
  filename: value.annotation.filename,
@@ -6200,7 +6235,7 @@ var OpenAIResponsesLanguageModel = class {
6200
6235
  controller.enqueue({
6201
6236
  type: "source",
6202
6237
  sourceType: "document",
6203
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils29.generateId)(),
6238
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (0, import_provider_utils29.generateId)(),
6204
6239
  mediaType: "text/plain",
6205
6240
  title: value.annotation.filename,
6206
6241
  filename: value.annotation.filename,
@@ -6216,7 +6251,7 @@ var OpenAIResponsesLanguageModel = class {
6216
6251
  controller.enqueue({
6217
6252
  type: "source",
6218
6253
  sourceType: "document",
6219
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils29.generateId)(),
6254
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (0, import_provider_utils29.generateId)(),
6220
6255
  mediaType: "application/octet-stream",
6221
6256
  title: value.annotation.file_id,
6222
6257
  filename: value.annotation.file_id,
@@ -6264,6 +6299,9 @@ function isResponseOutputItemDoneChunk(chunk) {
6264
6299
  function isResponseFinishedChunk(chunk) {
6265
6300
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
6266
6301
  }
6302
+ function isResponseFailedChunk(chunk) {
6303
+ return chunk.type === "response.failed";
6304
+ }
6267
6305
  function isResponseCreatedChunk(chunk) {
6268
6306
  return chunk.type === "response.created";
6269
6307
  }
@@ -6678,7 +6716,7 @@ var OpenAITranscriptionModel = class {
6678
6716
  };
6679
6717
 
6680
6718
  // src/version.ts
6681
- var VERSION = true ? "4.0.0-beta.12" : "0.0.0-test";
6719
+ var VERSION = true ? "4.0.0-beta.15" : "0.0.0-test";
6682
6720
 
6683
6721
  // src/openai-provider.ts
6684
6722
  function createOpenAI(options = {}) {