@ai-sdk/openai 3.0.32 → 3.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "3.0.32",
3
+ "version": "3.0.34",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -21,17 +21,25 @@ export type OpenAIChatModelId =
21
21
  | 'gpt-4o-2024-05-13'
22
22
  | 'gpt-4o-2024-08-06'
23
23
  | 'gpt-4o-2024-11-20'
24
+ | 'gpt-4o-audio-preview'
25
+ | 'gpt-4o-audio-preview-2024-12-17'
26
+ | 'gpt-4o-audio-preview-2025-06-03'
24
27
  | 'gpt-4o-mini'
25
28
  | 'gpt-4o-mini-2024-07-18'
29
+ | 'gpt-4o-mini-audio-preview'
30
+ | 'gpt-4o-mini-audio-preview-2024-12-17'
31
+ | 'gpt-4o-search-preview'
32
+ | 'gpt-4o-search-preview-2025-03-11'
33
+ | 'gpt-4o-mini-search-preview'
34
+ | 'gpt-4o-mini-search-preview-2025-03-11'
26
35
  | 'gpt-4-turbo'
27
36
  | 'gpt-4-turbo-2024-04-09'
28
37
  | 'gpt-4'
29
38
  | 'gpt-4-0613'
30
- | 'gpt-4.5-preview'
31
- | 'gpt-4.5-preview-2025-02-27'
32
39
  | 'gpt-3.5-turbo-0125'
33
40
  | 'gpt-3.5-turbo'
34
41
  | 'gpt-3.5-turbo-1106'
42
+ | 'gpt-3.5-turbo-16k'
35
43
  | 'chatgpt-4o-latest'
36
44
  | 'gpt-5'
37
45
  | 'gpt-5-2025-08-07'
@@ -41,10 +49,13 @@ export type OpenAIChatModelId =
41
49
  | 'gpt-5-nano-2025-08-07'
42
50
  | 'gpt-5-chat-latest'
43
51
  | 'gpt-5.1'
52
+ | 'gpt-5.1-2025-11-13'
44
53
  | 'gpt-5.1-chat-latest'
45
54
  | 'gpt-5.2'
55
+ | 'gpt-5.2-2025-12-11'
46
56
  | 'gpt-5.2-chat-latest'
47
57
  | 'gpt-5.2-pro'
58
+ | 'gpt-5.2-pro-2025-12-11'
48
59
  | (string & {});
49
60
 
50
61
  export const openaiLanguageModelChatOptions = lazySchema(() =>
@@ -2,7 +2,10 @@ import { InferSchema, lazySchema, zodSchema } from '@ai-sdk/provider-utils';
2
2
  import { z } from 'zod/v4';
3
3
 
4
4
  // https://platform.openai.com/docs/models
5
- export type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
5
+ export type OpenAICompletionModelId =
6
+ | 'gpt-3.5-turbo-instruct'
7
+ | 'gpt-3.5-turbo-instruct-0914'
8
+ | (string & {});
6
9
 
7
10
  export const openaiLanguageModelCompletionOptions = lazySchema(() =>
8
11
  zodSchema(
@@ -4,6 +4,7 @@ export type OpenAIImageModelId =
4
4
  | 'gpt-image-1'
5
5
  | 'gpt-image-1-mini'
6
6
  | 'gpt-image-1.5'
7
+ | 'chatgpt-image-latest'
7
8
  | (string & {});
8
9
 
9
10
  // https://platform.openai.com/docs/guides/images
@@ -13,9 +14,11 @@ export const modelMaxImagesPerCall: Record<OpenAIImageModelId, number> = {
13
14
  'gpt-image-1': 10,
14
15
  'gpt-image-1-mini': 10,
15
16
  'gpt-image-1.5': 10,
17
+ 'chatgpt-image-latest': 10,
16
18
  };
17
19
 
18
20
  const defaultResponseFormatPrefixes = [
21
+ 'chatgpt-image-',
19
22
  'gpt-image-1-mini',
20
23
  'gpt-image-1.5',
21
24
  'gpt-image-1',
@@ -159,8 +159,12 @@ export async function convertToOpenAIResponsesInput({
159
159
  for (const part of content) {
160
160
  switch (part.type) {
161
161
  case 'text': {
162
- const id = part.providerOptions?.[providerOptionsName]?.itemId as
163
- | string
162
+ const providerOpts = part.providerOptions?.[providerOptionsName];
163
+ const id = providerOpts?.itemId as string | undefined;
164
+ const phase = providerOpts?.phase as
165
+ | 'commentary'
166
+ | 'final_answer'
167
+ | null
164
168
  | undefined;
165
169
 
166
170
  // when using conversation, skip items that already exist in the conversation context to avoid "Duplicate item found" errors
@@ -178,6 +182,7 @@ export async function convertToOpenAIResponsesInput({
178
182
  role: 'assistant',
179
183
  content: [{ type: 'output_text', text: part.text }],
180
184
  id,
185
+ ...(phase != null && { phase }),
181
186
  });
182
187
 
183
188
  break;
@@ -71,6 +71,7 @@ export type OpenAIResponsesAssistantMessage = {
71
71
  role: 'assistant';
72
72
  content: Array<{ type: 'output_text'; text: string }>;
73
73
  id?: string;
74
+ phase?: 'commentary' | 'final_answer' | null;
74
75
  };
75
76
 
76
77
  export type OpenAIResponsesFunctionCall = {
@@ -443,6 +444,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
443
444
  z.object({
444
445
  type: z.literal('message'),
445
446
  id: z.string(),
447
+ phase: z.enum(['commentary', 'final_answer']).nullish(),
446
448
  }),
447
449
  z.object({
448
450
  type: z.literal('reasoning'),
@@ -562,6 +564,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
562
564
  z.object({
563
565
  type: z.literal('message'),
564
566
  id: z.string(),
567
+ phase: z.enum(['commentary', 'final_answer']).nullish(),
565
568
  }),
566
569
  z.object({
567
570
  type: z.literal('reasoning'),
@@ -913,6 +916,7 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
913
916
  type: z.literal('message'),
914
917
  role: z.literal('assistant'),
915
918
  id: z.string(),
919
+ phase: z.enum(['commentary', 'final_answer']).nullish(),
916
920
  content: z.array(
917
921
  z.object({
918
922
  type: z.literal('output_text'),
@@ -612,6 +612,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
612
612
 
613
613
  const providerMetadata: SharedV3ProviderMetadata[string] = {
614
614
  itemId: part.id,
615
+ ...(part.phase != null && { phase: part.phase }),
615
616
  ...(contentPart.annotations.length > 0 && {
616
617
  annotations: contentPart.annotations,
617
618
  }),
@@ -1008,6 +1009,9 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
1008
1009
  >['annotation']
1009
1010
  > = [];
1010
1011
 
1012
+ // track the phase of the current message being streamed
1013
+ let activeMessagePhase: 'commentary' | 'final_answer' | undefined;
1014
+
1011
1015
  // flag that checks if there have been client-side tool calls (not executed by openai)
1012
1016
  let hasFunctionCall = false;
1013
1017
 
@@ -1200,12 +1204,16 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
1200
1204
  // shell_call_output is handled in output_item.done
1201
1205
  } else if (value.item.type === 'message') {
1202
1206
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
1207
+ activeMessagePhase = value.item.phase ?? undefined;
1203
1208
  controller.enqueue({
1204
1209
  type: 'text-start',
1205
1210
  id: value.item.id,
1206
1211
  providerMetadata: {
1207
1212
  [providerOptionsName]: {
1208
1213
  itemId: value.item.id,
1214
+ ...(value.item.phase != null && {
1215
+ phase: value.item.phase,
1216
+ }),
1209
1217
  },
1210
1218
  },
1211
1219
  });
@@ -1232,12 +1240,15 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
1232
1240
  }
1233
1241
  } else if (isResponseOutputItemDoneChunk(value)) {
1234
1242
  if (value.item.type === 'message') {
1243
+ const phase = value.item.phase ?? activeMessagePhase;
1244
+ activeMessagePhase = undefined;
1235
1245
  controller.enqueue({
1236
1246
  type: 'text-end',
1237
1247
  id: value.item.id,
1238
1248
  providerMetadata: {
1239
1249
  [providerOptionsName]: {
1240
1250
  itemId: value.item.id,
1251
+ ...(phase != null && { phase }),
1241
1252
  ...(ongoingAnnotations.length > 0 && {
1242
1253
  annotations: ongoingAnnotations,
1243
1254
  }),
@@ -105,13 +105,16 @@ export type OpenAIResponsesModelId =
105
105
  | 'gpt-4o-mini'
106
106
  | 'gpt-4o'
107
107
  | 'gpt-5.1'
108
+ | 'gpt-5.1-2025-11-13'
108
109
  | 'gpt-5.1-chat-latest'
109
110
  | 'gpt-5.1-codex-mini'
110
111
  | 'gpt-5.1-codex'
111
112
  | 'gpt-5.1-codex-max'
112
113
  | 'gpt-5.2'
114
+ | 'gpt-5.2-2025-12-11'
113
115
  | 'gpt-5.2-chat-latest'
114
116
  | 'gpt-5.2-pro'
117
+ | 'gpt-5.2-pro-2025-12-11'
115
118
  | 'gpt-5.2-codex'
116
119
  | 'gpt-5.3-codex'
117
120
  | 'gpt-5-2025-08-07'
@@ -130,6 +133,8 @@ export type OpenAIResponsesModelId =
130
133
  | 'o3-mini-2025-01-31'
131
134
  | 'o3-mini'
132
135
  | 'o3'
136
+ | 'o4-mini'
137
+ | 'o4-mini-2025-04-16'
133
138
  | (string & {});
134
139
 
135
140
  // TODO AI SDK 6: use optional here instead of nullish
@@ -32,6 +32,7 @@ export type OpenaiResponsesProviderMetadata = {
32
32
 
33
33
  export type ResponsesTextProviderMetadata = {
34
34
  itemId: string;
35
+ phase?: 'commentary' | 'final_answer' | null;
35
36
  annotations?: Array<ResponsesOutputTextAnnotationProviderMetadata>;
36
37
  };
37
38
 
@@ -3,8 +3,12 @@ import { z } from 'zod/v4';
3
3
 
4
4
  export type OpenAISpeechModelId =
5
5
  | 'tts-1'
6
+ | 'tts-1-1106'
6
7
  | 'tts-1-hd'
8
+ | 'tts-1-hd-1106'
7
9
  | 'gpt-4o-mini-tts'
10
+ | 'gpt-4o-mini-tts-2025-03-20'
11
+ | 'gpt-4o-mini-tts-2025-12-15'
8
12
  | (string & {});
9
13
 
10
14
  // https://platform.openai.com/docs/api-reference/audio/createSpeech
@@ -4,7 +4,10 @@ import { z } from 'zod/v4';
4
4
  export type OpenAITranscriptionModelId =
5
5
  | 'whisper-1'
6
6
  | 'gpt-4o-mini-transcribe'
7
+ | 'gpt-4o-mini-transcribe-2025-03-20'
8
+ | 'gpt-4o-mini-transcribe-2025-12-15'
7
9
  | 'gpt-4o-transcribe'
10
+ | 'gpt-4o-transcribe-diarize'
8
11
  | (string & {});
9
12
 
10
13
  // https://platform.openai.com/docs/api-reference/audio/createTranscription