@ai-sdk/openai 4.0.71 → 4.0.73
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 +17 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +76 -19
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -4
- package/dist/internal/index.js +75 -18
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +5 -3
- package/package.json +3 -3
- package/src/chat/openai-chat-api.ts +5 -0
- package/src/chat/openai-chat-language-model-options.ts +2 -0
- package/src/chat/openai-chat-language-model.ts +4 -1
- package/src/normalize-openai-json-schema.ts +79 -10
- package/src/openai-language-model-capabilities.ts +7 -3
- package/src/responses/openai-responses-language-model-options.ts +4 -0
- package/src/speech/openai-speech-model-options.ts +1 -1
- package/src/speech/openai-speech-model.ts +4 -1
package/docs/03-openai.mdx
CHANGED
|
@@ -192,9 +192,9 @@ The following provider options are available:
|
|
|
192
192
|
Reasoning effort for reasoning models. Defaults to `medium`. If you use `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
193
193
|
|
|
194
194
|
<Note>
|
|
195
|
-
Supported reasoning efforts vary by model. GPT-5.6
|
|
196
|
-
`'medium'`, `'high'`, `'xhigh'`, and `'max'`. GPT-6
|
|
197
|
-
|
|
195
|
+
Supported reasoning efforts vary by model. GPT-5.6 and GPT-6 support `'none'`,
|
|
196
|
+
`'low'`, `'medium'`, `'high'`, `'xhigh'`, and `'max'`. GPT-6 Astra does not
|
|
197
|
+
support `'none'`.
|
|
198
198
|
</Note>
|
|
199
199
|
|
|
200
200
|
<Note type="warning">
|
|
@@ -2811,6 +2811,8 @@ The following optional provider options are available for OpenAI completion mode
|
|
|
2811
2811
|
| Model | Image Input | Audio Input | Object Generation | Tool Usage |
|
|
2812
2812
|
| --------------------- | ----------- | ----------- | ----------------- | ---------- |
|
|
2813
2813
|
| `gpt-6-astra` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2814
|
+
| `gpt-6-luna` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2815
|
+
| `gpt-6-sol` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2814
2816
|
| `gpt-5.6` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2815
2817
|
| `gpt-5.6-luna` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2816
2818
|
| `gpt-5.6-sol` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.18",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.46"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.1",
|
|
@@ -36,6 +36,11 @@ export const openaiChatResponseSchema = lazySchema(() =>
|
|
|
36
36
|
message: z.object({
|
|
37
37
|
role: z.literal('assistant').nullish(),
|
|
38
38
|
content: z.string().nullish(),
|
|
39
|
+
audio: z
|
|
40
|
+
.object({
|
|
41
|
+
transcript: z.string().nullish(),
|
|
42
|
+
})
|
|
43
|
+
.nullish(),
|
|
39
44
|
tool_calls: z
|
|
40
45
|
.array(
|
|
41
46
|
z.object({
|
|
@@ -416,7 +416,10 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
|
|
|
416
416
|
const content: Array<LanguageModelV4Content> = [];
|
|
417
417
|
|
|
418
418
|
// text content:
|
|
419
|
-
const text =
|
|
419
|
+
const text =
|
|
420
|
+
choice.message.content != null && choice.message.content.length > 0
|
|
421
|
+
? choice.message.content
|
|
422
|
+
: choice.message.audio?.transcript;
|
|
420
423
|
if (text != null && text.length > 0) {
|
|
421
424
|
content.push({ type: 'text', text });
|
|
422
425
|
}
|
|
@@ -12,27 +12,42 @@ import {
|
|
|
12
12
|
* names in JSON objects are always strings, so string-based constraints can be
|
|
13
13
|
* left to client-side validation after removing the keyword. This
|
|
14
14
|
* compatibility layer does not rewrite non-string property name schemas.
|
|
15
|
+
*
|
|
16
|
+
* OpenAI also does not support regex lookaround in JSON Schema `pattern`
|
|
17
|
+
* values. Those patterns are removed and left to client-side validation.
|
|
15
18
|
*/
|
|
16
19
|
export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
17
20
|
schema: JSONSchema7;
|
|
18
21
|
warnings: SharedV4Warning[];
|
|
19
22
|
} {
|
|
20
23
|
let removedPropertyNames = false;
|
|
24
|
+
let removedLookaroundPattern = false;
|
|
21
25
|
|
|
22
26
|
const normalizedSchema = normalizeSchema(schema);
|
|
23
27
|
|
|
28
|
+
const warnings: SharedV4Warning[] = [];
|
|
29
|
+
|
|
30
|
+
if (removedPropertyNames) {
|
|
31
|
+
warnings.push({
|
|
32
|
+
type: 'compatibility',
|
|
33
|
+
feature: 'JSON Schema propertyNames',
|
|
34
|
+
details:
|
|
35
|
+
'OpenAI does not support JSON Schema propertyNames. It was removed before sending the schema, so OpenAI will not enforce property-name constraints.',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (removedLookaroundPattern) {
|
|
40
|
+
warnings.push({
|
|
41
|
+
type: 'compatibility',
|
|
42
|
+
feature: 'JSON Schema pattern with regex lookaround',
|
|
43
|
+
details:
|
|
44
|
+
'OpenAI does not support regex lookaround in JSON Schema patterns. The pattern was removed before sending the schema, so OpenAI will not enforce that constraint.',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
24
48
|
return {
|
|
25
49
|
schema: normalizedSchema,
|
|
26
|
-
warnings
|
|
27
|
-
? [
|
|
28
|
-
{
|
|
29
|
-
type: 'compatibility',
|
|
30
|
-
feature: 'JSON Schema propertyNames',
|
|
31
|
-
details:
|
|
32
|
-
'OpenAI does not support JSON Schema propertyNames. It was removed before sending the schema, so OpenAI will not enforce property-name constraints.',
|
|
33
|
-
},
|
|
34
|
-
]
|
|
35
|
-
: [],
|
|
50
|
+
warnings,
|
|
36
51
|
};
|
|
37
52
|
|
|
38
53
|
function normalizeSchema(schema: JSONSchema7): JSONSchema7 {
|
|
@@ -55,6 +70,14 @@ export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
|
55
70
|
const normalizedSchema = { ...schema };
|
|
56
71
|
delete normalizedSchema.propertyNames;
|
|
57
72
|
|
|
73
|
+
if (
|
|
74
|
+
normalizedSchema.pattern != null &&
|
|
75
|
+
containsRegexLookaround(normalizedSchema.pattern)
|
|
76
|
+
) {
|
|
77
|
+
delete normalizedSchema.pattern;
|
|
78
|
+
removedLookaroundPattern = true;
|
|
79
|
+
}
|
|
80
|
+
|
|
58
81
|
if (normalizedSchema.properties != null) {
|
|
59
82
|
normalizedSchema.properties = normalizeSchemaRecord(
|
|
60
83
|
normalizedSchema.properties,
|
|
@@ -159,3 +182,49 @@ export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
|
159
182
|
: normalizeSchema(definition);
|
|
160
183
|
}
|
|
161
184
|
}
|
|
185
|
+
|
|
186
|
+
function containsRegexLookaround(pattern: string): boolean {
|
|
187
|
+
let escaped = false;
|
|
188
|
+
let inCharacterClass = false;
|
|
189
|
+
|
|
190
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
191
|
+
const character = pattern[index];
|
|
192
|
+
|
|
193
|
+
if (escaped) {
|
|
194
|
+
escaped = false;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (character === '\\') {
|
|
199
|
+
escaped = true;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (character === '[') {
|
|
204
|
+
inCharacterClass = true;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (character === ']') {
|
|
209
|
+
inCharacterClass = false;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!inCharacterClass && character === '(' && pattern[index + 1] === '?') {
|
|
214
|
+
const lookaroundPrefix = pattern[index + 2];
|
|
215
|
+
|
|
216
|
+
if (lookaroundPrefix === '=' || lookaroundPrefix === '!') {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (
|
|
221
|
+
lookaroundPrefix === '<' &&
|
|
222
|
+
(pattern[index + 3] === '=' || pattern[index + 3] === '!')
|
|
223
|
+
) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
@@ -24,6 +24,8 @@ export function getOpenAILanguageModelCapabilities(
|
|
|
24
24
|
const isGptNanoModel = gptVersion?.variant?.startsWith('nano') ?? false;
|
|
25
25
|
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
26
26
|
|
|
27
|
+
const isGpt6SolOrLuna = modelId === 'gpt-6-sol' || modelId === 'gpt-6-luna';
|
|
28
|
+
|
|
27
29
|
const supportsFlexProcessing =
|
|
28
30
|
(oSeriesVersion != null && oSeriesVersion >= 3) ||
|
|
29
31
|
(gptVersion != null && gptVersion.major >= 5 && !isGptChatModel);
|
|
@@ -57,9 +59,11 @@ export function getOpenAILanguageModelCapabilities(
|
|
|
57
59
|
supportsPriorityProcessing,
|
|
58
60
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
59
61
|
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
60
|
-
supportedReasoningEfforts:
|
|
61
|
-
? ['low', 'medium', 'high', 'xhigh', 'max']
|
|
62
|
-
:
|
|
62
|
+
supportedReasoningEfforts: isGpt6SolOrLuna
|
|
63
|
+
? ['none', 'low', 'medium', 'high', 'xhigh', 'max']
|
|
64
|
+
: isGpt6OrLaterModel
|
|
65
|
+
? ['low', 'medium', 'high', 'xhigh', 'max']
|
|
66
|
+
: undefined,
|
|
63
67
|
isReasoningModel,
|
|
64
68
|
systemMessageMode,
|
|
65
69
|
supportsNonReasoningParameters,
|
|
@@ -58,6 +58,8 @@ export const openaiResponsesReasoningModelIds = [
|
|
|
58
58
|
'gpt-5.6-sol',
|
|
59
59
|
'gpt-5.6-terra',
|
|
60
60
|
'gpt-6-astra',
|
|
61
|
+
'gpt-6-luna',
|
|
62
|
+
'gpt-6-sol',
|
|
61
63
|
] as const;
|
|
62
64
|
|
|
63
65
|
export const openaiResponsesModelIds = [
|
|
@@ -131,6 +133,8 @@ export type OpenAIResponsesModelId =
|
|
|
131
133
|
| 'gpt-5.6-sol'
|
|
132
134
|
| 'gpt-5.6-terra'
|
|
133
135
|
| 'gpt-6-astra'
|
|
136
|
+
| 'gpt-6-luna'
|
|
137
|
+
| 'gpt-6-sol'
|
|
134
138
|
| 'gpt-5-2025-08-07'
|
|
135
139
|
| 'gpt-5-chat-latest'
|
|
136
140
|
| 'gpt-5-codex'
|
|
@@ -20,7 +20,7 @@ export const openaiSpeechModelOptionsSchema = lazySchema(() =>
|
|
|
20
20
|
zodSchema(
|
|
21
21
|
z.object({
|
|
22
22
|
instructions: z.string().nullish(),
|
|
23
|
-
speed: z.number().min(0.25).max(4.0).
|
|
23
|
+
speed: z.number().min(0.25).max(4.0).nullish(),
|
|
24
24
|
}),
|
|
25
25
|
),
|
|
26
26
|
);
|
|
@@ -89,7 +89,10 @@ export class OpenAISpeechModel implements SpeechModelV4 {
|
|
|
89
89
|
|
|
90
90
|
// Add provider-specific options
|
|
91
91
|
if (openAIOptions) {
|
|
92
|
-
const speechModelOptions: OpenAISpeechAPITypes = {
|
|
92
|
+
const speechModelOptions: OpenAISpeechAPITypes = {
|
|
93
|
+
speed: openAIOptions.speed ?? undefined,
|
|
94
|
+
instructions: openAIOptions.instructions ?? undefined,
|
|
95
|
+
};
|
|
93
96
|
|
|
94
97
|
for (const key in speechModelOptions) {
|
|
95
98
|
const value = speechModelOptions[key as keyof OpenAISpeechAPITypes];
|