@ai-sdk/openai 4.0.0-beta.6 → 4.0.0-beta.74

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +644 -24
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +240 -44
  4. package/dist/index.js +3345 -1683
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +390 -36
  7. package/dist/internal/index.js +2707 -1706
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/03-openai.mdx +413 -39
  10. package/package.json +17 -18
  11. package/src/chat/convert-openai-chat-usage.ts +1 -1
  12. package/src/chat/convert-to-openai-chat-messages.ts +96 -68
  13. package/src/chat/map-openai-finish-reason.ts +1 -1
  14. package/src/chat/openai-chat-api.ts +6 -2
  15. package/src/chat/{openai-chat-options.ts → openai-chat-language-model-options.ts} +11 -1
  16. package/src/chat/openai-chat-language-model.ts +82 -148
  17. package/src/chat/openai-chat-prepare-tools.ts +3 -3
  18. package/src/completion/convert-openai-completion-usage.ts +1 -1
  19. package/src/completion/convert-to-openai-completion-prompt.ts +1 -2
  20. package/src/completion/map-openai-finish-reason.ts +1 -1
  21. package/src/completion/openai-completion-api.ts +5 -2
  22. package/src/completion/{openai-completion-options.ts → openai-completion-language-model-options.ts} +5 -1
  23. package/src/completion/openai-completion-language-model.ts +53 -17
  24. package/src/embedding/{openai-embedding-options.ts → openai-embedding-model-options.ts} +5 -1
  25. package/src/embedding/openai-embedding-model.ts +22 -5
  26. package/src/files/openai-files-api.ts +17 -0
  27. package/src/files/openai-files-options.ts +22 -0
  28. package/src/files/openai-files.ts +100 -0
  29. package/src/image/openai-image-model-options.ts +123 -0
  30. package/src/image/openai-image-model.ts +62 -83
  31. package/src/index.ts +15 -6
  32. package/src/internal/index.ts +7 -6
  33. package/src/openai-config.ts +7 -7
  34. package/src/openai-language-model-capabilities.ts +5 -4
  35. package/src/openai-provider.ts +80 -9
  36. package/src/openai-stream-error.ts +181 -0
  37. package/src/openai-tools.ts +12 -1
  38. package/src/realtime/index.ts +2 -0
  39. package/src/realtime/openai-realtime-event-mapper.ts +436 -0
  40. package/src/realtime/openai-realtime-model-options.ts +3 -0
  41. package/src/realtime/openai-realtime-model.ts +111 -0
  42. package/src/responses/convert-openai-responses-usage.ts +1 -1
  43. package/src/responses/convert-to-openai-responses-input.ts +345 -90
  44. package/src/responses/map-openai-responses-finish-reason.ts +1 -1
  45. package/src/responses/openai-responses-api.ts +186 -17
  46. package/src/responses/{openai-responses-options.ts → openai-responses-language-model-options.ts} +55 -1
  47. package/src/responses/openai-responses-language-model.ts +330 -52
  48. package/src/responses/openai-responses-prepare-tools.ts +129 -18
  49. package/src/responses/openai-responses-provider-metadata.ts +12 -2
  50. package/src/skills/openai-skills-api.ts +31 -0
  51. package/src/skills/openai-skills.ts +83 -0
  52. package/src/speech/{openai-speech-options.ts → openai-speech-model-options.ts} +5 -1
  53. package/src/speech/openai-speech-model.ts +23 -7
  54. package/src/tool/apply-patch.ts +33 -32
  55. package/src/tool/code-interpreter.ts +40 -41
  56. package/src/tool/custom.ts +2 -8
  57. package/src/tool/file-search.ts +3 -3
  58. package/src/tool/image-generation.ts +2 -2
  59. package/src/tool/local-shell.ts +2 -2
  60. package/src/tool/mcp.ts +3 -3
  61. package/src/tool/shell.ts +9 -4
  62. package/src/tool/tool-search.ts +98 -0
  63. package/src/tool/web-search-preview.ts +2 -2
  64. package/src/tool/web-search.ts +10 -2
  65. package/src/transcription/{openai-transcription-options.ts → openai-transcription-model-options.ts} +5 -1
  66. package/src/transcription/openai-transcription-model.ts +35 -13
  67. package/dist/index.d.mts +0 -1107
  68. package/dist/index.mjs +0 -6509
  69. package/dist/index.mjs.map +0 -1
  70. package/dist/internal/index.d.mts +0 -1137
  71. package/dist/internal/index.mjs +0 -6322
  72. package/dist/internal/index.mjs.map +0 -1
  73. package/src/image/openai-image-options.ts +0 -31
@@ -0,0 +1,100 @@
1
+ import type {
2
+ FilesV4,
3
+ FilesV4UploadFileCallOptions,
4
+ FilesV4UploadFileResult,
5
+ } from '@ai-sdk/provider';
6
+ import {
7
+ combineHeaders,
8
+ convertInlineFileDataToUint8Array,
9
+ createJsonResponseHandler,
10
+ parseProviderOptions,
11
+ postFormDataToApi,
12
+ type FetchFunction,
13
+ } from '@ai-sdk/provider-utils';
14
+ import { openaiFailedResponseHandler } from '../openai-error';
15
+ import { openaiFilesResponseSchema } from './openai-files-api';
16
+ import {
17
+ openaiFilesOptionsSchema,
18
+ type OpenAIFilesOptions,
19
+ } from './openai-files-options';
20
+ interface OpenAIFilesConfig {
21
+ provider: string;
22
+ baseURL: string;
23
+ headers: () => Record<string, string | undefined>;
24
+ fetch?: FetchFunction;
25
+ }
26
+
27
+ export class OpenAIFiles implements FilesV4 {
28
+ readonly specificationVersion = 'v4';
29
+
30
+ get provider(): string {
31
+ return this.config.provider;
32
+ }
33
+
34
+ constructor(private readonly config: OpenAIFilesConfig) {}
35
+
36
+ async uploadFile({
37
+ data,
38
+ mediaType,
39
+ filename,
40
+ providerOptions,
41
+ }: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult> {
42
+ const openaiOptions = (await parseProviderOptions({
43
+ provider: 'openai',
44
+ providerOptions,
45
+ schema: openaiFilesOptionsSchema,
46
+ })) as OpenAIFilesOptions | undefined;
47
+
48
+ const fileBytes = convertInlineFileDataToUint8Array(data);
49
+
50
+ const blob = new Blob([fileBytes], {
51
+ type: mediaType,
52
+ });
53
+
54
+ const formData = new FormData();
55
+ if (filename != null) {
56
+ formData.append('file', blob, filename);
57
+ } else {
58
+ formData.append('file', blob);
59
+ }
60
+ formData.append('purpose', openaiOptions?.purpose ?? 'assistants');
61
+
62
+ if (openaiOptions?.expiresAfter != null) {
63
+ formData.append('expires_after', String(openaiOptions.expiresAfter));
64
+ }
65
+
66
+ const { value: response } = await postFormDataToApi({
67
+ url: `${this.config.baseURL}/files`,
68
+ headers: combineHeaders(this.config.headers()),
69
+ formData,
70
+ failedResponseHandler: openaiFailedResponseHandler,
71
+ successfulResponseHandler: createJsonResponseHandler(
72
+ openaiFilesResponseSchema,
73
+ ),
74
+ fetch: this.config.fetch,
75
+ });
76
+
77
+ return {
78
+ warnings: [],
79
+ providerReference: { openai: response.id },
80
+ ...((response.filename ?? filename)
81
+ ? { filename: response.filename ?? filename }
82
+ : {}),
83
+ ...(mediaType != null ? { mediaType } : {}),
84
+ providerMetadata: {
85
+ openai: {
86
+ ...(response.filename != null ? { filename: response.filename } : {}),
87
+ ...(response.purpose != null ? { purpose: response.purpose } : {}),
88
+ ...(response.bytes != null ? { bytes: response.bytes } : {}),
89
+ ...(response.created_at != null
90
+ ? { createdAt: response.created_at }
91
+ : {}),
92
+ ...(response.status != null ? { status: response.status } : {}),
93
+ ...(response.expires_at != null
94
+ ? { expiresAt: response.expires_at }
95
+ : {}),
96
+ },
97
+ },
98
+ };
99
+ }
100
+ }
@@ -0,0 +1,123 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ export type OpenAIImageModelId =
9
+ | 'dall-e-3'
10
+ | 'dall-e-2'
11
+ | 'gpt-image-1'
12
+ | 'gpt-image-1-mini'
13
+ | 'gpt-image-1.5'
14
+ | 'gpt-image-2'
15
+ | 'chatgpt-image-latest'
16
+ | (string & {});
17
+
18
+ // https://platform.openai.com/docs/guides/images
19
+ export const modelMaxImagesPerCall: Record<OpenAIImageModelId, number> = {
20
+ 'dall-e-3': 1,
21
+ 'dall-e-2': 10,
22
+ 'gpt-image-1': 10,
23
+ 'gpt-image-1-mini': 10,
24
+ 'gpt-image-1.5': 10,
25
+ 'gpt-image-2': 10,
26
+ 'chatgpt-image-latest': 10,
27
+ };
28
+
29
+ const defaultResponseFormatPrefixes = [
30
+ 'chatgpt-image-',
31
+ 'gpt-image-1-mini',
32
+ 'gpt-image-1.5',
33
+ 'gpt-image-1',
34
+ 'gpt-image-2',
35
+ ];
36
+
37
+ export function hasDefaultResponseFormat(modelId: string): boolean {
38
+ return defaultResponseFormatPrefixes.some(prefix =>
39
+ modelId.startsWith(prefix),
40
+ );
41
+ }
42
+
43
+ const baseImageModelOptionsObject = z.object({
44
+ /**
45
+ * Quality of the generated image(s).
46
+ *
47
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
48
+ */
49
+ quality: z
50
+ .enum(['standard', 'hd', 'low', 'medium', 'high', 'auto'])
51
+ .optional(),
52
+
53
+ /**
54
+ * Background behavior for the generated image(s).
55
+ *
56
+ * If `transparent`, the output format must support transparency
57
+ * (i.e. `png` or `webp`).
58
+ */
59
+ background: z.enum(['transparent', 'opaque', 'auto']).optional(),
60
+
61
+ /**
62
+ * Format in which the generated image(s) are returned.
63
+ */
64
+ outputFormat: z.enum(['png', 'jpeg', 'webp']).optional(),
65
+
66
+ /**
67
+ * Compression level (0-100) for the generated image(s). Applies to the
68
+ * `jpeg` and `webp` output formats.
69
+ */
70
+ outputCompression: z.number().int().min(0).max(100).optional(),
71
+
72
+ /**
73
+ * A unique identifier representing your end-user, which can help OpenAI
74
+ * to monitor and detect abuse.
75
+ */
76
+ user: z.string().optional(),
77
+ });
78
+
79
+ export const openaiImageModelOptions = lazySchema(() =>
80
+ zodSchema(baseImageModelOptionsObject),
81
+ );
82
+
83
+ export type OpenAIImageModelOptions = InferSchema<
84
+ typeof openaiImageModelOptions
85
+ >;
86
+
87
+ export const openaiImageModelGenerationOptions = lazySchema(() =>
88
+ zodSchema(
89
+ baseImageModelOptionsObject.extend({
90
+ /**
91
+ * Style of the generated image. `vivid` produces hyper-real and
92
+ * dramatic images; `natural` produces more subdued, less hyper-real
93
+ * looking images.
94
+ */
95
+ style: z.enum(['vivid', 'natural']).optional(),
96
+
97
+ /**
98
+ * Content moderation level for the generated image(s). `low` applies
99
+ * less restrictive filtering.
100
+ */
101
+ moderation: z.enum(['auto', 'low']).optional(),
102
+ }),
103
+ ),
104
+ );
105
+
106
+ export type OpenAIImageModelGenerationOptions = InferSchema<
107
+ typeof openaiImageModelGenerationOptions
108
+ >;
109
+
110
+ export const openaiImageModelEditOptions = lazySchema(() =>
111
+ zodSchema(
112
+ baseImageModelOptionsObject.extend({
113
+ /**
114
+ * Fidelity of the output image(s) to the input image(s).
115
+ */
116
+ inputFidelity: z.enum(['high', 'low']).optional(),
117
+ }),
118
+ ),
119
+ );
120
+
121
+ export type OpenAIImageModelEditOptions = InferSchema<
122
+ typeof openaiImageModelEditOptions
123
+ >;
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ImageModelV4,
3
3
  ImageModelV4File,
4
4
  SharedV4Warning,
@@ -9,18 +9,24 @@ import {
9
9
  convertToFormData,
10
10
  createJsonResponseHandler,
11
11
  downloadBlob,
12
+ parseProviderOptions,
12
13
  postFormDataToApi,
13
14
  postJsonToApi,
15
+ serializeModelOptions,
16
+ WORKFLOW_DESERIALIZE,
17
+ WORKFLOW_SERIALIZE,
14
18
  } from '@ai-sdk/provider-utils';
15
- import { OpenAIConfig } from '../openai-config';
19
+ import type { OpenAIConfig } from '../openai-config';
16
20
  import { openaiFailedResponseHandler } from '../openai-error';
17
21
  import { openaiImageResponseSchema } from './openai-image-api';
18
22
  import {
19
- OpenAIImageModelId,
20
23
  hasDefaultResponseFormat,
21
24
  modelMaxImagesPerCall,
22
- } from './openai-image-options';
23
-
25
+ openaiImageModelEditOptions,
26
+ openaiImageModelGenerationOptions,
27
+ type OpenAIImageModelEditOptions,
28
+ type OpenAIImageModelId,
29
+ } from './openai-image-model-options';
24
30
  interface OpenAIImageModelConfig extends OpenAIConfig {
25
31
  _internal?: {
26
32
  currentDate?: () => Date;
@@ -30,6 +36,20 @@ interface OpenAIImageModelConfig extends OpenAIConfig {
30
36
  export class OpenAIImageModel implements ImageModelV4 {
31
37
  readonly specificationVersion = 'v4';
32
38
 
39
+ static [WORKFLOW_SERIALIZE](model: OpenAIImageModel) {
40
+ return serializeModelOptions({
41
+ modelId: model.modelId,
42
+ config: model.config,
43
+ });
44
+ }
45
+
46
+ static [WORKFLOW_DESERIALIZE](options: {
47
+ modelId: OpenAIImageModelId;
48
+ config: OpenAIImageModelConfig;
49
+ }) {
50
+ return new OpenAIImageModel(options.modelId, options.config);
51
+ }
52
+
33
53
  get maxImagesPerCall(): number {
34
54
  return modelMaxImagesPerCall[this.modelId] ?? 1;
35
55
  }
@@ -75,12 +95,19 @@ export class OpenAIImageModel implements ImageModelV4 {
75
95
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
76
96
 
77
97
  if (files != null) {
98
+ const openaiOptions =
99
+ (await parseProviderOptions({
100
+ provider: 'openai',
101
+ providerOptions,
102
+ schema: openaiImageModelEditOptions,
103
+ })) ?? {};
104
+
78
105
  const { value: response, responseHeaders } = await postFormDataToApi({
79
106
  url: this.config.url({
80
107
  path: '/images/edits',
81
108
  modelId: this.modelId,
82
109
  }),
83
- headers: combineHeaders(this.config.headers(), headers),
110
+ headers: combineHeaders(this.config.headers?.(), headers),
84
111
  formData: convertToFormData<OpenAIImageEditInput>({
85
112
  model: this.modelId,
86
113
  prompt,
@@ -105,7 +132,12 @@ export class OpenAIImageModel implements ImageModelV4 {
105
132
  mask: mask != null ? await fileToBlob(mask) : undefined,
106
133
  n,
107
134
  size,
108
- ...(providerOptions.openai ?? {}),
135
+ quality: openaiOptions.quality,
136
+ background: openaiOptions.background,
137
+ output_format: openaiOptions.outputFormat,
138
+ output_compression: openaiOptions.outputCompression,
139
+ input_fidelity: openaiOptions.inputFidelity,
140
+ user: openaiOptions.user,
109
141
  }),
110
142
  failedResponseHandler: openaiFailedResponseHandler,
111
143
  successfulResponseHandler: createJsonResponseHandler(
@@ -153,18 +185,31 @@ export class OpenAIImageModel implements ImageModelV4 {
153
185
  };
154
186
  }
155
187
 
188
+ const openaiOptions =
189
+ (await parseProviderOptions({
190
+ provider: 'openai',
191
+ providerOptions,
192
+ schema: openaiImageModelGenerationOptions,
193
+ })) ?? {};
194
+
156
195
  const { value: response, responseHeaders } = await postJsonToApi({
157
196
  url: this.config.url({
158
197
  path: '/images/generations',
159
198
  modelId: this.modelId,
160
199
  }),
161
- headers: combineHeaders(this.config.headers(), headers),
200
+ headers: combineHeaders(this.config.headers?.(), headers),
162
201
  body: {
163
202
  model: this.modelId,
164
203
  prompt,
165
204
  n,
166
205
  size,
167
- ...(providerOptions.openai ?? {}),
206
+ quality: openaiOptions.quality,
207
+ style: openaiOptions.style,
208
+ background: openaiOptions.background,
209
+ moderation: openaiOptions.moderation,
210
+ output_format: openaiOptions.outputFormat,
211
+ output_compression: openaiOptions.outputCompression,
212
+ user: openaiOptions.user,
168
213
  ...(!hasDefaultResponseFormat(this.modelId)
169
214
  ? { response_format: 'b64_json' }
170
215
  : {}),
@@ -251,84 +296,18 @@ function distributeTokenDetails(
251
296
  }
252
297
 
253
298
  type OpenAIImageEditInput = {
254
- /**
255
- * Allows to set transparency for the background of the generated image(s).
256
- * This parameter is only supported for `gpt-image-1`. Must be one of
257
- * `transparent`, `opaque` or `auto` (default value). When `auto` is used, the
258
- * model will automatically determine the best background for the image.
259
- *
260
- * If `transparent`, the output format needs to support transparency, so it
261
- * should be set to either `png` (default value) or `webp`.
262
- *
263
- */
264
- background?: 'transparent' | 'opaque' | 'auto';
265
- /**
266
- * The image(s) to edit. Must be a supported image file or an array of images.
267
- *
268
- * For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less
269
- * than 50MB. You can provide up to 16 images.
270
- *
271
- * For `dall-e-2`, you can only provide one image, and it should be a square
272
- * `png` file less than 4MB.
273
- *
274
- */
299
+ model: OpenAIImageModelId;
300
+ prompt?: string;
275
301
  image: Blob | Blob[];
276
- input_fidelity?: ('high' | 'low') | null;
277
- /**
278
- * An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.
279
- */
280
302
  mask?: Blob;
281
- /**
282
- * The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1` is used.
283
- */
284
- model?: 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | (string & {});
285
- /**
286
- * The number of images to generate. Must be between 1 and 10.
287
- */
288
303
  n?: number;
289
- /**
290
- * The compression level (0-100%) for the generated images. This parameter
291
- * is only supported for `gpt-image-1` with the `webp` or `jpeg` output
292
- * formats, and defaults to 100.
293
- *
294
- */
295
- output_compression?: number;
296
- /**
297
- * The format in which the generated images are returned. This parameter is
298
- * only supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
299
- * The default value is `png`.
300
- *
301
- */
302
- output_format?: 'png' | 'jpeg' | 'webp';
303
- partial_images?: number | null;
304
- /**
305
- * A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
306
- */
307
- prompt?: string;
308
- /**
309
- * The quality of the image that will be generated. `high`, `medium` and `low` are only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality. Defaults to `auto`.
310
- *
311
- */
312
- quality?: 'standard' | 'low' | 'medium' | 'high' | 'auto';
313
- /**
314
- * The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1` will always return base64-encoded images.
315
- */
316
- response_format?: 'url' | 'b64_json';
317
- /**
318
- * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
319
- */
320
304
  size?: `${number}x${number}`;
321
- /**
322
- * Edit the image in streaming mode. Defaults to `false`. See the
323
- * [Image generation guide](https://platform.openai.com/docs/guides/image-generation) for more information.
324
- *
325
- */
326
- stream?: boolean;
327
- /**
328
- * A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
329
- *
330
- */
331
- user?: string;
305
+ quality?: OpenAIImageModelEditOptions['quality'];
306
+ background?: OpenAIImageModelEditOptions['background'];
307
+ output_format?: OpenAIImageModelEditOptions['outputFormat'];
308
+ output_compression?: OpenAIImageModelEditOptions['outputCompression'];
309
+ input_fidelity?: OpenAIImageModelEditOptions['inputFidelity'];
310
+ user?: OpenAIImageModelEditOptions['user'];
332
311
  };
333
312
 
334
313
  async function fileToBlob(
package/src/index.ts CHANGED
@@ -1,20 +1,29 @@
1
1
  export { createOpenAI, openai } from './openai-provider';
2
2
  export type { OpenAIProvider, OpenAIProviderSettings } from './openai-provider';
3
+ export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel } from './realtime/openai-realtime-model';
4
+ export type { OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig } from './realtime/openai-realtime-model';
3
5
  export type {
4
6
  OpenAILanguageModelResponsesOptions,
5
7
  /** @deprecated Use `OpenAILanguageModelResponsesOptions` instead. */
6
8
  OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions,
7
- } from './responses/openai-responses-options';
9
+ } from './responses/openai-responses-language-model-options';
8
10
  export type {
9
11
  OpenAILanguageModelChatOptions,
10
12
  /** @deprecated Use `OpenAILanguageModelChatOptions` instead. */
11
13
  OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions,
12
- } from './chat/openai-chat-options';
13
- export type { OpenAILanguageModelCompletionOptions } from './completion/openai-completion-options';
14
- export type { OpenAIEmbeddingModelOptions } from './embedding/openai-embedding-options';
15
- export type { OpenAISpeechModelOptions } from './speech/openai-speech-options';
16
- export type { OpenAITranscriptionModelOptions } from './transcription/openai-transcription-options';
14
+ } from './chat/openai-chat-language-model-options';
17
15
  export type {
16
+ OpenAIImageModelOptions,
17
+ OpenAIImageModelGenerationOptions,
18
+ OpenAIImageModelEditOptions,
19
+ } from './image/openai-image-model-options';
20
+ export type { OpenAILanguageModelCompletionOptions } from './completion/openai-completion-language-model-options';
21
+ export type { OpenAIEmbeddingModelOptions } from './embedding/openai-embedding-model-options';
22
+ export type { OpenAISpeechModelOptions } from './speech/openai-speech-model-options';
23
+ export type { OpenAITranscriptionModelOptions } from './transcription/openai-transcription-model-options';
24
+ export type { OpenAIFilesOptions } from './files/openai-files-options';
25
+ export type {
26
+ OpenaiResponsesCompactionProviderMetadata,
18
27
  OpenaiResponsesProviderMetadata,
19
28
  OpenaiResponsesReasoningProviderMetadata,
20
29
  OpenaiResponsesTextProviderMetadata,
@@ -1,19 +1,20 @@
1
1
  export * from '../chat/openai-chat-language-model';
2
- export * from '../chat/openai-chat-options';
2
+ export * from '../chat/openai-chat-language-model-options';
3
3
  export * from '../completion/openai-completion-language-model';
4
- export * from '../completion/openai-completion-options';
4
+ export * from '../completion/openai-completion-language-model-options';
5
5
  export * from '../embedding/openai-embedding-model';
6
- export * from '../embedding/openai-embedding-options';
6
+ export * from '../embedding/openai-embedding-model-options';
7
7
  export * from '../image/openai-image-model';
8
- export * from '../image/openai-image-options';
8
+ export * from '../image/openai-image-model-options';
9
9
  export * from '../transcription/openai-transcription-model';
10
- export * from '../transcription/openai-transcription-options';
10
+ export * from '../transcription/openai-transcription-model-options';
11
11
  export * from '../speech/openai-speech-model';
12
- export * from '../speech/openai-speech-options';
12
+ export * from '../speech/openai-speech-model-options';
13
13
  export * from '../responses/openai-responses-language-model';
14
14
  export * from '../responses/openai-responses-provider-metadata';
15
15
  export * from '../tool/apply-patch';
16
16
  export * from '../tool/code-interpreter';
17
17
  export * from '../tool/file-search';
18
18
  export * from '../tool/image-generation';
19
+ export * from '../tool/web-search';
19
20
  export * from '../tool/web-search-preview';
@@ -1,18 +1,18 @@
1
- import { FetchFunction } from '@ai-sdk/provider-utils';
1
+ import type { FetchFunction } from '@ai-sdk/provider-utils';
2
2
 
3
3
  export type OpenAIConfig = {
4
4
  provider: string;
5
5
  url: (options: { modelId: string; path: string }) => string;
6
- headers: () => Record<string, string | undefined>;
6
+ headers?: () => Record<string, string | undefined>;
7
7
  fetch?: FetchFunction;
8
8
  generateId?: () => string;
9
9
  /**
10
- * File ID prefixes used to identify file IDs in Responses API.
11
- * When undefined, all file data is treated as base64 content.
10
+ * This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
11
+ * in file part data instead. File ID prefixes used to identify file IDs
12
+ * in Responses API. When undefined, all string file data is treated as
13
+ * base64 content.
12
14
  *
13
- * Examples:
14
- * - OpenAI: ['file-'] for IDs like 'file-abc123'
15
- * - Azure OpenAI: ['assistant-'] for IDs like 'assistant-abc123'
15
+ * TODO: remove in v8
16
16
  */
17
17
  fileIdPrefixes?: readonly string[];
18
18
  };
@@ -20,10 +20,10 @@ export function getOpenAILanguageModelCapabilities(
20
20
 
21
21
  const supportsPriorityProcessing =
22
22
  modelId.startsWith('gpt-4') ||
23
- modelId.startsWith('gpt-5-mini') ||
24
23
  (modelId.startsWith('gpt-5') &&
25
24
  !modelId.startsWith('gpt-5-nano') &&
26
- !modelId.startsWith('gpt-5-chat')) ||
25
+ !modelId.startsWith('gpt-5-chat') &&
26
+ !modelId.startsWith('gpt-5.4-nano')) ||
27
27
  modelId.startsWith('o3') ||
28
28
  modelId.startsWith('o4-mini');
29
29
 
@@ -36,12 +36,13 @@ export function getOpenAILanguageModelCapabilities(
36
36
  (modelId.startsWith('gpt-5') && !modelId.startsWith('gpt-5-chat'));
37
37
 
38
38
  // https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
39
- // GPT-5.1, GPT-5.2, and GPT-5.4 support temperature, topP, logProbs when reasoningEffort is none
39
+ // GPT-5.1 and later model families support temperature, topP, logProbs when reasoningEffort is none.
40
40
  const supportsNonReasoningParameters =
41
41
  modelId.startsWith('gpt-5.1') ||
42
42
  modelId.startsWith('gpt-5.2') ||
43
43
  modelId.startsWith('gpt-5.3') ||
44
- modelId.startsWith('gpt-5.4');
44
+ modelId.startsWith('gpt-5.4') ||
45
+ modelId.startsWith('gpt-5.5');
45
46
 
46
47
  const systemMessageMode = isReasoningModel ? 'developer' : 'system';
47
48