@ai-sdk/openai 4.0.80 → 4.0.82
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 +16 -0
- package/dist/index.d.ts +1716 -1693
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9734 -11963
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2240 -2219
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +7712 -9502
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +11 -9
- package/package.json +8 -8
- package/src/chat/openai-chat-language-model-options.ts +1 -0
- package/src/normalize-openai-json-schema.ts +76 -3
- package/src/responses/openai-responses-language-model-options.ts +2 -0
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 and GPT-6
|
|
196
|
-
`'low'`, `'medium'`, `'high'`, `'xhigh'`, and `'max'`. GPT-6
|
|
197
|
-
support `'none'`.
|
|
195
|
+
Supported reasoning efforts vary by model. GPT-5.6, GPT-6 Sol, and GPT-6 Luna
|
|
196
|
+
support `'none'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`, and `'max'`. GPT-6
|
|
197
|
+
Astra and GPT-6.1 Sol do not support `'none'`.
|
|
198
198
|
</Note>
|
|
199
199
|
|
|
200
200
|
<Note type="warning">
|
|
@@ -220,8 +220,8 @@ The following provider options are available:
|
|
|
220
220
|
- **reasoningContext** _'auto' | 'current_turn' | 'all_turns'_
|
|
221
221
|
Controls which available reasoning items GPT-5.6 can reuse. `'auto'` uses the model default, `'current_turn'` excludes reasoning from earlier turns, and `'all_turns'` makes compatible earlier reasoning available. The effective context is returned as `providerMetadata.openai.reasoningContext`.
|
|
222
222
|
|
|
223
|
-
- **reasoningSummary** _'auto' | 'detailed'
|
|
224
|
-
Controls whether the model returns its reasoning process. Set to `'auto'` for a condensed summary, `'detailed'` for more comprehensive reasoning. Defaults to `
|
|
223
|
+
- **reasoningSummary** _'auto' | 'detailed' | null_
|
|
224
|
+
Controls whether the model returns its reasoning process. Set to `'auto'` for a condensed summary, `'detailed'` for more comprehensive reasoning, or `null` to omit reasoning summaries. Defaults to `'detailed'` when `reasoningEffort` is set to a value other than `'none'`, and to no reasoning summaries otherwise. When enabled, reasoning summaries appear in the stream as events with type `'reasoning'` and in non-streaming responses within the `reasoning` field.
|
|
225
225
|
|
|
226
226
|
- **strictJsonSchema** _boolean_
|
|
227
227
|
Whether to use strict JSON schema validation. Defaults to `true`.
|
|
@@ -1323,6 +1323,7 @@ const result = await generateText({
|
|
|
1323
1323
|
apply_patch: openai.tools.applyPatch({
|
|
1324
1324
|
execute: async ({ callId, operation }) => {
|
|
1325
1325
|
// ... your implementation for applying the diffs.
|
|
1326
|
+
return { status: 'completed' };
|
|
1326
1327
|
},
|
|
1327
1328
|
}),
|
|
1328
1329
|
},
|
|
@@ -1657,7 +1658,7 @@ name those tools as you declared them instead.
|
|
|
1657
1658
|
#### Image Inputs
|
|
1658
1659
|
|
|
1659
1660
|
The OpenAI Responses API supports Image inputs for appropriate models.
|
|
1660
|
-
You can pass Image files as part of the message content using the
|
|
1661
|
+
You can pass Image files as part of the message content using the `file` type with an `image` media type:
|
|
1661
1662
|
|
|
1662
1663
|
```ts
|
|
1663
1664
|
const result = await generateText({
|
|
@@ -1682,7 +1683,7 @@ const result = await generateText({
|
|
|
1682
1683
|
```
|
|
1683
1684
|
|
|
1684
1685
|
The model will have access to the image and will respond to questions about it.
|
|
1685
|
-
The image should be passed using the `
|
|
1686
|
+
The image should be passed using the `data` field.
|
|
1686
1687
|
|
|
1687
1688
|
You can also pass a file-id from the OpenAI Files API.
|
|
1688
1689
|
|
|
@@ -2457,7 +2458,7 @@ const logprobs = openaiMetadata?.logprobs;
|
|
|
2457
2458
|
#### Image Support
|
|
2458
2459
|
|
|
2459
2460
|
The OpenAI Chat API supports Image inputs for appropriate models.
|
|
2460
|
-
You can pass Image files as part of the message content using the
|
|
2461
|
+
You can pass Image files as part of the message content using the `file` type with an `image` media type:
|
|
2461
2462
|
|
|
2462
2463
|
```ts
|
|
2463
2464
|
const result = await generateText({
|
|
@@ -2482,7 +2483,7 @@ const result = await generateText({
|
|
|
2482
2483
|
```
|
|
2483
2484
|
|
|
2484
2485
|
The model will have access to the image and will respond to questions about it.
|
|
2485
|
-
The image should be passed using the `
|
|
2486
|
+
The image should be passed using the `data` field.
|
|
2486
2487
|
|
|
2487
2488
|
You can also pass the URL of an image.
|
|
2488
2489
|
|
|
@@ -2878,6 +2879,7 @@ The following optional provider options are available for OpenAI completion mode
|
|
|
2878
2879
|
| Model | Image Input | Audio Input | Object Generation | Tool Usage |
|
|
2879
2880
|
| --------------------- | ----------- | ----------- | ----------------- | ---------- |
|
|
2880
2881
|
| `gpt-6-astra` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2882
|
+
| `gpt-6.1-sol` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2881
2883
|
| `gpt-6-luna` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2882
2884
|
| `gpt-6-sol` | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
2883
2885
|
| `gpt-5.6` | <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.82",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,14 +35,14 @@
|
|
|
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.20",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.52"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@ai-sdk/test-server": "2.0.
|
|
42
|
+
"@ai-sdk/test-server": "2.0.3",
|
|
43
43
|
"@types/node": "22.19.19",
|
|
44
44
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
45
|
-
"
|
|
45
|
+
"tsdown": "^0.23.0",
|
|
46
46
|
"typescript": "5.8.3",
|
|
47
47
|
"zod": "3.25.76"
|
|
48
48
|
},
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"ai"
|
|
70
70
|
],
|
|
71
71
|
"scripts": {
|
|
72
|
-
"build": "pnpm clean &&
|
|
73
|
-
"build:watch": "pnpm clean &&
|
|
74
|
-
"clean": "del-cli
|
|
72
|
+
"build": "pnpm clean && tsdown",
|
|
73
|
+
"build:watch": "pnpm clean && tsdown --watch",
|
|
74
|
+
"clean": "del-cli docs *.tsbuildinfo",
|
|
75
75
|
"type-check": "tsc --build",
|
|
76
76
|
"test": "pnpm test:node && pnpm test:edge",
|
|
77
77
|
"test:update": "pnpm test:node -u",
|
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
*
|
|
16
16
|
* OpenAI also does not support regex lookaround in JSON Schema `pattern`
|
|
17
17
|
* values. Those patterns are removed and left to client-side validation.
|
|
18
|
+
*
|
|
19
|
+
* Zod 4 represents recursive references as singleton `allOf` schemas. OpenAI
|
|
20
|
+
* does not support `allOf`, but a singleton local reference can be rewritten
|
|
21
|
+
* to a direct reference without changing its validation behavior.
|
|
18
22
|
*/
|
|
19
23
|
export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
20
24
|
schema: JSONSchema7;
|
|
@@ -23,7 +27,7 @@ export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
|
23
27
|
let removedPropertyNames = false;
|
|
24
28
|
let removedLookaroundPattern = false;
|
|
25
29
|
|
|
26
|
-
const normalizedSchema = normalizeSchema(schema);
|
|
30
|
+
const normalizedSchema = normalizeSchema(schema, true);
|
|
27
31
|
|
|
28
32
|
const warnings: SharedV4Warning[] = [];
|
|
29
33
|
|
|
@@ -50,7 +54,7 @@ export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
|
50
54
|
warnings,
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
function normalizeSchema(schema: JSONSchema7): JSONSchema7 {
|
|
57
|
+
function normalizeSchema(schema: JSONSchema7, isRoot = false): JSONSchema7 {
|
|
54
58
|
const propertyNames = schema.propertyNames;
|
|
55
59
|
|
|
56
60
|
if (propertyNames != null) {
|
|
@@ -160,7 +164,76 @@ export function normalizeOpenAIJsonSchema(schema: JSONSchema7): {
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
const reference = getSingletonReference(normalizedSchema);
|
|
168
|
+
|
|
169
|
+
if (reference == null) {
|
|
170
|
+
return normalizedSchema;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const { allOf: _allOf, ...schemaWithoutAllOf } = normalizedSchema;
|
|
174
|
+
|
|
175
|
+
if (!isRoot) {
|
|
176
|
+
// A one-item allOf has the same validation behavior as its reference.
|
|
177
|
+
return {
|
|
178
|
+
...schemaWithoutAllOf,
|
|
179
|
+
$ref: reference,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const referencedSchema = getLocalReferenceSchema(
|
|
184
|
+
reference,
|
|
185
|
+
normalizedSchema,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// OpenAI requires an object at the schema root, so a local root reference
|
|
189
|
+
// must be expanded instead of being sent as a direct $ref.
|
|
190
|
+
if (referencedSchema == null) {
|
|
191
|
+
return normalizedSchema;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
...referencedSchema,
|
|
196
|
+
...schemaWithoutAllOf,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function getSingletonReference(schema: JSONSchema7): string | undefined {
|
|
201
|
+
// Do not rewrite intersections: only a single reference is equivalent to
|
|
202
|
+
// a direct $ref.
|
|
203
|
+
if (schema.allOf?.length !== 1) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const [allOfSchema] = schema.allOf;
|
|
208
|
+
|
|
209
|
+
return typeof allOfSchema === 'object' &&
|
|
210
|
+
allOfSchema != null &&
|
|
211
|
+
Object.keys(allOfSchema).length === 1 &&
|
|
212
|
+
typeof allOfSchema.$ref === 'string'
|
|
213
|
+
? allOfSchema.$ref
|
|
214
|
+
: undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function getLocalReferenceSchema(
|
|
218
|
+
reference: string,
|
|
219
|
+
schema: JSONSchema7,
|
|
220
|
+
): JSONSchema7 | undefined {
|
|
221
|
+
const match = /^#\/(definitions|\$defs)\/(.+)$/.exec(reference);
|
|
222
|
+
|
|
223
|
+
if (match == null) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const [, keyword, encodedName] = match;
|
|
228
|
+
const name = encodedName.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
229
|
+
const definition =
|
|
230
|
+
keyword === 'definitions'
|
|
231
|
+
? schema.definitions?.[name]
|
|
232
|
+
: schema.$defs?.[name];
|
|
233
|
+
|
|
234
|
+
return typeof definition === 'object' && definition != null
|
|
235
|
+
? definition
|
|
236
|
+
: undefined;
|
|
164
237
|
}
|
|
165
238
|
|
|
166
239
|
function normalizeSchemaRecord(
|
|
@@ -58,6 +58,7 @@ export const openaiResponsesReasoningModelIds = [
|
|
|
58
58
|
'gpt-5.6-sol',
|
|
59
59
|
'gpt-5.6-terra',
|
|
60
60
|
'gpt-6-astra',
|
|
61
|
+
'gpt-6.1-sol',
|
|
61
62
|
'gpt-6-luna',
|
|
62
63
|
'gpt-6-sol',
|
|
63
64
|
] as const;
|
|
@@ -133,6 +134,7 @@ export type OpenAIResponsesModelId =
|
|
|
133
134
|
| 'gpt-5.6-sol'
|
|
134
135
|
| 'gpt-5.6-terra'
|
|
135
136
|
| 'gpt-6-astra'
|
|
137
|
+
| 'gpt-6.1-sol'
|
|
136
138
|
| 'gpt-6-luna'
|
|
137
139
|
| 'gpt-6-sol'
|
|
138
140
|
| 'gpt-5-2025-08-07'
|