@ai-sdk/openai 2.0.0-alpha.9 → 2.0.0-beta.1
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 +83 -0
- package/dist/index.d.mts +77 -75
- package/dist/index.d.ts +77 -75
- package/dist/index.js +745 -389
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +690 -334
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +20 -8
- package/dist/internal/index.d.ts +20 -8
- package/dist/internal/index.js +739 -365
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +687 -313
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV2, EmbeddingModelV2, ImageModelV2,
|
|
1
|
+
import { LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2CallOptions, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -56,6 +56,13 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
56
56
|
* @default true
|
|
57
57
|
*/
|
|
58
58
|
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Service tier for the request. Set to 'flex' for 50% cheaper processing
|
|
61
|
+
* at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
62
|
+
*
|
|
63
|
+
* @default 'auto'
|
|
64
|
+
*/
|
|
65
|
+
serviceTier: z.ZodOptional<z.ZodEnum<["auto", "flex"]>>;
|
|
59
66
|
}, "strip", z.ZodTypeAny, {
|
|
60
67
|
user?: string | undefined;
|
|
61
68
|
logitBias?: Record<number, number> | undefined;
|
|
@@ -67,6 +74,7 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
67
74
|
metadata?: Record<string, string> | undefined;
|
|
68
75
|
prediction?: Record<string, any> | undefined;
|
|
69
76
|
structuredOutputs?: boolean | undefined;
|
|
77
|
+
serviceTier?: "auto" | "flex" | undefined;
|
|
70
78
|
}, {
|
|
71
79
|
user?: string | undefined;
|
|
72
80
|
logitBias?: Record<number, number> | undefined;
|
|
@@ -78,6 +86,7 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
78
86
|
metadata?: Record<string, string> | undefined;
|
|
79
87
|
prediction?: Record<string, any> | undefined;
|
|
80
88
|
structuredOutputs?: boolean | undefined;
|
|
89
|
+
serviceTier?: "auto" | "flex" | undefined;
|
|
81
90
|
}>;
|
|
82
91
|
type OpenAIProviderOptions = z.infer<typeof openaiProviderOptions>;
|
|
83
92
|
|
|
@@ -282,7 +291,7 @@ declare const openAITranscriptionProviderOptions: z.ZodObject<{
|
|
|
282
291
|
}>;
|
|
283
292
|
type OpenAITranscriptionProviderOptions = z.infer<typeof openAITranscriptionProviderOptions>;
|
|
284
293
|
|
|
285
|
-
type OpenAITranscriptionCallOptions = Omit<
|
|
294
|
+
type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV2CallOptions, 'providerOptions'> & {
|
|
286
295
|
providerOptions?: {
|
|
287
296
|
openai?: OpenAITranscriptionProviderOptions;
|
|
288
297
|
};
|
|
@@ -292,14 +301,14 @@ interface OpenAITranscriptionModelConfig extends OpenAIConfig {
|
|
|
292
301
|
currentDate?: () => Date;
|
|
293
302
|
};
|
|
294
303
|
}
|
|
295
|
-
declare class OpenAITranscriptionModel implements
|
|
304
|
+
declare class OpenAITranscriptionModel implements TranscriptionModelV2 {
|
|
296
305
|
readonly modelId: OpenAITranscriptionModelId;
|
|
297
306
|
private readonly config;
|
|
298
|
-
readonly specificationVersion = "
|
|
307
|
+
readonly specificationVersion = "v2";
|
|
299
308
|
get provider(): string;
|
|
300
309
|
constructor(modelId: OpenAITranscriptionModelId, config: OpenAITranscriptionModelConfig);
|
|
301
310
|
private getArgs;
|
|
302
|
-
doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<
|
|
311
|
+
doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV2['doGenerate']>>>;
|
|
303
312
|
}
|
|
304
313
|
|
|
305
314
|
type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string & {});
|
|
@@ -320,14 +329,14 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
|
|
|
320
329
|
currentDate?: () => Date;
|
|
321
330
|
};
|
|
322
331
|
}
|
|
323
|
-
declare class OpenAISpeechModel implements
|
|
332
|
+
declare class OpenAISpeechModel implements SpeechModelV2 {
|
|
324
333
|
readonly modelId: OpenAISpeechModelId;
|
|
325
334
|
private readonly config;
|
|
326
|
-
readonly specificationVersion = "
|
|
335
|
+
readonly specificationVersion = "v2";
|
|
327
336
|
get provider(): string;
|
|
328
337
|
constructor(modelId: OpenAISpeechModelId, config: OpenAISpeechModelConfig);
|
|
329
338
|
private getArgs;
|
|
330
|
-
doGenerate(options: Parameters<
|
|
339
|
+
doGenerate(options: Parameters<SpeechModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV2['doGenerate']>>>;
|
|
331
340
|
}
|
|
332
341
|
|
|
333
342
|
type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | '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-10-01' | 'gpt-4o-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-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
@@ -353,12 +362,14 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
|
|
|
353
362
|
strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
354
363
|
instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
355
364
|
reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
365
|
+
serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<["auto", "flex"]>>>;
|
|
356
366
|
}, "strip", z.ZodTypeAny, {
|
|
357
367
|
user?: string | null | undefined;
|
|
358
368
|
parallelToolCalls?: boolean | null | undefined;
|
|
359
369
|
reasoningEffort?: string | null | undefined;
|
|
360
370
|
store?: boolean | null | undefined;
|
|
361
371
|
metadata?: any;
|
|
372
|
+
serviceTier?: "auto" | "flex" | null | undefined;
|
|
362
373
|
instructions?: string | null | undefined;
|
|
363
374
|
previousResponseId?: string | null | undefined;
|
|
364
375
|
strictSchemas?: boolean | null | undefined;
|
|
@@ -369,6 +380,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
|
|
|
369
380
|
reasoningEffort?: string | null | undefined;
|
|
370
381
|
store?: boolean | null | undefined;
|
|
371
382
|
metadata?: any;
|
|
383
|
+
serviceTier?: "auto" | "flex" | null | undefined;
|
|
372
384
|
instructions?: string | null | undefined;
|
|
373
385
|
previousResponseId?: string | null | undefined;
|
|
374
386
|
strictSchemas?: boolean | null | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV2, EmbeddingModelV2, ImageModelV2,
|
|
1
|
+
import { LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2CallOptions, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -56,6 +56,13 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
56
56
|
* @default true
|
|
57
57
|
*/
|
|
58
58
|
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Service tier for the request. Set to 'flex' for 50% cheaper processing
|
|
61
|
+
* at the cost of increased latency. Only available for o3 and o4-mini models.
|
|
62
|
+
*
|
|
63
|
+
* @default 'auto'
|
|
64
|
+
*/
|
|
65
|
+
serviceTier: z.ZodOptional<z.ZodEnum<["auto", "flex"]>>;
|
|
59
66
|
}, "strip", z.ZodTypeAny, {
|
|
60
67
|
user?: string | undefined;
|
|
61
68
|
logitBias?: Record<number, number> | undefined;
|
|
@@ -67,6 +74,7 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
67
74
|
metadata?: Record<string, string> | undefined;
|
|
68
75
|
prediction?: Record<string, any> | undefined;
|
|
69
76
|
structuredOutputs?: boolean | undefined;
|
|
77
|
+
serviceTier?: "auto" | "flex" | undefined;
|
|
70
78
|
}, {
|
|
71
79
|
user?: string | undefined;
|
|
72
80
|
logitBias?: Record<number, number> | undefined;
|
|
@@ -78,6 +86,7 @@ declare const openaiProviderOptions: z.ZodObject<{
|
|
|
78
86
|
metadata?: Record<string, string> | undefined;
|
|
79
87
|
prediction?: Record<string, any> | undefined;
|
|
80
88
|
structuredOutputs?: boolean | undefined;
|
|
89
|
+
serviceTier?: "auto" | "flex" | undefined;
|
|
81
90
|
}>;
|
|
82
91
|
type OpenAIProviderOptions = z.infer<typeof openaiProviderOptions>;
|
|
83
92
|
|
|
@@ -282,7 +291,7 @@ declare const openAITranscriptionProviderOptions: z.ZodObject<{
|
|
|
282
291
|
}>;
|
|
283
292
|
type OpenAITranscriptionProviderOptions = z.infer<typeof openAITranscriptionProviderOptions>;
|
|
284
293
|
|
|
285
|
-
type OpenAITranscriptionCallOptions = Omit<
|
|
294
|
+
type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV2CallOptions, 'providerOptions'> & {
|
|
286
295
|
providerOptions?: {
|
|
287
296
|
openai?: OpenAITranscriptionProviderOptions;
|
|
288
297
|
};
|
|
@@ -292,14 +301,14 @@ interface OpenAITranscriptionModelConfig extends OpenAIConfig {
|
|
|
292
301
|
currentDate?: () => Date;
|
|
293
302
|
};
|
|
294
303
|
}
|
|
295
|
-
declare class OpenAITranscriptionModel implements
|
|
304
|
+
declare class OpenAITranscriptionModel implements TranscriptionModelV2 {
|
|
296
305
|
readonly modelId: OpenAITranscriptionModelId;
|
|
297
306
|
private readonly config;
|
|
298
|
-
readonly specificationVersion = "
|
|
307
|
+
readonly specificationVersion = "v2";
|
|
299
308
|
get provider(): string;
|
|
300
309
|
constructor(modelId: OpenAITranscriptionModelId, config: OpenAITranscriptionModelConfig);
|
|
301
310
|
private getArgs;
|
|
302
|
-
doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<
|
|
311
|
+
doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV2['doGenerate']>>>;
|
|
303
312
|
}
|
|
304
313
|
|
|
305
314
|
type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string & {});
|
|
@@ -320,14 +329,14 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
|
|
|
320
329
|
currentDate?: () => Date;
|
|
321
330
|
};
|
|
322
331
|
}
|
|
323
|
-
declare class OpenAISpeechModel implements
|
|
332
|
+
declare class OpenAISpeechModel implements SpeechModelV2 {
|
|
324
333
|
readonly modelId: OpenAISpeechModelId;
|
|
325
334
|
private readonly config;
|
|
326
|
-
readonly specificationVersion = "
|
|
335
|
+
readonly specificationVersion = "v2";
|
|
327
336
|
get provider(): string;
|
|
328
337
|
constructor(modelId: OpenAISpeechModelId, config: OpenAISpeechModelConfig);
|
|
329
338
|
private getArgs;
|
|
330
|
-
doGenerate(options: Parameters<
|
|
339
|
+
doGenerate(options: Parameters<SpeechModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV2['doGenerate']>>>;
|
|
331
340
|
}
|
|
332
341
|
|
|
333
342
|
type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | '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-10-01' | 'gpt-4o-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-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
|
|
@@ -353,12 +362,14 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
|
|
|
353
362
|
strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
354
363
|
instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
355
364
|
reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
365
|
+
serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<["auto", "flex"]>>>;
|
|
356
366
|
}, "strip", z.ZodTypeAny, {
|
|
357
367
|
user?: string | null | undefined;
|
|
358
368
|
parallelToolCalls?: boolean | null | undefined;
|
|
359
369
|
reasoningEffort?: string | null | undefined;
|
|
360
370
|
store?: boolean | null | undefined;
|
|
361
371
|
metadata?: any;
|
|
372
|
+
serviceTier?: "auto" | "flex" | null | undefined;
|
|
362
373
|
instructions?: string | null | undefined;
|
|
363
374
|
previousResponseId?: string | null | undefined;
|
|
364
375
|
strictSchemas?: boolean | null | undefined;
|
|
@@ -369,6 +380,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
|
|
|
369
380
|
reasoningEffort?: string | null | undefined;
|
|
370
381
|
store?: boolean | null | undefined;
|
|
371
382
|
metadata?: any;
|
|
383
|
+
serviceTier?: "auto" | "flex" | null | undefined;
|
|
372
384
|
instructions?: string | null | undefined;
|
|
373
385
|
previousResponseId?: string | null | undefined;
|
|
374
386
|
strictSchemas?: boolean | null | undefined;
|