@ai-sdk/openai 2.1.0-beta.2 → 2.1.0-beta.4
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 +32 -0
- package/dist/index.d.mts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +7 -7
- package/dist/internal/index.d.ts +7 -7
- package/dist/internal/index.js +7 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +5 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ed329cb: feat: `Provider-V3`
|
|
8
|
+
- 522f6b8: feat: `ImageModelV3`
|
|
9
|
+
- Updated dependencies [ed329cb]
|
|
10
|
+
- Updated dependencies [522f6b8]
|
|
11
|
+
- @ai-sdk/provider@2.1.0-beta.2
|
|
12
|
+
- @ai-sdk/provider-utils@3.1.0-beta.3
|
|
13
|
+
|
|
14
|
+
## 2.1.0-beta.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 2e86082: feat(provider/openai): `OpenAIChatLanguageModelOptions` type
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { openai, type OpenAIChatLanguageModelOptions } from '@ai-sdk/openai';
|
|
22
|
+
import { generateText } from 'ai';
|
|
23
|
+
|
|
24
|
+
await generateText({
|
|
25
|
+
model: openai.chat('gpt-4o'),
|
|
26
|
+
prompt: 'Invent a new holiday and describe its traditions.',
|
|
27
|
+
providerOptions: {
|
|
28
|
+
openai: {
|
|
29
|
+
user: 'user-123',
|
|
30
|
+
} satisfies OpenAIChatLanguageModelOptions,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
3
35
|
## 2.1.0-beta.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV3, LanguageModelV2, EmbeddingModelV3, ImageModelV3, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
6
|
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-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-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | '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' | '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' | (string & {});
|
|
7
|
+
declare const openaiChatLanguageModelOptions: z.ZodObject<{
|
|
8
|
+
logitBias: z.ZodOptional<z.ZodRecord<z.ZodCoercedNumber<string>, z.ZodNumber>>;
|
|
9
|
+
logprobs: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber]>>;
|
|
10
|
+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
user: z.ZodOptional<z.ZodString>;
|
|
12
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
minimal: "minimal";
|
|
14
|
+
low: "low";
|
|
15
|
+
medium: "medium";
|
|
16
|
+
high: "high";
|
|
17
|
+
}>>;
|
|
18
|
+
maxCompletionTokens: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
21
|
+
prediction: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
22
|
+
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
auto: "auto";
|
|
25
|
+
flex: "flex";
|
|
26
|
+
priority: "priority";
|
|
27
|
+
}>>;
|
|
28
|
+
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
textVerbosity: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
low: "low";
|
|
31
|
+
medium: "medium";
|
|
32
|
+
high: "high";
|
|
33
|
+
}>>;
|
|
34
|
+
promptCacheKey: z.ZodOptional<z.ZodString>;
|
|
35
|
+
safetyIdentifier: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type OpenAIChatLanguageModelOptions = z.infer<typeof openaiChatLanguageModelOptions>;
|
|
7
38
|
|
|
8
39
|
type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
|
|
9
40
|
|
|
@@ -213,7 +244,7 @@ type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string &
|
|
|
213
244
|
|
|
214
245
|
type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
|
|
215
246
|
|
|
216
|
-
interface OpenAIProvider extends
|
|
247
|
+
interface OpenAIProvider extends ProviderV3 {
|
|
217
248
|
(modelId: OpenAIResponsesModelId): LanguageModelV2;
|
|
218
249
|
/**
|
|
219
250
|
Creates an OpenAI model for text generation.
|
|
@@ -246,11 +277,11 @@ interface OpenAIProvider extends ProviderV2 {
|
|
|
246
277
|
/**
|
|
247
278
|
Creates a model for image generation.
|
|
248
279
|
*/
|
|
249
|
-
image(modelId: OpenAIImageModelId):
|
|
280
|
+
image(modelId: OpenAIImageModelId): ImageModelV3;
|
|
250
281
|
/**
|
|
251
282
|
Creates a model for image generation.
|
|
252
283
|
*/
|
|
253
|
-
imageModel(modelId: OpenAIImageModelId):
|
|
284
|
+
imageModel(modelId: OpenAIImageModelId): ImageModelV3;
|
|
254
285
|
/**
|
|
255
286
|
Creates a model for transcription.
|
|
256
287
|
*/
|
|
@@ -338,4 +369,4 @@ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOpti
|
|
|
338
369
|
|
|
339
370
|
declare const VERSION: string;
|
|
340
371
|
|
|
341
|
-
export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
|
|
372
|
+
export { type OpenAIChatLanguageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV3, LanguageModelV2, EmbeddingModelV3, ImageModelV3, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
6
|
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-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-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | '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' | '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' | (string & {});
|
|
7
|
+
declare const openaiChatLanguageModelOptions: z.ZodObject<{
|
|
8
|
+
logitBias: z.ZodOptional<z.ZodRecord<z.ZodCoercedNumber<string>, z.ZodNumber>>;
|
|
9
|
+
logprobs: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber]>>;
|
|
10
|
+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
user: z.ZodOptional<z.ZodString>;
|
|
12
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
minimal: "minimal";
|
|
14
|
+
low: "low";
|
|
15
|
+
medium: "medium";
|
|
16
|
+
high: "high";
|
|
17
|
+
}>>;
|
|
18
|
+
maxCompletionTokens: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
21
|
+
prediction: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
22
|
+
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
auto: "auto";
|
|
25
|
+
flex: "flex";
|
|
26
|
+
priority: "priority";
|
|
27
|
+
}>>;
|
|
28
|
+
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
textVerbosity: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
low: "low";
|
|
31
|
+
medium: "medium";
|
|
32
|
+
high: "high";
|
|
33
|
+
}>>;
|
|
34
|
+
promptCacheKey: z.ZodOptional<z.ZodString>;
|
|
35
|
+
safetyIdentifier: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type OpenAIChatLanguageModelOptions = z.infer<typeof openaiChatLanguageModelOptions>;
|
|
7
38
|
|
|
8
39
|
type OpenAICompletionModelId = 'gpt-3.5-turbo-instruct' | (string & {});
|
|
9
40
|
|
|
@@ -213,7 +244,7 @@ type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string &
|
|
|
213
244
|
|
|
214
245
|
type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
|
|
215
246
|
|
|
216
|
-
interface OpenAIProvider extends
|
|
247
|
+
interface OpenAIProvider extends ProviderV3 {
|
|
217
248
|
(modelId: OpenAIResponsesModelId): LanguageModelV2;
|
|
218
249
|
/**
|
|
219
250
|
Creates an OpenAI model for text generation.
|
|
@@ -246,11 +277,11 @@ interface OpenAIProvider extends ProviderV2 {
|
|
|
246
277
|
/**
|
|
247
278
|
Creates a model for image generation.
|
|
248
279
|
*/
|
|
249
|
-
image(modelId: OpenAIImageModelId):
|
|
280
|
+
image(modelId: OpenAIImageModelId): ImageModelV3;
|
|
250
281
|
/**
|
|
251
282
|
Creates a model for image generation.
|
|
252
283
|
*/
|
|
253
|
-
imageModel(modelId: OpenAIImageModelId):
|
|
284
|
+
imageModel(modelId: OpenAIImageModelId): ImageModelV3;
|
|
254
285
|
/**
|
|
255
286
|
Creates a model for transcription.
|
|
256
287
|
*/
|
|
@@ -338,4 +369,4 @@ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOpti
|
|
|
338
369
|
|
|
339
370
|
declare const VERSION: string;
|
|
340
371
|
|
|
341
|
-
export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
|
|
372
|
+
export { type OpenAIChatLanguageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
|
package/dist/index.js
CHANGED
|
@@ -263,7 +263,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
263
263
|
|
|
264
264
|
// src/chat/openai-chat-options.ts
|
|
265
265
|
var import_v42 = require("zod/v4");
|
|
266
|
-
var
|
|
266
|
+
var openaiChatLanguageModelOptions = import_v42.z.object({
|
|
267
267
|
/**
|
|
268
268
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
269
269
|
*
|
|
@@ -445,7 +445,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
445
445
|
const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
446
446
|
provider: "openai",
|
|
447
447
|
providerOptions,
|
|
448
|
-
schema:
|
|
448
|
+
schema: openaiChatLanguageModelOptions
|
|
449
449
|
})) != null ? _a : {};
|
|
450
450
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
451
451
|
if (topK != null) {
|
|
@@ -1599,7 +1599,7 @@ var OpenAIImageModel = class {
|
|
|
1599
1599
|
constructor(modelId, config) {
|
|
1600
1600
|
this.modelId = modelId;
|
|
1601
1601
|
this.config = config;
|
|
1602
|
-
this.specificationVersion = "
|
|
1602
|
+
this.specificationVersion = "v3";
|
|
1603
1603
|
}
|
|
1604
1604
|
get maxImagesPerCall() {
|
|
1605
1605
|
var _a;
|
|
@@ -3870,7 +3870,7 @@ var openaiTranscriptionResponseSchema = import_v418.z.object({
|
|
|
3870
3870
|
});
|
|
3871
3871
|
|
|
3872
3872
|
// src/version.ts
|
|
3873
|
-
var VERSION = true ? "2.1.0-beta.
|
|
3873
|
+
var VERSION = true ? "2.1.0-beta.4" : "0.0.0-test";
|
|
3874
3874
|
|
|
3875
3875
|
// src/openai-provider.ts
|
|
3876
3876
|
function createOpenAI(options = {}) {
|