@ai-sdk/openai 4.0.0-beta.3 → 4.0.0-beta.31

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 (51) hide show
  1. package/CHANGELOG.md +320 -22
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +139 -36
  4. package/dist/index.js +2343 -1490
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +168 -45
  7. package/dist/internal/index.js +2112 -1511
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/03-openai.mdx +274 -9
  10. package/package.json +9 -12
  11. package/src/chat/convert-openai-chat-usage.ts +2 -2
  12. package/src/chat/convert-to-openai-chat-messages.ts +26 -15
  13. package/src/chat/map-openai-finish-reason.ts +2 -2
  14. package/src/chat/openai-chat-language-model.ts +52 -28
  15. package/src/chat/openai-chat-options.ts +5 -0
  16. package/src/chat/openai-chat-prepare-tools.ts +6 -6
  17. package/src/completion/convert-openai-completion-usage.ts +2 -2
  18. package/src/completion/convert-to-openai-completion-prompt.ts +2 -2
  19. package/src/completion/map-openai-finish-reason.ts +2 -2
  20. package/src/completion/openai-completion-language-model.ts +40 -23
  21. package/src/embedding/openai-embedding-model.ts +23 -6
  22. package/src/files/openai-files-api.ts +17 -0
  23. package/src/files/openai-files-options.ts +18 -0
  24. package/src/files/openai-files.ts +102 -0
  25. package/src/image/openai-image-model.ts +28 -11
  26. package/src/index.ts +2 -0
  27. package/src/openai-config.ts +6 -6
  28. package/src/openai-language-model-capabilities.ts +3 -2
  29. package/src/openai-provider.ts +54 -21
  30. package/src/openai-tools.ts +12 -1
  31. package/src/responses/convert-openai-responses-usage.ts +2 -2
  32. package/src/responses/convert-to-openai-responses-input.ts +211 -37
  33. package/src/responses/map-openai-responses-finish-reason.ts +2 -2
  34. package/src/responses/openai-responses-api.ts +136 -2
  35. package/src/responses/openai-responses-language-model.ts +252 -39
  36. package/src/responses/openai-responses-options.ts +24 -2
  37. package/src/responses/openai-responses-prepare-tools.ts +47 -14
  38. package/src/responses/openai-responses-provider-metadata.ts +10 -0
  39. package/src/skills/openai-skills-api.ts +31 -0
  40. package/src/skills/openai-skills.ts +87 -0
  41. package/src/speech/openai-speech-model.ts +25 -8
  42. package/src/tool/custom.ts +0 -6
  43. package/src/tool/shell.ts +7 -2
  44. package/src/tool/tool-search.ts +98 -0
  45. package/src/transcription/openai-transcription-model.ts +26 -9
  46. package/dist/index.d.mts +0 -1107
  47. package/dist/index.mjs +0 -6497
  48. package/dist/index.mjs.map +0 -1
  49. package/dist/internal/index.d.mts +0 -1137
  50. package/dist/internal/index.mjs +0 -6310
  51. package/dist/internal/index.mjs.map +0 -1
@@ -1,15 +1,21 @@
1
1
  import {
2
- LanguageModelV3CallOptions,
3
- SharedV3Warning,
2
+ LanguageModelV4CallOptions,
3
+ SharedV4ProviderReference,
4
+ SharedV4Warning,
4
5
  UnsupportedFunctionalityError,
5
6
  } from '@ai-sdk/provider';
6
- import { ToolNameMapping, validateTypes } from '@ai-sdk/provider-utils';
7
+ import {
8
+ resolveProviderReference,
9
+ ToolNameMapping,
10
+ validateTypes,
11
+ } from '@ai-sdk/provider-utils';
7
12
  import { codeInterpreterArgsSchema } from '../tool/code-interpreter';
8
13
  import { fileSearchArgsSchema } from '../tool/file-search';
9
14
  import { imageGenerationArgsSchema } from '../tool/image-generation';
10
15
  import { customArgsSchema } from '../tool/custom';
11
16
  import { mcpArgsSchema } from '../tool/mcp';
12
17
  import { shellArgsSchema } from '../tool/shell';
18
+ import { toolSearchArgsSchema } from '../tool/tool-search';
13
19
  import { webSearchArgsSchema } from '../tool/web-search';
14
20
  import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
15
21
  import { OpenAIResponsesTool } from './openai-responses-api';
@@ -20,8 +26,8 @@ export async function prepareResponsesTools({
20
26
  toolNameMapping,
21
27
  customProviderToolNames,
22
28
  }: {
23
- tools: LanguageModelV3CallOptions['tools'];
24
- toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
29
+ tools: LanguageModelV4CallOptions['tools'];
30
+ toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
25
31
  toolNameMapping?: ToolNameMapping;
26
32
  customProviderToolNames?: Set<string>;
27
33
  }): Promise<{
@@ -39,12 +45,12 @@ export async function prepareResponsesTools({
39
45
  | { type: 'mcp' }
40
46
  | { type: 'image_generation' }
41
47
  | { type: 'apply_patch' };
42
- toolWarnings: SharedV3Warning[];
48
+ toolWarnings: SharedV4Warning[];
43
49
  }> {
44
50
  // when the tools array is empty, change it to undefined to prevent errors:
45
51
  tools = tools?.length ? tools : undefined;
46
52
 
47
- const toolWarnings: SharedV3Warning[] = [];
53
+ const toolWarnings: SharedV4Warning[] = [];
48
54
 
49
55
  if (tools == null) {
50
56
  return { tools: undefined, toolChoice: undefined, toolWarnings };
@@ -56,15 +62,22 @@ export async function prepareResponsesTools({
56
62
 
57
63
  for (const tool of tools) {
58
64
  switch (tool.type) {
59
- case 'function':
65
+ case 'function': {
66
+ const openaiOptions = tool.providerOptions?.openai as
67
+ | { deferLoading?: boolean }
68
+ | undefined;
69
+ const deferLoading = openaiOptions?.deferLoading;
70
+
60
71
  openaiTools.push({
61
72
  type: 'function',
62
73
  name: tool.name,
63
74
  description: tool.description,
64
75
  parameters: tool.inputSchema,
65
76
  ...(tool.strict != null ? { strict: tool.strict } : {}),
77
+ ...(deferLoading != null ? { defer_loading: deferLoading } : {}),
66
78
  });
67
79
  break;
80
+ }
68
81
  case 'provider': {
69
82
  switch (tool.id) {
70
83
  case 'openai.file_search': {
@@ -241,11 +254,28 @@ export async function prepareResponsesTools({
241
254
 
242
255
  openaiTools.push({
243
256
  type: 'custom',
244
- name: args.name,
257
+ name: tool.name,
245
258
  description: args.description,
246
259
  format: args.format,
247
260
  });
248
- resolvedCustomProviderToolNames.add(args.name);
261
+ resolvedCustomProviderToolNames.add(tool.name);
262
+ break;
263
+ }
264
+ case 'openai.tool_search': {
265
+ const args = await validateTypes({
266
+ value: tool.args,
267
+ schema: toolSearchArgsSchema,
268
+ });
269
+ openaiTools.push({
270
+ type: 'tool_search',
271
+ ...(args.execution != null ? { execution: args.execution } : {}),
272
+ ...(args.description != null
273
+ ? { description: args.description }
274
+ : {}),
275
+ ...(args.parameters != null
276
+ ? { parameters: args.parameters }
277
+ : {}),
278
+ });
249
279
  break;
250
280
  }
251
281
  }
@@ -335,7 +365,7 @@ function mapShellEnvironment(environment: {
335
365
  };
336
366
  skills?: Array<{
337
367
  type: string;
338
- skillId?: string;
368
+ providerReference?: SharedV4ProviderReference;
339
369
  version?: string;
340
370
  name?: string;
341
371
  description?: string;
@@ -379,7 +409,7 @@ function mapShellSkills(
379
409
  skills:
380
410
  | Array<{
381
411
  type: string;
382
- skillId?: string;
412
+ providerReference?: SharedV4ProviderReference;
383
413
  version?: string;
384
414
  name?: string;
385
415
  description?: string;
@@ -391,8 +421,11 @@ function mapShellSkills(
391
421
  skill.type === 'skillReference'
392
422
  ? {
393
423
  type: 'skill_reference' as const,
394
- skill_id: skill.skillId!,
395
- version: skill.version,
424
+ skill_id: resolveProviderReference({
425
+ reference: skill.providerReference ?? {},
426
+ provider: 'openai',
427
+ }),
428
+ version: skill.version ?? 'latest',
396
429
  }
397
430
  : {
398
431
  type: 'inline' as const,
@@ -30,6 +30,16 @@ export type OpenaiResponsesProviderMetadata = {
30
30
  openai: ResponsesProviderMetadata;
31
31
  };
32
32
 
33
+ export type ResponsesCompactionProviderMetadata = {
34
+ type: 'compaction';
35
+ itemId: string;
36
+ encryptedContent?: string;
37
+ };
38
+
39
+ export type OpenaiResponsesCompactionProviderMetadata = {
40
+ openai: ResponsesCompactionProviderMetadata;
41
+ };
42
+
33
43
  export type ResponsesTextProviderMetadata = {
34
44
  itemId: string;
35
45
  phase?: 'commentary' | 'final_answer' | null;
@@ -0,0 +1,31 @@
1
+ import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
2
+ import { z } from 'zod/v4';
3
+
4
+ export const openaiSkillResponseSchema = lazySchema(() =>
5
+ zodSchema(
6
+ z.object({
7
+ id: z.string(),
8
+ name: z.string().nullish(),
9
+ description: z.string().nullish(),
10
+ default_version: z.string().nullish(),
11
+ latest_version: z.string().nullish(),
12
+ created_at: z.number(),
13
+ updated_at: z.number().nullish(),
14
+ }),
15
+ ),
16
+ );
17
+
18
+ export type OpenAISkillResponse = ReturnType<
19
+ typeof openaiSkillResponseSchema
20
+ >['_type'];
21
+
22
+ export const openaiSkillVersionResponseSchema = lazySchema(() =>
23
+ zodSchema(
24
+ z.object({
25
+ id: z.string(),
26
+ version: z.string().nullish(),
27
+ name: z.string().nullish(),
28
+ description: z.string().nullish(),
29
+ }),
30
+ ),
31
+ );
@@ -0,0 +1,87 @@
1
+ import { SkillsV4, SharedV4Warning } from '@ai-sdk/provider';
2
+ import {
3
+ combineHeaders,
4
+ convertBase64ToUint8Array,
5
+ createJsonResponseHandler,
6
+ FetchFunction,
7
+ postFormDataToApi,
8
+ } from '@ai-sdk/provider-utils';
9
+ import { openaiFailedResponseHandler } from '../openai-error';
10
+ import { openaiSkillResponseSchema } from './openai-skills-api';
11
+
12
+ interface OpenAISkillsConfig {
13
+ provider: string;
14
+ url: (options: { path: string }) => string;
15
+ headers: () => Record<string, string | undefined>;
16
+ fetch?: FetchFunction;
17
+ }
18
+
19
+ export class OpenAISkills implements SkillsV4 {
20
+ readonly specificationVersion = 'v4';
21
+
22
+ get provider(): string {
23
+ return this.config.provider;
24
+ }
25
+
26
+ constructor(private readonly config: OpenAISkillsConfig) {}
27
+
28
+ async uploadSkill(
29
+ params: Parameters<SkillsV4['uploadSkill']>[0],
30
+ ): Promise<Awaited<ReturnType<SkillsV4['uploadSkill']>>> {
31
+ const warnings: SharedV4Warning[] = [];
32
+
33
+ if (params.displayTitle != null) {
34
+ warnings.push({
35
+ type: 'unsupported',
36
+ feature: 'displayTitle',
37
+ });
38
+ }
39
+
40
+ const formData = new FormData();
41
+
42
+ for (const file of params.files) {
43
+ const content =
44
+ typeof file.content === 'string'
45
+ ? convertBase64ToUint8Array(file.content)
46
+ : file.content;
47
+
48
+ formData.append('files[]', new Blob([content]), file.path);
49
+ }
50
+
51
+ const { value: response } = await postFormDataToApi({
52
+ url: this.config.url({ path: '/skills' }),
53
+ headers: combineHeaders(this.config.headers()),
54
+ formData,
55
+ failedResponseHandler: openaiFailedResponseHandler,
56
+ successfulResponseHandler: createJsonResponseHandler(
57
+ openaiSkillResponseSchema,
58
+ ),
59
+ fetch: this.config.fetch,
60
+ });
61
+
62
+ return {
63
+ providerReference: { openai: response.id },
64
+ ...(response.name != null ? { name: response.name } : {}),
65
+ ...(response.description != null
66
+ ? { description: response.description }
67
+ : {}),
68
+ ...(response.latest_version != null
69
+ ? { latestVersion: response.latest_version }
70
+ : {}),
71
+ providerMetadata: {
72
+ openai: {
73
+ ...(response.default_version != null
74
+ ? { defaultVersion: response.default_version }
75
+ : {}),
76
+ ...(response.created_at != null
77
+ ? { createdAt: response.created_at }
78
+ : {}),
79
+ ...(response.updated_at != null
80
+ ? { updatedAt: response.updated_at }
81
+ : {}),
82
+ },
83
+ },
84
+ warnings,
85
+ };
86
+ }
87
+ }
@@ -1,9 +1,12 @@
1
- import { SpeechModelV3, SharedV3Warning } from '@ai-sdk/provider';
1
+ import { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import {
3
3
  combineHeaders,
4
4
  createBinaryResponseHandler,
5
5
  parseProviderOptions,
6
6
  postJsonToApi,
7
+ serializeModelOptions,
8
+ WORKFLOW_DESERIALIZE,
9
+ WORKFLOW_SERIALIZE,
7
10
  } from '@ai-sdk/provider-utils';
8
11
  import { OpenAIConfig } from '../openai-config';
9
12
  import { openaiFailedResponseHandler } from '../openai-error';
@@ -19,8 +22,22 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
19
22
  };
20
23
  }
21
24
 
22
- export class OpenAISpeechModel implements SpeechModelV3 {
23
- readonly specificationVersion = 'v3';
25
+ export class OpenAISpeechModel implements SpeechModelV4 {
26
+ readonly specificationVersion = 'v4';
27
+
28
+ static [WORKFLOW_SERIALIZE](model: OpenAISpeechModel) {
29
+ return serializeModelOptions({
30
+ modelId: model.modelId,
31
+ config: model.config,
32
+ });
33
+ }
34
+
35
+ static [WORKFLOW_DESERIALIZE](options: {
36
+ modelId: OpenAISpeechModelId;
37
+ config: OpenAISpeechModelConfig;
38
+ }) {
39
+ return new OpenAISpeechModel(options.modelId, options.config);
40
+ }
24
41
 
25
42
  get provider(): string {
26
43
  return this.config.provider;
@@ -39,8 +56,8 @@ export class OpenAISpeechModel implements SpeechModelV3 {
39
56
  instructions,
40
57
  language,
41
58
  providerOptions,
42
- }: Parameters<SpeechModelV3['doGenerate']>[0]) {
43
- const warnings: SharedV3Warning[] = [];
59
+ }: Parameters<SpeechModelV4['doGenerate']>[0]) {
60
+ const warnings: SharedV4Warning[] = [];
44
61
 
45
62
  // Parse provider options
46
63
  const openAIOptions = await parseProviderOptions({
@@ -98,8 +115,8 @@ export class OpenAISpeechModel implements SpeechModelV3 {
98
115
  }
99
116
 
100
117
  async doGenerate(
101
- options: Parameters<SpeechModelV3['doGenerate']>[0],
102
- ): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>> {
118
+ options: Parameters<SpeechModelV4['doGenerate']>[0],
119
+ ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {
103
120
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
104
121
  const { requestBody, warnings } = await this.getArgs(options);
105
122
 
@@ -112,7 +129,7 @@ export class OpenAISpeechModel implements SpeechModelV3 {
112
129
  path: '/audio/speech',
113
130
  modelId: this.modelId,
114
131
  }),
115
- headers: combineHeaders(this.config.headers(), options.headers),
132
+ headers: combineHeaders(this.config.headers?.(), options.headers),
116
133
  body: requestBody,
117
134
  failedResponseHandler: openaiFailedResponseHandler,
118
135
  successfulResponseHandler: createBinaryResponseHandler(),
@@ -8,7 +8,6 @@ import { z } from 'zod/v4';
8
8
  export const customArgsSchema = lazySchema(() =>
9
9
  zodSchema(
10
10
  z.object({
11
- name: z.string(),
12
11
  description: z.string().optional(),
13
12
  format: z
14
13
  .union([
@@ -31,11 +30,6 @@ const customInputSchema = lazySchema(() => zodSchema(z.string()));
31
30
  export const customToolFactory = createProviderToolFactory<
32
31
  string,
33
32
  {
34
- /**
35
- * The name of the custom tool, used to identify it in the API.
36
- */
37
- name: string;
38
-
39
33
  /**
40
34
  * An optional description of what the tool does.
41
35
  */
package/src/tool/shell.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  lazySchema,
4
4
  zodSchema,
5
5
  } from '@ai-sdk/provider-utils';
6
+ import type { SharedV4ProviderReference } from '@ai-sdk/provider';
6
7
  import { z } from 'zod/v4';
7
8
 
8
9
  export const shellInputSchema = lazySchema(() =>
@@ -39,7 +40,7 @@ const shellSkillsSchema = z
39
40
  z.discriminatedUnion('type', [
40
41
  z.object({
41
42
  type: z.literal('skillReference'),
42
- skillId: z.string(),
43
+ providerReference: z.record(z.string(), z.string()),
43
44
  version: z.string().optional(),
44
45
  }),
45
46
  z.object({
@@ -125,7 +126,11 @@ type ShellArgs = {
125
126
  }>;
126
127
  };
127
128
  skills?: Array<
128
- | { type: 'skillReference'; skillId: string; version?: string }
129
+ | {
130
+ type: 'skillReference';
131
+ providerReference: SharedV4ProviderReference;
132
+ version?: string;
133
+ }
129
134
  | {
130
135
  type: 'inline';
131
136
  name: string;
@@ -0,0 +1,98 @@
1
+ import { JSONObject } from '@ai-sdk/provider';
2
+ import {
3
+ createProviderToolFactoryWithOutputSchema,
4
+ FlexibleSchema,
5
+ lazySchema,
6
+ zodSchema,
7
+ } from '@ai-sdk/provider-utils';
8
+ import { z } from 'zod/v4';
9
+
10
+ export const toolSearchArgsSchema = lazySchema(() =>
11
+ zodSchema(
12
+ z.object({
13
+ execution: z.enum(['server', 'client']).optional(),
14
+ description: z.string().optional(),
15
+ parameters: z.record(z.string(), z.unknown()).optional(),
16
+ }),
17
+ ),
18
+ );
19
+
20
+ export const toolSearchInputSchema = lazySchema(() =>
21
+ zodSchema(
22
+ z.object({
23
+ arguments: z.unknown().optional(),
24
+ call_id: z.string().nullish(),
25
+ }),
26
+ ),
27
+ );
28
+
29
+ export const toolSearchOutputSchema: FlexibleSchema<{
30
+ tools: Array<JSONObject>;
31
+ }> = lazySchema(() =>
32
+ zodSchema(
33
+ z.object({
34
+ tools: z.array(z.record(z.string(), z.unknown())),
35
+ }),
36
+ ),
37
+ ) as FlexibleSchema<{ tools: Array<JSONObject> }>;
38
+
39
+ const toolSearchToolFactory = createProviderToolFactoryWithOutputSchema<
40
+ {
41
+ /**
42
+ * The arguments from the tool_search_call.
43
+ * This is preserved for multi-turn conversation reconstruction.
44
+ */
45
+ arguments?: unknown;
46
+
47
+ /**
48
+ * The call ID from the tool_search_call.
49
+ * Present for client-executed tool search; null for hosted.
50
+ */
51
+ call_id?: string | null;
52
+ },
53
+ {
54
+ /**
55
+ * The tools that were loaded by the tool search.
56
+ * These are the deferred tools that the model requested to load.
57
+ * Each tool is represented as a JSON object with properties depending on its type.
58
+ *
59
+ * Common properties include:
60
+ * - `type`: The type of the tool (e.g., 'function', 'web_search', etc.)
61
+ * - `name`: The name of the tool (for function tools)
62
+ * - `description`: A description of the tool
63
+ * - `deferLoading`: Whether this tool was deferred (had defer_loading: true)
64
+ * - `parameters`: The JSON Schema for the function parameters (for function tools)
65
+ * - `strict`: Whether to enable strict schema adherence (for function tools)
66
+ */
67
+ tools: Array<JSONObject>;
68
+ },
69
+ {
70
+ /**
71
+ * Whether the tool search is executed by the server (hosted) or client.
72
+ * - `'server'` (default): OpenAI performs the search across deferred tools.
73
+ * - `'client'`: The model emits a `tool_search_call` and your `execute`
74
+ * function performs the lookup, returning the tools to load.
75
+ */
76
+ execution?: 'server' | 'client';
77
+
78
+ /**
79
+ * A description of the tool search capability.
80
+ * Only used for client-executed tool search.
81
+ */
82
+ description?: string;
83
+
84
+ /**
85
+ * JSON Schema for the search arguments your application expects.
86
+ * Only used for client-executed tool search.
87
+ */
88
+ parameters?: Record<string, unknown>;
89
+ }
90
+ >({
91
+ id: 'openai.tool_search',
92
+ inputSchema: toolSearchInputSchema,
93
+ outputSchema: toolSearchOutputSchema,
94
+ });
95
+
96
+ export const toolSearch = (
97
+ args: Parameters<typeof toolSearchToolFactory>[0] = {},
98
+ ) => toolSearchToolFactory(args);
@@ -1,7 +1,7 @@
1
1
  import {
2
- TranscriptionModelV3,
3
- TranscriptionModelV3CallOptions,
4
- SharedV3Warning,
2
+ TranscriptionModelV4,
3
+ TranscriptionModelV4CallOptions,
4
+ SharedV4Warning,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
7
  combineHeaders,
@@ -10,6 +10,9 @@ import {
10
10
  mediaTypeToExtension,
11
11
  parseProviderOptions,
12
12
  postFormDataToApi,
13
+ serializeModelOptions,
14
+ WORKFLOW_DESERIALIZE,
15
+ WORKFLOW_SERIALIZE,
13
16
  } from '@ai-sdk/provider-utils';
14
17
  import { OpenAIConfig } from '../openai-config';
15
18
  import { openaiFailedResponseHandler } from '../openai-error';
@@ -21,7 +24,7 @@ import {
21
24
  } from './openai-transcription-options';
22
25
 
23
26
  export type OpenAITranscriptionCallOptions = Omit<
24
- TranscriptionModelV3CallOptions,
27
+ TranscriptionModelV4CallOptions,
25
28
  'providerOptions'
26
29
  > & {
27
30
  providerOptions?: {
@@ -96,8 +99,22 @@ const languageMap = {
96
99
  welsh: 'cy',
97
100
  };
98
101
 
99
- export class OpenAITranscriptionModel implements TranscriptionModelV3 {
100
- readonly specificationVersion = 'v3';
102
+ export class OpenAITranscriptionModel implements TranscriptionModelV4 {
103
+ readonly specificationVersion = 'v4';
104
+
105
+ static [WORKFLOW_SERIALIZE](model: OpenAITranscriptionModel) {
106
+ return serializeModelOptions({
107
+ modelId: model.modelId,
108
+ config: model.config,
109
+ });
110
+ }
111
+
112
+ static [WORKFLOW_DESERIALIZE](options: {
113
+ modelId: OpenAITranscriptionModelId;
114
+ config: OpenAITranscriptionModelConfig;
115
+ }) {
116
+ return new OpenAITranscriptionModel(options.modelId, options.config);
117
+ }
101
118
 
102
119
  get provider(): string {
103
120
  return this.config.provider;
@@ -113,7 +130,7 @@ export class OpenAITranscriptionModel implements TranscriptionModelV3 {
113
130
  mediaType,
114
131
  providerOptions,
115
132
  }: OpenAITranscriptionCallOptions) {
116
- const warnings: SharedV3Warning[] = [];
133
+ const warnings: SharedV4Warning[] = [];
117
134
 
118
135
  // Parse provider options
119
136
  const openAIOptions = await parseProviderOptions({
@@ -176,7 +193,7 @@ export class OpenAITranscriptionModel implements TranscriptionModelV3 {
176
193
 
177
194
  async doGenerate(
178
195
  options: OpenAITranscriptionCallOptions,
179
- ): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>> {
196
+ ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {
180
197
  const currentDate = this.config._internal?.currentDate?.() ?? new Date();
181
198
  const { formData, warnings } = await this.getArgs(options);
182
199
 
@@ -189,7 +206,7 @@ export class OpenAITranscriptionModel implements TranscriptionModelV3 {
189
206
  path: '/audio/transcriptions',
190
207
  modelId: this.modelId,
191
208
  }),
192
- headers: combineHeaders(this.config.headers(), options.headers),
209
+ headers: combineHeaders(this.config.headers?.(), options.headers),
193
210
  formData,
194
211
  failedResponseHandler: openaiFailedResponseHandler,
195
212
  successfulResponseHandler: createJsonResponseHandler(