@ai-sdk/openai 4.0.62 → 4.0.64
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 +18 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +14 -3
- package/dist/internal/index.js +32 -3
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +27 -67
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +18 -10
- package/src/image/openai-image-model-options.ts +8 -0
- package/src/openai-config.ts +7 -0
- package/src/responses/convert-to-openai-responses-input.ts +29 -6
- package/src/responses/openai-responses-api.ts +3 -0
- package/src/responses/openai-responses-language-model.ts +5 -0
- package/src/tool/image-generation.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.64
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ccb8952: fix(openai): return an AI SDK error for empty chat completion choices
|
|
8
|
+
- Updated dependencies [912fb01]
|
|
9
|
+
- @ai-sdk/provider@4.0.12
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.38
|
|
11
|
+
|
|
12
|
+
## 4.0.63
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 85db433: Include explicit message item types in Azure AI Foundry Responses requests.
|
|
17
|
+
- 5fb2a64: feat(openai): add GPT Image 2.5 Flare and Sunburst model IDs
|
|
18
|
+
- e105b2b: fix(openai): reject denied programmatic tool calls
|
|
19
|
+
- 45f2b6a: fix(openai): report apply patch responses with a tool-calls finish reason
|
|
20
|
+
|
|
3
21
|
## 4.0.62
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
47
47
|
}>;
|
|
48
48
|
type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
|
|
49
49
|
|
|
50
|
-
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
|
|
50
|
+
type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
|
|
51
51
|
declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
52
52
|
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
|
|
53
53
|
background?: "auto" | "transparent" | "opaque" | undefined;
|
|
@@ -1629,6 +1629,13 @@ type OpenAIConfig = {
|
|
|
1629
1629
|
fetch?: FetchFunction;
|
|
1630
1630
|
webSocket?: WebSocketConstructor;
|
|
1631
1631
|
generateId?: () => string;
|
|
1632
|
+
/**
|
|
1633
|
+
* Whether Responses API message input items must include an explicit
|
|
1634
|
+
* `type: 'message'` discriminator.
|
|
1635
|
+
*
|
|
1636
|
+
* @see https://github.com/vercel/ai/issues/20180
|
|
1637
|
+
*/
|
|
1638
|
+
explicitMessageItemType?: boolean;
|
|
1632
1639
|
/**
|
|
1633
1640
|
* This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
|
|
1634
1641
|
* in file part data instead. File ID prefixes used to identify file IDs
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
} from "@ai-sdk/provider-utils";
|
|
9
9
|
|
|
10
10
|
// src/chat/openai-chat-language-model.ts
|
|
11
|
+
import {
|
|
12
|
+
InvalidResponseDataError
|
|
13
|
+
} from "@ai-sdk/provider";
|
|
11
14
|
import {
|
|
12
15
|
StreamingToolCallTracker,
|
|
13
16
|
combineHeaders,
|
|
@@ -1224,6 +1227,12 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
1224
1227
|
fetch: this.config.fetch
|
|
1225
1228
|
});
|
|
1226
1229
|
const choice = response.choices[0];
|
|
1230
|
+
if (choice == null) {
|
|
1231
|
+
throw new InvalidResponseDataError({
|
|
1232
|
+
data: rawResponse,
|
|
1233
|
+
message: "Response did not contain any choices."
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1227
1236
|
const content = [];
|
|
1228
1237
|
const text = choice.message.content;
|
|
1229
1238
|
if (text != null && text.length > 0) {
|
|
@@ -2401,6 +2410,10 @@ var modelMaxImagesPerCall = {
|
|
|
2401
2410
|
"gpt-image-1-mini": 10,
|
|
2402
2411
|
"gpt-image-1.5": 10,
|
|
2403
2412
|
"gpt-image-2": 10,
|
|
2413
|
+
"gpt-image-2.5-flare": 10,
|
|
2414
|
+
"gpt-image-2.5-flare-2026-09-08": 10,
|
|
2415
|
+
"gpt-image-2.5-sunburst": 10,
|
|
2416
|
+
"gpt-image-2.5-sunburst-2026-09-08": 10,
|
|
2404
2417
|
"chatgpt-image-latest": 10
|
|
2405
2418
|
};
|
|
2406
2419
|
var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
|
|
@@ -3549,7 +3562,7 @@ var openaiTools = {
|
|
|
3549
3562
|
// src/openai-batch.ts
|
|
3550
3563
|
import {
|
|
3551
3564
|
InvalidArgumentError as InvalidArgumentError2,
|
|
3552
|
-
InvalidResponseDataError
|
|
3565
|
+
InvalidResponseDataError as InvalidResponseDataError2
|
|
3553
3566
|
} from "@ai-sdk/provider";
|
|
3554
3567
|
import {
|
|
3555
3568
|
combineHeaders as combineHeaders7,
|
|
@@ -4999,6 +5012,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4999
5012
|
toolNameMapping,
|
|
5000
5013
|
systemMessageMode,
|
|
5001
5014
|
providerOptionsName,
|
|
5015
|
+
explicitMessageItemType = false,
|
|
5002
5016
|
fileIdPrefixes,
|
|
5003
5017
|
passThroughUnsupportedFiles = false,
|
|
5004
5018
|
store,
|
|
@@ -5016,6 +5030,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
5016
5030
|
let input = [];
|
|
5017
5031
|
const warnings = [];
|
|
5018
5032
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
5033
|
+
const programmaticToolCallIds = /* @__PURE__ */ new Set();
|
|
5019
5034
|
const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
|
|
5020
5035
|
prompt,
|
|
5021
5036
|
providerOptionsName
|
|
@@ -5032,6 +5047,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
5032
5047
|
providerOptionsName
|
|
5033
5048
|
);
|
|
5034
5049
|
input.push({
|
|
5050
|
+
...explicitMessageItemType && { type: "message" },
|
|
5035
5051
|
role: "system",
|
|
5036
5052
|
content: promptCacheBreakpoint == null ? content : [
|
|
5037
5053
|
{
|
|
@@ -5049,6 +5065,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
5049
5065
|
providerOptionsName
|
|
5050
5066
|
);
|
|
5051
5067
|
input.push({
|
|
5068
|
+
...explicitMessageItemType && { type: "message" },
|
|
5052
5069
|
role: "developer",
|
|
5053
5070
|
content: promptCacheBreakpoint == null ? content : [
|
|
5054
5071
|
{
|
|
@@ -5078,6 +5095,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
5078
5095
|
}
|
|
5079
5096
|
case "user": {
|
|
5080
5097
|
input.push({
|
|
5098
|
+
...explicitMessageItemType && { type: "message" },
|
|
5081
5099
|
role: "user",
|
|
5082
5100
|
content: content.map((part, index) => {
|
|
5083
5101
|
var _a3, _b2, _c2, _d2, _e2;
|
|
@@ -5194,6 +5212,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
5194
5212
|
break;
|
|
5195
5213
|
}
|
|
5196
5214
|
input.push({
|
|
5215
|
+
...explicitMessageItemType && { type: "message" },
|
|
5197
5216
|
role: "assistant",
|
|
5198
5217
|
content: [{ type: "output_text", text: part.text }],
|
|
5199
5218
|
id,
|
|
@@ -5234,6 +5253,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
5234
5253
|
const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
|
|
5235
5254
|
const isAsync = (_p = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.async) != null ? _p : (_o = (_n = part.providerMetadata) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.async;
|
|
5236
5255
|
const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
|
|
5256
|
+
if ((caller == null ? void 0 : caller.type) === "program") {
|
|
5257
|
+
programmaticToolCallIds.add(part.toolCallId);
|
|
5258
|
+
}
|
|
5237
5259
|
if (hasConversation && id != null) {
|
|
5238
5260
|
break;
|
|
5239
5261
|
}
|
|
@@ -5885,6 +5907,12 @@ ${text}`,
|
|
|
5885
5907
|
});
|
|
5886
5908
|
continue;
|
|
5887
5909
|
}
|
|
5910
|
+
const resultCaller = (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller;
|
|
5911
|
+
if (output.type === "execution-denied" && ((resultCaller == null ? void 0 : resultCaller.type) === "program" || programmaticToolCallIds.has(part.toolCallId))) {
|
|
5912
|
+
throw new UnsupportedFunctionalityError4({
|
|
5913
|
+
functionality: "execution-denied results for programmatic tool calls"
|
|
5914
|
+
});
|
|
5915
|
+
}
|
|
5888
5916
|
const contentValue = await convertFunctionToolResultOutput({
|
|
5889
5917
|
output,
|
|
5890
5918
|
toolName: part.toolName,
|
|
@@ -5897,9 +5925,7 @@ ${text}`,
|
|
|
5897
5925
|
providerOptionsName,
|
|
5898
5926
|
warnings
|
|
5899
5927
|
});
|
|
5900
|
-
const caller = mapToolCaller(
|
|
5901
|
-
(_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
|
|
5902
|
-
);
|
|
5928
|
+
const caller = mapToolCaller(resultCaller);
|
|
5903
5929
|
input.push({
|
|
5904
5930
|
type: "function_call_output",
|
|
5905
5931
|
call_id: part.toolCallId,
|
|
@@ -6963,6 +6989,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6963
6989
|
toolNameMapping,
|
|
6964
6990
|
systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
6965
6991
|
providerOptionsName,
|
|
6992
|
+
explicitMessageItemType: config.explicitMessageItemType,
|
|
6966
6993
|
fileIdPrefixes: config.fileIdPrefixes,
|
|
6967
6994
|
passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
|
|
6968
6995
|
store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
|
|
@@ -7721,6 +7748,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7721
7748
|
break;
|
|
7722
7749
|
}
|
|
7723
7750
|
case "apply_patch_call": {
|
|
7751
|
+
hasFunctionCall = true;
|
|
7724
7752
|
content.push({
|
|
7725
7753
|
type: "tool-call",
|
|
7726
7754
|
toolCallId: part.call_id,
|
|
@@ -8464,6 +8492,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8464
8492
|
toolCall.applyPatch.endEmitted = true;
|
|
8465
8493
|
}
|
|
8466
8494
|
if (toolCall && value.item.status === "completed") {
|
|
8495
|
+
hasFunctionCall = true;
|
|
8467
8496
|
controller.enqueue({
|
|
8468
8497
|
type: "tool-call",
|
|
8469
8498
|
toolCallId: toolCall.toolCallId,
|
|
@@ -9257,7 +9286,7 @@ var OpenAIBatch = class {
|
|
|
9257
9286
|
(fileId) => fileId != null
|
|
9258
9287
|
);
|
|
9259
9288
|
if (batchStatus.status === "completed" && fileIds.length === 0) {
|
|
9260
|
-
throw new
|
|
9289
|
+
throw new InvalidResponseDataError2({
|
|
9261
9290
|
data: batch,
|
|
9262
9291
|
message: `OpenAI batch "${options.batchId}" completed without batch output.`
|
|
9263
9292
|
});
|
|
@@ -11188,7 +11217,7 @@ var OpenAISkills = class {
|
|
|
11188
11217
|
};
|
|
11189
11218
|
|
|
11190
11219
|
// src/version.ts
|
|
11191
|
-
var VERSION = true ? "4.0.
|
|
11220
|
+
var VERSION = true ? "4.0.64" : "0.0.0-test";
|
|
11192
11221
|
|
|
11193
11222
|
// src/openai-provider.ts
|
|
11194
11223
|
function createOpenAI(options = {}) {
|