@ai-sdk/openai 3.0.106 → 3.0.108

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
+ ## 3.0.108
4
+
5
+ ### Patch Changes
6
+
7
+ - 019eec8: feat(openai): add support for the gpt-6-astra
8
+
9
+ ## 3.0.107
10
+
11
+ ### Patch Changes
12
+
13
+ - 8844beb: fix(openai): flatten mid-stream Responses error events
14
+ - cf1ba03: fix(openai): preserve complete Responses API raw usage objects
15
+
3
16
  ## 3.0.106
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { JSONValue, ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3,
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-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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | (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' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | (string & {});
7
7
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
8
8
  logitBias?: Record<number, number> | undefined;
9
9
  logprobs?: number | boolean | undefined;
@@ -250,23 +250,24 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
250
250
  } | {
251
251
  type: "response.completed" | "response.incomplete";
252
252
  response: {
253
- usage: {
253
+ incomplete_details?: {
254
+ reason: string;
255
+ } | null | undefined;
256
+ usage?: (Record<string, JSONValue | undefined> & {
254
257
  input_tokens: number;
255
258
  output_tokens: number;
256
- input_tokens_details?: {
259
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
257
260
  cached_tokens?: number | null | undefined;
258
261
  cache_write_tokens?: number | null | undefined;
259
262
  orchestration_input_tokens?: number | null | undefined;
260
263
  orchestration_input_cached_tokens?: number | null | undefined;
261
- } | null | undefined;
262
- output_tokens_details?: {
264
+ }) | null | undefined;
265
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
263
266
  reasoning_tokens?: number | null | undefined;
264
267
  orchestration_output_tokens?: number | null | undefined;
265
- } | null | undefined;
266
- };
267
- incomplete_details?: {
268
- reason: string;
269
- } | null | undefined;
268
+ }) | null | undefined;
269
+ total_tokens?: number | undefined;
270
+ }) | null | undefined;
270
271
  reasoning?: {
271
272
  context?: string | null | undefined;
272
273
  } | null | undefined;
@@ -283,20 +284,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
283
284
  incomplete_details?: {
284
285
  reason: string;
285
286
  } | null | undefined;
286
- usage?: {
287
+ usage?: (Record<string, JSONValue | undefined> & {
287
288
  input_tokens: number;
288
289
  output_tokens: number;
289
- input_tokens_details?: {
290
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
290
291
  cached_tokens?: number | null | undefined;
291
292
  cache_write_tokens?: number | null | undefined;
292
293
  orchestration_input_tokens?: number | null | undefined;
293
294
  orchestration_input_cached_tokens?: number | null | undefined;
294
- } | null | undefined;
295
- output_tokens_details?: {
295
+ }) | null | undefined;
296
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
296
297
  reasoning_tokens?: number | null | undefined;
297
298
  orchestration_output_tokens?: number | null | undefined;
298
- } | null | undefined;
299
- } | null | undefined;
299
+ }) | null | undefined;
300
+ total_tokens?: number | undefined;
301
+ }) | null | undefined;
300
302
  reasoning?: {
301
303
  context?: string | null | undefined;
302
304
  } | null | undefined;
@@ -1092,7 +1094,7 @@ declare const openaiTools: {
1092
1094
  }>;
1093
1095
  };
1094
1096
 
1095
- 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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | '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 & {});
1097
+ 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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | '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 & {});
1096
1098
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
1097
1099
  conversation?: string | null | undefined;
1098
1100
  include?: ("web_search_call.results" | "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, ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3,
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-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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | (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' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | (string & {});
7
7
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
8
8
  logitBias?: Record<number, number> | undefined;
9
9
  logprobs?: number | boolean | undefined;
@@ -250,23 +250,24 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
250
250
  } | {
251
251
  type: "response.completed" | "response.incomplete";
252
252
  response: {
253
- usage: {
253
+ incomplete_details?: {
254
+ reason: string;
255
+ } | null | undefined;
256
+ usage?: (Record<string, JSONValue | undefined> & {
254
257
  input_tokens: number;
255
258
  output_tokens: number;
256
- input_tokens_details?: {
259
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
257
260
  cached_tokens?: number | null | undefined;
258
261
  cache_write_tokens?: number | null | undefined;
259
262
  orchestration_input_tokens?: number | null | undefined;
260
263
  orchestration_input_cached_tokens?: number | null | undefined;
261
- } | null | undefined;
262
- output_tokens_details?: {
264
+ }) | null | undefined;
265
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
263
266
  reasoning_tokens?: number | null | undefined;
264
267
  orchestration_output_tokens?: number | null | undefined;
265
- } | null | undefined;
266
- };
267
- incomplete_details?: {
268
- reason: string;
269
- } | null | undefined;
268
+ }) | null | undefined;
269
+ total_tokens?: number | undefined;
270
+ }) | null | undefined;
270
271
  reasoning?: {
271
272
  context?: string | null | undefined;
272
273
  } | null | undefined;
@@ -283,20 +284,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
283
284
  incomplete_details?: {
284
285
  reason: string;
285
286
  } | null | undefined;
286
- usage?: {
287
+ usage?: (Record<string, JSONValue | undefined> & {
287
288
  input_tokens: number;
288
289
  output_tokens: number;
289
- input_tokens_details?: {
290
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
290
291
  cached_tokens?: number | null | undefined;
291
292
  cache_write_tokens?: number | null | undefined;
292
293
  orchestration_input_tokens?: number | null | undefined;
293
294
  orchestration_input_cached_tokens?: number | null | undefined;
294
- } | null | undefined;
295
- output_tokens_details?: {
295
+ }) | null | undefined;
296
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
296
297
  reasoning_tokens?: number | null | undefined;
297
298
  orchestration_output_tokens?: number | null | undefined;
298
- } | null | undefined;
299
- } | null | undefined;
299
+ }) | null | undefined;
300
+ total_tokens?: number | undefined;
301
+ }) | null | undefined;
300
302
  reasoning?: {
301
303
  context?: string | null | undefined;
302
304
  } | null | undefined;
@@ -1092,7 +1094,7 @@ declare const openaiTools: {
1092
1094
  }>;
1093
1095
  };
1094
1096
 
1095
- 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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | '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 & {});
1097
+ 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.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | '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 & {});
1096
1098
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
1097
1099
  conversation?: string | null | undefined;
1098
1100
  include?: ("web_search_call.results" | "file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
package/dist/index.js CHANGED
@@ -90,6 +90,22 @@ function getGptVersion(modelId) {
90
90
 
91
91
  // src/openai-stream-error.ts
92
92
  var import_provider = require("@ai-sdk/provider");
93
+ function createOpenAIProviderStreamError(frame) {
94
+ var _a2, _b;
95
+ const streamError = parseStreamError(frame);
96
+ if (streamError == null) {
97
+ return void 0;
98
+ }
99
+ const statusCode = getStatusCode(streamError);
100
+ return {
101
+ message: streamError.message,
102
+ type: (_a2 = streamError.type) != null ? _a2 : void 0,
103
+ code: (_b = streamError.code) != null ? _b : void 0,
104
+ statusCode,
105
+ isRetryable: isRetryableStreamError(streamError, statusCode),
106
+ data: frame
107
+ };
108
+ }
93
109
  async function throwIfOpenAIStreamErrorBeforeOutput({
94
110
  stream,
95
111
  getError,
@@ -161,16 +177,14 @@ function parseStreamError(frame) {
161
177
  return typeof (responseError == null ? void 0 : responseError.message) === "string" ? {
162
178
  message: responseError.message,
163
179
  code: getStringOrNumber(responseError.code),
164
- type: "response.failed",
165
- frame
180
+ type: "response.failed"
166
181
  } : void 0;
167
182
  }
168
183
  const error = (_a2 = asRecord(value.error)) != null ? _a2 : value;
169
184
  return typeof error.message === "string" && (asRecord(value.error) != null || typeof error.type === "string" || "code" in error || "param" in error) ? {
170
185
  message: error.message,
171
186
  code: getStringOrNumber(error.code),
172
- type: typeof error.type === "string" ? error.type : void 0,
173
- frame
187
+ type: typeof error.type === "string" ? error.type : void 0
174
188
  } : void 0;
175
189
  }
176
190
  function getStatusCode(error) {
@@ -210,6 +224,15 @@ function getStringOrNumber(value) {
210
224
  function isHttpErrorStatusCode(value) {
211
225
  return Number.isInteger(value) && value >= 400 && value <= 599;
212
226
  }
227
+ function isRetryableStatusCode(statusCode) {
228
+ return statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500;
229
+ }
230
+ function isRetryableStreamError(error, statusCode) {
231
+ if (error.code === "insufficient_quota" || error.type === "insufficient_quota") {
232
+ return false;
233
+ }
234
+ return isRetryableStatusCode(statusCode);
235
+ }
213
236
 
214
237
  // src/chat/convert-openai-chat-usage.ts
215
238
  function convertOpenAIChatUsage(usage) {
@@ -4008,6 +4031,31 @@ var jsonValueSchema2 = import_v422.z.lazy(
4008
4031
  import_v422.z.record(import_v422.z.string(), jsonValueSchema2.optional())
4009
4032
  ])
4010
4033
  );
4034
+ var jsonObjectSchema = import_v422.z.record(import_v422.z.string(), jsonValueSchema2.optional());
4035
+ var openaiResponsesUsageSchema = import_v422.z.intersection(
4036
+ jsonObjectSchema,
4037
+ import_v422.z.object({
4038
+ input_tokens: import_v422.z.number(),
4039
+ input_tokens_details: import_v422.z.intersection(
4040
+ jsonObjectSchema,
4041
+ import_v422.z.object({
4042
+ cached_tokens: import_v422.z.number().nullish(),
4043
+ cache_write_tokens: import_v422.z.number().nullish(),
4044
+ orchestration_input_tokens: import_v422.z.number().nullish(),
4045
+ orchestration_input_cached_tokens: import_v422.z.number().nullish()
4046
+ })
4047
+ ).nullish(),
4048
+ output_tokens: import_v422.z.number(),
4049
+ output_tokens_details: import_v422.z.intersection(
4050
+ jsonObjectSchema,
4051
+ import_v422.z.object({
4052
+ reasoning_tokens: import_v422.z.number().nullish(),
4053
+ orchestration_output_tokens: import_v422.z.number().nullish()
4054
+ })
4055
+ ).nullish(),
4056
+ total_tokens: import_v422.z.number().optional()
4057
+ })
4058
+ );
4011
4059
  function isRecord(value) {
4012
4060
  return value != null && typeof value === "object" && !Array.isArray(value);
4013
4061
  }
@@ -4119,20 +4167,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4119
4167
  type: import_v422.z.enum(["response.completed", "response.incomplete"]),
4120
4168
  response: import_v422.z.object({
4121
4169
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
4122
- usage: import_v422.z.object({
4123
- input_tokens: import_v422.z.number(),
4124
- input_tokens_details: import_v422.z.object({
4125
- cached_tokens: import_v422.z.number().nullish(),
4126
- cache_write_tokens: import_v422.z.number().nullish(),
4127
- orchestration_input_tokens: import_v422.z.number().nullish(),
4128
- orchestration_input_cached_tokens: import_v422.z.number().nullish()
4129
- }).nullish(),
4130
- output_tokens: import_v422.z.number(),
4131
- output_tokens_details: import_v422.z.object({
4132
- reasoning_tokens: import_v422.z.number().nullish(),
4133
- orchestration_output_tokens: import_v422.z.number().nullish()
4134
- }).nullish()
4135
- }),
4170
+ usage: openaiResponsesUsageSchema.nullish(),
4136
4171
  reasoning: import_v422.z.object({
4137
4172
  context: import_v422.z.string().nullish()
4138
4173
  }).nullish(),
@@ -4148,20 +4183,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4148
4183
  message: import_v422.z.string()
4149
4184
  }).nullish(),
4150
4185
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
4151
- usage: import_v422.z.object({
4152
- input_tokens: import_v422.z.number(),
4153
- input_tokens_details: import_v422.z.object({
4154
- cached_tokens: import_v422.z.number().nullish(),
4155
- cache_write_tokens: import_v422.z.number().nullish(),
4156
- orchestration_input_tokens: import_v422.z.number().nullish(),
4157
- orchestration_input_cached_tokens: import_v422.z.number().nullish()
4158
- }).nullish(),
4159
- output_tokens: import_v422.z.number(),
4160
- output_tokens_details: import_v422.z.object({
4161
- reasoning_tokens: import_v422.z.number().nullish(),
4162
- orchestration_output_tokens: import_v422.z.number().nullish()
4163
- }).nullish()
4164
- }).nullish(),
4186
+ usage: openaiResponsesUsageSchema.nullish(),
4165
4187
  reasoning: import_v422.z.object({
4166
4188
  context: import_v422.z.string().nullish()
4167
4189
  }).nullish(),
@@ -4927,20 +4949,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
4927
4949
  context: import_v422.z.string().nullish()
4928
4950
  }).nullish(),
4929
4951
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
4930
- usage: import_v422.z.object({
4931
- input_tokens: import_v422.z.number(),
4932
- input_tokens_details: import_v422.z.object({
4933
- cached_tokens: import_v422.z.number().nullish(),
4934
- cache_write_tokens: import_v422.z.number().nullish(),
4935
- orchestration_input_tokens: import_v422.z.number().nullish(),
4936
- orchestration_input_cached_tokens: import_v422.z.number().nullish()
4937
- }).nullish(),
4938
- output_tokens: import_v422.z.number(),
4939
- output_tokens_details: import_v422.z.object({
4940
- reasoning_tokens: import_v422.z.number().nullish(),
4941
- orchestration_output_tokens: import_v422.z.number().nullish()
4942
- }).nullish()
4943
- }).optional()
4952
+ usage: openaiResponsesUsageSchema.nullish()
4944
4953
  })
4945
4954
  )
4946
4955
  );
@@ -4991,7 +5000,8 @@ var openaiResponsesReasoningModelIds = [
4991
5000
  "gpt-5.6",
4992
5001
  "gpt-5.6-luna",
4993
5002
  "gpt-5.6-sol",
4994
- "gpt-5.6-terra"
5003
+ "gpt-5.6-terra",
5004
+ "gpt-6-astra"
4995
5005
  ];
4996
5006
  var openaiResponsesModelIds = [
4997
5007
  "gpt-4.1",
@@ -6527,7 +6537,7 @@ var OpenAIResponsesLanguageModel = class {
6527
6537
  controller.enqueue({ type: "stream-start", warnings });
6528
6538
  },
6529
6539
  transform(chunk, controller) {
6530
- var _a3, _b2, _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, _M, _N, _O, _P;
6540
+ var _a3, _b2, _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, _M, _N, _O, _P, _Q, _R, _S;
6531
6541
  if (options.includeRawChunks) {
6532
6542
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6533
6543
  }
@@ -7348,15 +7358,15 @@ var OpenAIResponsesLanguageModel = class {
7348
7358
  raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7349
7359
  };
7350
7360
  }
7351
- usage = value.response.usage;
7361
+ usage = (_A = value.response.usage) != null ? _A : void 0;
7352
7362
  if (typeof value.response.service_tier === "string") {
7353
7363
  serviceTier = value.response.service_tier;
7354
7364
  }
7355
- if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
7365
+ if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7356
7366
  reasoningContext = value.response.reasoning.context;
7357
7367
  }
7358
7368
  } else if (isResponseFailedChunk(value)) {
7359
- const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
7369
+ const incompleteReason = (_C = value.response.incomplete_details) == null ? void 0 : _C.reason;
7360
7370
  finishReason = {
7361
7371
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
7362
7372
  finishReason: incompleteReason,
@@ -7364,23 +7374,24 @@ var OpenAIResponsesLanguageModel = class {
7364
7374
  }) : "error",
7365
7375
  raw: incompleteReason != null ? incompleteReason : "error"
7366
7376
  };
7367
- usage = (_C = value.response.usage) != null ? _C : void 0;
7368
- if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
7377
+ usage = (_D = value.response.usage) != null ? _D : void 0;
7378
+ if (((_E = value.response.reasoning) == null ? void 0 : _E.context) != null) {
7369
7379
  reasoningContext = value.response.reasoning.context;
7370
7380
  }
7371
7381
  if (!encounteredStreamError && value.response.error != null) {
7372
7382
  encounteredStreamError = true;
7383
+ const error = {
7384
+ type: "response.failed",
7385
+ sequence_number: value.sequence_number,
7386
+ response: {
7387
+ error: value.response.error,
7388
+ incomplete_details: value.response.incomplete_details,
7389
+ service_tier: value.response.service_tier
7390
+ }
7391
+ };
7373
7392
  controller.enqueue({
7374
7393
  type: "error",
7375
- error: {
7376
- type: "response.failed",
7377
- sequence_number: value.sequence_number,
7378
- response: {
7379
- error: value.response.error,
7380
- incomplete_details: value.response.incomplete_details,
7381
- service_tier: value.response.service_tier
7382
- }
7383
- }
7394
+ error: (_F = createOpenAIProviderStreamError(error)) != null ? _F : error
7384
7395
  });
7385
7396
  }
7386
7397
  } else if (isResponseAnnotationAddedChunk(value)) {
@@ -7389,7 +7400,7 @@ var OpenAIResponsesLanguageModel = class {
7389
7400
  controller.enqueue({
7390
7401
  type: "source",
7391
7402
  sourceType: "url",
7392
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils31.generateId)(),
7403
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (0, import_provider_utils31.generateId)(),
7393
7404
  url: value.annotation.url,
7394
7405
  title: value.annotation.title
7395
7406
  });
@@ -7397,7 +7408,7 @@ var OpenAIResponsesLanguageModel = class {
7397
7408
  controller.enqueue({
7398
7409
  type: "source",
7399
7410
  sourceType: "document",
7400
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils31.generateId)(),
7411
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (0, import_provider_utils31.generateId)(),
7401
7412
  mediaType: "text/plain",
7402
7413
  title: value.annotation.filename,
7403
7414
  filename: value.annotation.filename,
@@ -7413,7 +7424,7 @@ var OpenAIResponsesLanguageModel = class {
7413
7424
  controller.enqueue({
7414
7425
  type: "source",
7415
7426
  sourceType: "document",
7416
- id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : (0, import_provider_utils31.generateId)(),
7427
+ id: (_O = (_N = (_M = self.config).generateId) == null ? void 0 : _N.call(_M)) != null ? _O : (0, import_provider_utils31.generateId)(),
7417
7428
  mediaType: "text/plain",
7418
7429
  title: value.annotation.filename,
7419
7430
  filename: value.annotation.filename,
@@ -7429,7 +7440,7 @@ var OpenAIResponsesLanguageModel = class {
7429
7440
  controller.enqueue({
7430
7441
  type: "source",
7431
7442
  sourceType: "document",
7432
- id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : (0, import_provider_utils31.generateId)(),
7443
+ id: (_R = (_Q = (_P = self.config).generateId) == null ? void 0 : _Q.call(_P)) != null ? _R : (0, import_provider_utils31.generateId)(),
7433
7444
  mediaType: "application/octet-stream",
7434
7445
  title: value.annotation.file_id,
7435
7446
  filename: value.annotation.file_id,
@@ -7445,7 +7456,10 @@ var OpenAIResponsesLanguageModel = class {
7445
7456
  } else if (isErrorChunk(value)) {
7446
7457
  encounteredStreamError = true;
7447
7458
  finishReason = { unified: "error", raw: "error" };
7448
- controller.enqueue({ type: "error", error: value });
7459
+ controller.enqueue({
7460
+ type: "error",
7461
+ error: (_S = createOpenAIProviderStreamError(value)) != null ? _S : value
7462
+ });
7449
7463
  }
7450
7464
  },
7451
7465
  flush(controller) {
@@ -7948,7 +7962,7 @@ var OpenAITranscriptionModel = class {
7948
7962
  };
7949
7963
 
7950
7964
  // src/version.ts
7951
- var VERSION = true ? "3.0.106" : "0.0.0-test";
7965
+ var VERSION = true ? "3.0.108" : "0.0.0-test";
7952
7966
 
7953
7967
  // src/openai-provider.ts
7954
7968
  function createOpenAI(options = {}) {