@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.
@@ -2,7 +2,7 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { InferSchema, FetchFunction, EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } 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-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 & {});
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' | '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 & {});
6
6
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
7
7
  logitBias?: Record<number, number> | undefined;
8
8
  logprobs?: number | boolean | undefined;
@@ -221,7 +221,7 @@ declare class OpenAISpeechModel implements SpeechModelV3 {
221
221
  doGenerate(options: Parameters<SpeechModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>>;
222
222
  }
223
223
 
224
- 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 & {});
224
+ 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 & {});
225
225
 
226
226
  declare class OpenAIResponsesLanguageModel implements LanguageModelV3 {
227
227
  readonly specificationVersion = "v3";
@@ -298,23 +298,24 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
298
298
  } | {
299
299
  type: "response.completed" | "response.incomplete";
300
300
  response: {
301
- usage: {
301
+ incomplete_details?: {
302
+ reason: string;
303
+ } | null | undefined;
304
+ usage?: (Record<string, JSONValue | undefined> & {
302
305
  input_tokens: number;
303
306
  output_tokens: number;
304
- input_tokens_details?: {
307
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
305
308
  cached_tokens?: number | null | undefined;
306
309
  cache_write_tokens?: number | null | undefined;
307
310
  orchestration_input_tokens?: number | null | undefined;
308
311
  orchestration_input_cached_tokens?: number | null | undefined;
309
- } | null | undefined;
310
- output_tokens_details?: {
312
+ }) | null | undefined;
313
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
311
314
  reasoning_tokens?: number | null | undefined;
312
315
  orchestration_output_tokens?: number | null | undefined;
313
- } | null | undefined;
314
- };
315
- incomplete_details?: {
316
- reason: string;
317
- } | null | undefined;
316
+ }) | null | undefined;
317
+ total_tokens?: number | undefined;
318
+ }) | null | undefined;
318
319
  reasoning?: {
319
320
  context?: string | null | undefined;
320
321
  } | null | undefined;
@@ -331,20 +332,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
331
332
  incomplete_details?: {
332
333
  reason: string;
333
334
  } | null | undefined;
334
- usage?: {
335
+ usage?: (Record<string, JSONValue | undefined> & {
335
336
  input_tokens: number;
336
337
  output_tokens: number;
337
- input_tokens_details?: {
338
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
338
339
  cached_tokens?: number | null | undefined;
339
340
  cache_write_tokens?: number | null | undefined;
340
341
  orchestration_input_tokens?: number | null | undefined;
341
342
  orchestration_input_cached_tokens?: number | null | undefined;
342
- } | null | undefined;
343
- output_tokens_details?: {
343
+ }) | null | undefined;
344
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
344
345
  reasoning_tokens?: number | null | undefined;
345
346
  orchestration_output_tokens?: number | null | undefined;
346
- } | null | undefined;
347
- } | null | undefined;
347
+ }) | null | undefined;
348
+ total_tokens?: number | undefined;
349
+ }) | null | undefined;
348
350
  reasoning?: {
349
351
  context?: string | null | undefined;
350
352
  } | null | undefined;
@@ -2,7 +2,7 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { InferSchema, FetchFunction, EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } 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-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 & {});
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' | '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 & {});
6
6
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
7
7
  logitBias?: Record<number, number> | undefined;
8
8
  logprobs?: number | boolean | undefined;
@@ -221,7 +221,7 @@ declare class OpenAISpeechModel implements SpeechModelV3 {
221
221
  doGenerate(options: Parameters<SpeechModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>>;
222
222
  }
223
223
 
224
- 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 & {});
224
+ 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 & {});
225
225
 
226
226
  declare class OpenAIResponsesLanguageModel implements LanguageModelV3 {
227
227
  readonly specificationVersion = "v3";
@@ -298,23 +298,24 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
298
298
  } | {
299
299
  type: "response.completed" | "response.incomplete";
300
300
  response: {
301
- usage: {
301
+ incomplete_details?: {
302
+ reason: string;
303
+ } | null | undefined;
304
+ usage?: (Record<string, JSONValue | undefined> & {
302
305
  input_tokens: number;
303
306
  output_tokens: number;
304
- input_tokens_details?: {
307
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
305
308
  cached_tokens?: number | null | undefined;
306
309
  cache_write_tokens?: number | null | undefined;
307
310
  orchestration_input_tokens?: number | null | undefined;
308
311
  orchestration_input_cached_tokens?: number | null | undefined;
309
- } | null | undefined;
310
- output_tokens_details?: {
312
+ }) | null | undefined;
313
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
311
314
  reasoning_tokens?: number | null | undefined;
312
315
  orchestration_output_tokens?: number | null | undefined;
313
- } | null | undefined;
314
- };
315
- incomplete_details?: {
316
- reason: string;
317
- } | null | undefined;
316
+ }) | null | undefined;
317
+ total_tokens?: number | undefined;
318
+ }) | null | undefined;
318
319
  reasoning?: {
319
320
  context?: string | null | undefined;
320
321
  } | null | undefined;
@@ -331,20 +332,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
331
332
  incomplete_details?: {
332
333
  reason: string;
333
334
  } | null | undefined;
334
- usage?: {
335
+ usage?: (Record<string, JSONValue | undefined> & {
335
336
  input_tokens: number;
336
337
  output_tokens: number;
337
- input_tokens_details?: {
338
+ input_tokens_details?: (Record<string, JSONValue | undefined> & {
338
339
  cached_tokens?: number | null | undefined;
339
340
  cache_write_tokens?: number | null | undefined;
340
341
  orchestration_input_tokens?: number | null | undefined;
341
342
  orchestration_input_cached_tokens?: number | null | undefined;
342
- } | null | undefined;
343
- output_tokens_details?: {
343
+ }) | null | undefined;
344
+ output_tokens_details?: (Record<string, JSONValue | undefined> & {
344
345
  reasoning_tokens?: number | null | undefined;
345
346
  orchestration_output_tokens?: number | null | undefined;
346
- } | null | undefined;
347
- } | null | undefined;
347
+ }) | null | undefined;
348
+ total_tokens?: number | undefined;
349
+ }) | null | undefined;
348
350
  reasoning?: {
349
351
  context?: string | null | undefined;
350
352
  } | null | undefined;
@@ -125,6 +125,22 @@ function getGptVersion(modelId) {
125
125
 
126
126
  // src/openai-stream-error.ts
127
127
  var import_provider = require("@ai-sdk/provider");
128
+ function createOpenAIProviderStreamError(frame) {
129
+ var _a2, _b;
130
+ const streamError = parseStreamError(frame);
131
+ if (streamError == null) {
132
+ return void 0;
133
+ }
134
+ const statusCode = getStatusCode(streamError);
135
+ return {
136
+ message: streamError.message,
137
+ type: (_a2 = streamError.type) != null ? _a2 : void 0,
138
+ code: (_b = streamError.code) != null ? _b : void 0,
139
+ statusCode,
140
+ isRetryable: isRetryableStreamError(streamError, statusCode),
141
+ data: frame
142
+ };
143
+ }
128
144
  async function throwIfOpenAIStreamErrorBeforeOutput({
129
145
  stream,
130
146
  getError,
@@ -196,16 +212,14 @@ function parseStreamError(frame) {
196
212
  return typeof (responseError == null ? void 0 : responseError.message) === "string" ? {
197
213
  message: responseError.message,
198
214
  code: getStringOrNumber(responseError.code),
199
- type: "response.failed",
200
- frame
215
+ type: "response.failed"
201
216
  } : void 0;
202
217
  }
203
218
  const error = (_a2 = asRecord(value.error)) != null ? _a2 : value;
204
219
  return typeof error.message === "string" && (asRecord(value.error) != null || typeof error.type === "string" || "code" in error || "param" in error) ? {
205
220
  message: error.message,
206
221
  code: getStringOrNumber(error.code),
207
- type: typeof error.type === "string" ? error.type : void 0,
208
- frame
222
+ type: typeof error.type === "string" ? error.type : void 0
209
223
  } : void 0;
210
224
  }
211
225
  function getStatusCode(error) {
@@ -245,6 +259,15 @@ function getStringOrNumber(value) {
245
259
  function isHttpErrorStatusCode(value) {
246
260
  return Number.isInteger(value) && value >= 400 && value <= 599;
247
261
  }
262
+ function isRetryableStatusCode(statusCode) {
263
+ return statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500;
264
+ }
265
+ function isRetryableStreamError(error, statusCode) {
266
+ if (error.code === "insufficient_quota" || error.type === "insufficient_quota") {
267
+ return false;
268
+ }
269
+ return isRetryableStatusCode(statusCode);
270
+ }
248
271
 
249
272
  // src/chat/convert-openai-chat-usage.ts
250
273
  function convertOpenAIChatUsage(usage) {
@@ -3952,6 +3975,31 @@ var jsonValueSchema = import_v418.z.lazy(
3952
3975
  import_v418.z.record(import_v418.z.string(), jsonValueSchema.optional())
3953
3976
  ])
3954
3977
  );
3978
+ var jsonObjectSchema = import_v418.z.record(import_v418.z.string(), jsonValueSchema.optional());
3979
+ var openaiResponsesUsageSchema = import_v418.z.intersection(
3980
+ jsonObjectSchema,
3981
+ import_v418.z.object({
3982
+ input_tokens: import_v418.z.number(),
3983
+ input_tokens_details: import_v418.z.intersection(
3984
+ jsonObjectSchema,
3985
+ import_v418.z.object({
3986
+ cached_tokens: import_v418.z.number().nullish(),
3987
+ cache_write_tokens: import_v418.z.number().nullish(),
3988
+ orchestration_input_tokens: import_v418.z.number().nullish(),
3989
+ orchestration_input_cached_tokens: import_v418.z.number().nullish()
3990
+ })
3991
+ ).nullish(),
3992
+ output_tokens: import_v418.z.number(),
3993
+ output_tokens_details: import_v418.z.intersection(
3994
+ jsonObjectSchema,
3995
+ import_v418.z.object({
3996
+ reasoning_tokens: import_v418.z.number().nullish(),
3997
+ orchestration_output_tokens: import_v418.z.number().nullish()
3998
+ })
3999
+ ).nullish(),
4000
+ total_tokens: import_v418.z.number().optional()
4001
+ })
4002
+ );
3955
4003
  function isRecord(value) {
3956
4004
  return value != null && typeof value === "object" && !Array.isArray(value);
3957
4005
  }
@@ -4063,20 +4111,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
4063
4111
  type: import_v418.z.enum(["response.completed", "response.incomplete"]),
4064
4112
  response: import_v418.z.object({
4065
4113
  incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
4066
- usage: import_v418.z.object({
4067
- input_tokens: import_v418.z.number(),
4068
- input_tokens_details: import_v418.z.object({
4069
- cached_tokens: import_v418.z.number().nullish(),
4070
- cache_write_tokens: import_v418.z.number().nullish(),
4071
- orchestration_input_tokens: import_v418.z.number().nullish(),
4072
- orchestration_input_cached_tokens: import_v418.z.number().nullish()
4073
- }).nullish(),
4074
- output_tokens: import_v418.z.number(),
4075
- output_tokens_details: import_v418.z.object({
4076
- reasoning_tokens: import_v418.z.number().nullish(),
4077
- orchestration_output_tokens: import_v418.z.number().nullish()
4078
- }).nullish()
4079
- }),
4114
+ usage: openaiResponsesUsageSchema.nullish(),
4080
4115
  reasoning: import_v418.z.object({
4081
4116
  context: import_v418.z.string().nullish()
4082
4117
  }).nullish(),
@@ -4092,20 +4127,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
4092
4127
  message: import_v418.z.string()
4093
4128
  }).nullish(),
4094
4129
  incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
4095
- usage: import_v418.z.object({
4096
- input_tokens: import_v418.z.number(),
4097
- input_tokens_details: import_v418.z.object({
4098
- cached_tokens: import_v418.z.number().nullish(),
4099
- cache_write_tokens: import_v418.z.number().nullish(),
4100
- orchestration_input_tokens: import_v418.z.number().nullish(),
4101
- orchestration_input_cached_tokens: import_v418.z.number().nullish()
4102
- }).nullish(),
4103
- output_tokens: import_v418.z.number(),
4104
- output_tokens_details: import_v418.z.object({
4105
- reasoning_tokens: import_v418.z.number().nullish(),
4106
- orchestration_output_tokens: import_v418.z.number().nullish()
4107
- }).nullish()
4108
- }).nullish(),
4130
+ usage: openaiResponsesUsageSchema.nullish(),
4109
4131
  reasoning: import_v418.z.object({
4110
4132
  context: import_v418.z.string().nullish()
4111
4133
  }).nullish(),
@@ -4871,20 +4893,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils26.lazySchema)(
4871
4893
  context: import_v418.z.string().nullish()
4872
4894
  }).nullish(),
4873
4895
  incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
4874
- usage: import_v418.z.object({
4875
- input_tokens: import_v418.z.number(),
4876
- input_tokens_details: import_v418.z.object({
4877
- cached_tokens: import_v418.z.number().nullish(),
4878
- cache_write_tokens: import_v418.z.number().nullish(),
4879
- orchestration_input_tokens: import_v418.z.number().nullish(),
4880
- orchestration_input_cached_tokens: import_v418.z.number().nullish()
4881
- }).nullish(),
4882
- output_tokens: import_v418.z.number(),
4883
- output_tokens_details: import_v418.z.object({
4884
- reasoning_tokens: import_v418.z.number().nullish(),
4885
- orchestration_output_tokens: import_v418.z.number().nullish()
4886
- }).nullish()
4887
- }).optional()
4896
+ usage: openaiResponsesUsageSchema.nullish()
4888
4897
  })
4889
4898
  )
4890
4899
  );
@@ -4935,7 +4944,8 @@ var openaiResponsesReasoningModelIds = [
4935
4944
  "gpt-5.6",
4936
4945
  "gpt-5.6-luna",
4937
4946
  "gpt-5.6-sol",
4938
- "gpt-5.6-terra"
4947
+ "gpt-5.6-terra",
4948
+ "gpt-6-astra"
4939
4949
  ];
4940
4950
  var openaiResponsesModelIds = [
4941
4951
  "gpt-4.1",
@@ -6795,7 +6805,7 @@ var OpenAIResponsesLanguageModel = class {
6795
6805
  controller.enqueue({ type: "stream-start", warnings });
6796
6806
  },
6797
6807
  transform(chunk, controller) {
6798
- 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;
6808
+ 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;
6799
6809
  if (options.includeRawChunks) {
6800
6810
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6801
6811
  }
@@ -7616,15 +7626,15 @@ var OpenAIResponsesLanguageModel = class {
7616
7626
  raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7617
7627
  };
7618
7628
  }
7619
- usage = value.response.usage;
7629
+ usage = (_A = value.response.usage) != null ? _A : void 0;
7620
7630
  if (typeof value.response.service_tier === "string") {
7621
7631
  serviceTier = value.response.service_tier;
7622
7632
  }
7623
- if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
7633
+ if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7624
7634
  reasoningContext = value.response.reasoning.context;
7625
7635
  }
7626
7636
  } else if (isResponseFailedChunk(value)) {
7627
- const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
7637
+ const incompleteReason = (_C = value.response.incomplete_details) == null ? void 0 : _C.reason;
7628
7638
  finishReason = {
7629
7639
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
7630
7640
  finishReason: incompleteReason,
@@ -7632,23 +7642,24 @@ var OpenAIResponsesLanguageModel = class {
7632
7642
  }) : "error",
7633
7643
  raw: incompleteReason != null ? incompleteReason : "error"
7634
7644
  };
7635
- usage = (_C = value.response.usage) != null ? _C : void 0;
7636
- if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
7645
+ usage = (_D = value.response.usage) != null ? _D : void 0;
7646
+ if (((_E = value.response.reasoning) == null ? void 0 : _E.context) != null) {
7637
7647
  reasoningContext = value.response.reasoning.context;
7638
7648
  }
7639
7649
  if (!encounteredStreamError && value.response.error != null) {
7640
7650
  encounteredStreamError = true;
7651
+ const error = {
7652
+ type: "response.failed",
7653
+ sequence_number: value.sequence_number,
7654
+ response: {
7655
+ error: value.response.error,
7656
+ incomplete_details: value.response.incomplete_details,
7657
+ service_tier: value.response.service_tier
7658
+ }
7659
+ };
7641
7660
  controller.enqueue({
7642
7661
  type: "error",
7643
- error: {
7644
- type: "response.failed",
7645
- sequence_number: value.sequence_number,
7646
- response: {
7647
- error: value.response.error,
7648
- incomplete_details: value.response.incomplete_details,
7649
- service_tier: value.response.service_tier
7650
- }
7651
- }
7662
+ error: (_F = createOpenAIProviderStreamError(error)) != null ? _F : error
7652
7663
  });
7653
7664
  }
7654
7665
  } else if (isResponseAnnotationAddedChunk(value)) {
@@ -7657,7 +7668,7 @@ var OpenAIResponsesLanguageModel = class {
7657
7668
  controller.enqueue({
7658
7669
  type: "source",
7659
7670
  sourceType: "url",
7660
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils36.generateId)(),
7671
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (0, import_provider_utils36.generateId)(),
7661
7672
  url: value.annotation.url,
7662
7673
  title: value.annotation.title
7663
7674
  });
@@ -7665,7 +7676,7 @@ var OpenAIResponsesLanguageModel = class {
7665
7676
  controller.enqueue({
7666
7677
  type: "source",
7667
7678
  sourceType: "document",
7668
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils36.generateId)(),
7679
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (0, import_provider_utils36.generateId)(),
7669
7680
  mediaType: "text/plain",
7670
7681
  title: value.annotation.filename,
7671
7682
  filename: value.annotation.filename,
@@ -7681,7 +7692,7 @@ var OpenAIResponsesLanguageModel = class {
7681
7692
  controller.enqueue({
7682
7693
  type: "source",
7683
7694
  sourceType: "document",
7684
- id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : (0, import_provider_utils36.generateId)(),
7695
+ id: (_O = (_N = (_M = self.config).generateId) == null ? void 0 : _N.call(_M)) != null ? _O : (0, import_provider_utils36.generateId)(),
7685
7696
  mediaType: "text/plain",
7686
7697
  title: value.annotation.filename,
7687
7698
  filename: value.annotation.filename,
@@ -7697,7 +7708,7 @@ var OpenAIResponsesLanguageModel = class {
7697
7708
  controller.enqueue({
7698
7709
  type: "source",
7699
7710
  sourceType: "document",
7700
- id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : (0, import_provider_utils36.generateId)(),
7711
+ id: (_R = (_Q = (_P = self.config).generateId) == null ? void 0 : _Q.call(_P)) != null ? _R : (0, import_provider_utils36.generateId)(),
7701
7712
  mediaType: "application/octet-stream",
7702
7713
  title: value.annotation.file_id,
7703
7714
  filename: value.annotation.file_id,
@@ -7713,7 +7724,10 @@ var OpenAIResponsesLanguageModel = class {
7713
7724
  } else if (isErrorChunk(value)) {
7714
7725
  encounteredStreamError = true;
7715
7726
  finishReason = { unified: "error", raw: "error" };
7716
- controller.enqueue({ type: "error", error: value });
7727
+ controller.enqueue({
7728
+ type: "error",
7729
+ error: (_S = createOpenAIProviderStreamError(value)) != null ? _S : value
7730
+ });
7717
7731
  }
7718
7732
  },
7719
7733
  flush(controller) {