@ai-sdk/openai 4.0.89 → 4.0.91
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.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +14 -6
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +16 -0
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +1 -1
- package/src/embedding/openai-embedding-model.ts +2 -1
- package/src/openai-batch.ts +3 -1
- package/src/openai-decision-model.ts +2 -0
- package/src/openai-language-model-capabilities.ts +7 -5
- package/src/responses/openai-responses-language-model.ts +17 -4
package/docs/03-openai.mdx
CHANGED
|
@@ -3516,6 +3516,22 @@ text. Score levels receive zero-based index labels. Non-null Boolean criteria ar
|
|
|
3516
3516
|
appended to predicate instructions under `Criteria for true:` and `Criteria for false:`.
|
|
3517
3517
|
String criteria are passed through; structured criteria are serialized as JSON text.
|
|
3518
3518
|
|
|
3519
|
+
Image file parts in `state` are sent as inline images. Set `imageDetail` in a file
|
|
3520
|
+
part's `providerOptions.openai` to `'low'`, `'high'`, `'auto'`, or `'original'` to
|
|
3521
|
+
choose its detail level:
|
|
3522
|
+
|
|
3523
|
+
```ts
|
|
3524
|
+
state: [
|
|
3525
|
+
{ type: 'text', text: 'Inspect the product in this photo.' },
|
|
3526
|
+
{
|
|
3527
|
+
type: 'file',
|
|
3528
|
+
mediaType: 'image/png',
|
|
3529
|
+
data: productPhoto,
|
|
3530
|
+
providerOptions: { openai: { imageDetail: 'high' } },
|
|
3531
|
+
},
|
|
3532
|
+
],
|
|
3533
|
+
```
|
|
3534
|
+
|
|
3519
3535
|
The factory respects `createOpenAI` settings, including custom fetch and base URL.
|
|
3520
3536
|
Set `providerOptions.openai.safetyIdentifier` to an opaque end-user identifier for
|
|
3521
3537
|
safety monitoring (up to 128 characters). For example:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.91",
|
|
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.26",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.58"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -259,7 +259,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV4 {
|
|
|
259
259
|
// remove unsupported settings for reasoning models
|
|
260
260
|
// see https://platform.openai.com/docs/guides/reasoning#limitations
|
|
261
261
|
if (isReasoningModel) {
|
|
262
|
-
//
|
|
262
|
+
// supported models allow temperature, topP, and logprobs when reasoning effort is none
|
|
263
263
|
// https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
|
|
264
264
|
if (
|
|
265
265
|
resolvedReasoningEffort !== 'none' ||
|
|
@@ -54,6 +54,7 @@ export class OpenAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
54
54
|
|
|
55
55
|
async doEmbed({
|
|
56
56
|
values,
|
|
57
|
+
dimensions,
|
|
57
58
|
headers,
|
|
58
59
|
abortSignal,
|
|
59
60
|
providerOptions,
|
|
@@ -91,7 +92,7 @@ export class OpenAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
91
92
|
model: this.modelId,
|
|
92
93
|
input: values,
|
|
93
94
|
encoding_format: 'float',
|
|
94
|
-
dimensions: openaiOptions.dimensions,
|
|
95
|
+
dimensions: openaiOptions.dimensions ?? dimensions,
|
|
95
96
|
user: openaiOptions.user,
|
|
96
97
|
},
|
|
97
98
|
failedResponseHandler: openaiFailedResponseHandler,
|
package/src/openai-batch.ts
CHANGED
|
@@ -812,7 +812,9 @@ async function convertOpenAIBatchResult(
|
|
|
812
812
|
type: 'tool-result',
|
|
813
813
|
toolCallId: part.id,
|
|
814
814
|
toolName: 'web_search',
|
|
815
|
-
|
|
815
|
+
...(part.status === 'failed' || part.status === 'incomplete'
|
|
816
|
+
? { isError: true, result: { status: part.status } }
|
|
817
|
+
: { result: mapWebSearchOutput(part.action) }),
|
|
816
818
|
dynamic: true,
|
|
817
819
|
});
|
|
818
820
|
break;
|
|
@@ -170,9 +170,11 @@ export class DecisionOpenAIModel implements DecisionModelV4 {
|
|
|
170
170
|
functionality: `OpenAI decision image media type: ${part.mediaType}`,
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
+
const detail = part.providerOptions?.openai?.imageDetail;
|
|
173
174
|
return {
|
|
174
175
|
type: 'input_image',
|
|
175
176
|
image_url: `data:${mediaType};base64,${typeof part.data.data === 'string' ? part.data.data : convertUint8ArrayToBase64(part.data.data)}`,
|
|
177
|
+
...(detail != null && { detail }),
|
|
176
178
|
};
|
|
177
179
|
}),
|
|
178
180
|
},
|
|
@@ -45,12 +45,14 @@ export function getOpenAILanguageModelCapabilities(
|
|
|
45
45
|
(gptVersion != null && gptVersion.major >= 5 && !isGptChatModel);
|
|
46
46
|
|
|
47
47
|
// https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
|
|
48
|
-
// GPT-5.1 and
|
|
48
|
+
// GPT-5.1 through GPT-5.x and GPT-6 Sol/Luna support temperature,
|
|
49
|
+
// topP, and logProbs when reasoningEffort is none.
|
|
49
50
|
const supportsNonReasoningParameters =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(gptVersion.major
|
|
51
|
+
isGpt6SolOrLuna ||
|
|
52
|
+
(!isGpt6OrLaterModel &&
|
|
53
|
+
gptVersion != null &&
|
|
54
|
+
(gptVersion.major > 5 ||
|
|
55
|
+
(gptVersion.major === 5 && (gptVersion.minor ?? 0) >= 1)));
|
|
54
56
|
|
|
55
57
|
const systemMessageMode = isReasoningModel ? 'developer' : 'system';
|
|
56
58
|
|
|
@@ -685,11 +685,19 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
685
685
|
// remove unsupported settings for reasoning models
|
|
686
686
|
// see https://platform.openai.com/docs/guides/reasoning#limitations
|
|
687
687
|
if (isReasoningModel) {
|
|
688
|
-
//
|
|
688
|
+
// Input updates change the effort used to validate sampling parameters.
|
|
689
|
+
let effectiveReasoningEffort = resolvedReasoningEffort;
|
|
690
|
+
for (const item of input) {
|
|
691
|
+
if (item.type === 'configuration_update') {
|
|
692
|
+
effectiveReasoningEffort = item.reasoning.effort;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// supported models allow temperature, topP, and logprobs when reasoning effort is none
|
|
689
697
|
// https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
|
|
690
698
|
if (
|
|
691
699
|
!(
|
|
692
|
-
|
|
700
|
+
effectiveReasoningEffort === 'none' &&
|
|
693
701
|
modelCapabilities.supportsNonReasoningParameters
|
|
694
702
|
)
|
|
695
703
|
) {
|
|
@@ -1275,7 +1283,9 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1275
1283
|
toolName: toolNameMapping.toCustomToolName(
|
|
1276
1284
|
webSearchToolName ?? 'web_search',
|
|
1277
1285
|
),
|
|
1278
|
-
|
|
1286
|
+
...(part.status === 'failed' || part.status === 'incomplete'
|
|
1287
|
+
? { isError: true, result: { status: part.status } }
|
|
1288
|
+
: { result: mapWebSearchOutput(part.action) }),
|
|
1279
1289
|
});
|
|
1280
1290
|
|
|
1281
1291
|
break;
|
|
@@ -2140,7 +2150,10 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
2140
2150
|
toolName: toolNameMapping.toCustomToolName(
|
|
2141
2151
|
webSearchToolName ?? 'web_search',
|
|
2142
2152
|
),
|
|
2143
|
-
|
|
2153
|
+
...(value.item.status === 'failed' ||
|
|
2154
|
+
value.item.status === 'incomplete'
|
|
2155
|
+
? { isError: true, result: { status: value.item.status } }
|
|
2156
|
+
: { result: mapWebSearchOutput(value.item.action) }),
|
|
2144
2157
|
});
|
|
2145
2158
|
} else if (value.item.type === 'computer_call') {
|
|
2146
2159
|
ongoingToolCalls[value.output_index] = undefined;
|