@ai-sdk/openai 3.0.81 → 3.0.83

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/dist/index.mjs CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  createEventSourceResponseHandler,
16
16
  createJsonResponseHandler,
17
17
  generateId,
18
- isParsableJson,
19
18
  parseProviderOptions,
20
19
  postJsonToApi
21
20
  } from "@ai-sdk/provider-utils";
@@ -44,7 +43,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
44
43
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
45
44
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
46
45
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
47
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.5");
46
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.5") || modelId.startsWith("gpt-5.6");
48
47
  const systemMessageMode = isReasoningModel ? "developer" : "system";
49
48
  return {
50
49
  supportsFlexProcessing,
@@ -55,6 +54,129 @@ function getOpenAILanguageModelCapabilities(modelId) {
55
54
  };
56
55
  }
57
56
 
57
+ // src/openai-stream-error.ts
58
+ import { APICallError } from "@ai-sdk/provider";
59
+ async function throwIfOpenAIStreamErrorBeforeOutput({
60
+ stream,
61
+ getError,
62
+ isOutputChunk,
63
+ url,
64
+ requestBodyValues,
65
+ responseHeaders
66
+ }) {
67
+ const [streamForEarlyError, streamForConsumer] = stream.tee();
68
+ const reader = streamForEarlyError.getReader();
69
+ try {
70
+ while (true) {
71
+ const result = await reader.read();
72
+ if (result.done) {
73
+ return streamForConsumer;
74
+ }
75
+ const chunk = result.value;
76
+ if (!chunk.success) {
77
+ return streamForConsumer;
78
+ }
79
+ const errorFrame = getError(chunk.value);
80
+ if (errorFrame != null) {
81
+ streamForConsumer.cancel().catch(() => {
82
+ });
83
+ throw createOpenAIStreamError({
84
+ frame: errorFrame,
85
+ url,
86
+ requestBodyValues,
87
+ responseHeaders
88
+ });
89
+ }
90
+ if (isOutputChunk(chunk.value)) {
91
+ return streamForConsumer;
92
+ }
93
+ }
94
+ } finally {
95
+ reader.cancel().catch(() => {
96
+ });
97
+ reader.releaseLock();
98
+ }
99
+ }
100
+ function createOpenAIStreamError({
101
+ frame,
102
+ url,
103
+ requestBodyValues,
104
+ responseHeaders
105
+ }) {
106
+ var _a;
107
+ const streamError = parseStreamError(frame);
108
+ return new APICallError({
109
+ message: (_a = streamError == null ? void 0 : streamError.message) != null ? _a : "OpenAI stream failed before any output was generated",
110
+ url,
111
+ requestBodyValues,
112
+ statusCode: streamError == null ? 500 : getStatusCode(streamError),
113
+ responseHeaders,
114
+ responseBody: JSON.stringify(frame),
115
+ data: frame
116
+ });
117
+ }
118
+ function parseStreamError(frame) {
119
+ var _a;
120
+ const value = asRecord(frame);
121
+ if (value == null) {
122
+ return void 0;
123
+ }
124
+ if (value.type === "response.failed") {
125
+ const response = asRecord(value.response);
126
+ const responseError = asRecord(response == null ? void 0 : response.error);
127
+ return typeof (responseError == null ? void 0 : responseError.message) === "string" ? {
128
+ message: responseError.message,
129
+ code: getStringOrNumber(responseError.code),
130
+ type: "response.failed",
131
+ frame
132
+ } : void 0;
133
+ }
134
+ const error = (_a = asRecord(value.error)) != null ? _a : value;
135
+ return typeof error.message === "string" && (asRecord(value.error) != null || typeof error.type === "string" || "code" in error || "param" in error) ? {
136
+ message: error.message,
137
+ code: getStringOrNumber(error.code),
138
+ type: typeof error.type === "string" ? error.type : void 0,
139
+ frame
140
+ } : void 0;
141
+ }
142
+ function getStatusCode(error) {
143
+ if (typeof error.code === "number" && isHttpErrorStatusCode(error.code)) {
144
+ return error.code;
145
+ }
146
+ if (typeof error.code === "string" && /^\d{3}$/.test(error.code)) {
147
+ const numericCode = Number(error.code);
148
+ if (isHttpErrorStatusCode(numericCode)) {
149
+ return numericCode;
150
+ }
151
+ }
152
+ const discriminator = [error.code, error.type].filter((value) => typeof value === "string" || typeof value === "number").join(" ").toLowerCase();
153
+ if (["insufficient_quota", "rate_limit"].some(
154
+ (term) => discriminator.includes(term)
155
+ )) {
156
+ return 429;
157
+ }
158
+ if (discriminator.includes("authentication")) return 401;
159
+ if (discriminator.includes("permission")) return 403;
160
+ if (discriminator.includes("not_found")) return 404;
161
+ if (["invalid", "bad_request", "context_length"].some(
162
+ (term) => discriminator.includes(term)
163
+ )) {
164
+ return 400;
165
+ }
166
+ if (discriminator.includes("overload")) return 503;
167
+ if (discriminator.includes("timeout")) return 504;
168
+ return 500;
169
+ }
170
+ function asRecord(value) {
171
+ return typeof value === "object" && value != null ? value : void 0;
172
+ }
173
+ function getStringOrNumber(value) {
174
+ return typeof value === "string" || typeof value === "number" ? value : void 0;
175
+ }
176
+ function isHttpErrorStatusCode(value) {
177
+ return Number.isInteger(value) && value >= 400 && value <= 599;
178
+ }
179
+
58
180
  // src/chat/convert-openai-chat-usage.ts
59
181
  function convertOpenAIChatUsage(usage) {
60
182
  var _a, _b, _c, _d, _e, _f;
@@ -259,7 +381,7 @@ function convertToOpenAIChatMessages({
259
381
  contentValue = output.value;
260
382
  break;
261
383
  case "execution-denied":
262
- contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
384
+ contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
263
385
  break;
264
386
  case "content":
265
387
  case "json":
@@ -921,11 +1043,12 @@ var OpenAIChatLanguageModel = class {
921
1043
  include_usage: true
922
1044
  }
923
1045
  };
1046
+ const url = this.config.url({
1047
+ path: "/chat/completions",
1048
+ modelId: this.modelId
1049
+ });
924
1050
  const { responseHeaders, value: response } = await postJsonToApi({
925
- url: this.config.url({
926
- path: "/chat/completions",
927
- modelId: this.modelId
928
- }),
1051
+ url,
929
1052
  headers: combineHeaders(this.config.headers(), options.headers),
930
1053
  body,
931
1054
  failedResponseHandler: openaiFailedResponseHandler,
@@ -935,6 +1058,14 @@ var OpenAIChatLanguageModel = class {
935
1058
  abortSignal: options.abortSignal,
936
1059
  fetch: this.config.fetch
937
1060
  });
1061
+ const checkedResponse = await throwIfOpenAIStreamErrorBeforeOutput({
1062
+ stream: response,
1063
+ getError: (chunk) => "error" in chunk ? chunk.error : void 0,
1064
+ isOutputChunk: isOpenAIChatOutputChunk,
1065
+ url,
1066
+ requestBodyValues: body,
1067
+ responseHeaders
1068
+ });
938
1069
  const toolCalls = [];
939
1070
  let finishReason = {
940
1071
  unified: "other",
@@ -944,14 +1075,14 @@ var OpenAIChatLanguageModel = class {
944
1075
  let metadataExtracted = false;
945
1076
  let isActiveText = false;
946
1077
  const providerMetadata = { openai: {} };
947
- return {
948
- stream: response.pipeThrough(
1078
+ const result = {
1079
+ stream: checkedResponse.pipeThrough(
949
1080
  new TransformStream({
950
1081
  start(controller) {
951
1082
  controller.enqueue({ type: "stream-start", warnings });
952
1083
  },
953
1084
  transform(chunk, controller) {
954
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1085
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
955
1086
  if (options.includeRawChunks) {
956
1087
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
957
1088
  }
@@ -1055,19 +1186,6 @@ var OpenAIChatLanguageModel = class {
1055
1186
  delta: toolCall2.function.arguments
1056
1187
  });
1057
1188
  }
1058
- if (isParsableJson(toolCall2.function.arguments)) {
1059
- controller.enqueue({
1060
- type: "tool-input-end",
1061
- id: toolCall2.id
1062
- });
1063
- controller.enqueue({
1064
- type: "tool-call",
1065
- toolCallId: (_j = toolCall2.id) != null ? _j : generateId(),
1066
- toolName: toolCall2.function.name,
1067
- input: toolCall2.function.arguments
1068
- });
1069
- toolCall2.hasFinished = true;
1070
- }
1071
1189
  }
1072
1190
  continue;
1073
1191
  }
@@ -1075,27 +1193,14 @@ var OpenAIChatLanguageModel = class {
1075
1193
  if (toolCall.hasFinished) {
1076
1194
  continue;
1077
1195
  }
1078
- if (((_k = toolCallDelta.function) == null ? void 0 : _k.arguments) != null) {
1079
- toolCall.function.arguments += (_m = (_l = toolCallDelta.function) == null ? void 0 : _l.arguments) != null ? _m : "";
1196
+ if (((_j = toolCallDelta.function) == null ? void 0 : _j.arguments) != null) {
1197
+ toolCall.function.arguments += (_l = (_k = toolCallDelta.function) == null ? void 0 : _k.arguments) != null ? _l : "";
1080
1198
  }
1081
1199
  controller.enqueue({
1082
1200
  type: "tool-input-delta",
1083
1201
  id: toolCall.id,
1084
- delta: (_n = toolCallDelta.function.arguments) != null ? _n : ""
1202
+ delta: (_m = toolCallDelta.function.arguments) != null ? _m : ""
1085
1203
  });
1086
- if (((_o = toolCall.function) == null ? void 0 : _o.name) != null && ((_p = toolCall.function) == null ? void 0 : _p.arguments) != null && isParsableJson(toolCall.function.arguments)) {
1087
- controller.enqueue({
1088
- type: "tool-input-end",
1089
- id: toolCall.id
1090
- });
1091
- controller.enqueue({
1092
- type: "tool-call",
1093
- toolCallId: (_q = toolCall.id) != null ? _q : generateId(),
1094
- toolName: toolCall.function.name,
1095
- input: toolCall.function.arguments
1096
- });
1097
- toolCall.hasFinished = true;
1098
- }
1099
1204
  }
1100
1205
  }
1101
1206
  if (delta.annotations != null) {
@@ -1111,9 +1216,25 @@ var OpenAIChatLanguageModel = class {
1111
1216
  }
1112
1217
  },
1113
1218
  flush(controller) {
1219
+ var _a;
1114
1220
  if (isActiveText) {
1115
1221
  controller.enqueue({ type: "text-end", id: "0" });
1116
1222
  }
1223
+ for (const toolCall of toolCalls) {
1224
+ if (!toolCall.hasFinished) {
1225
+ controller.enqueue({
1226
+ type: "tool-input-end",
1227
+ id: toolCall.id
1228
+ });
1229
+ controller.enqueue({
1230
+ type: "tool-call",
1231
+ toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
1232
+ toolName: toolCall.function.name,
1233
+ input: toolCall.function.arguments
1234
+ });
1235
+ toolCall.hasFinished = true;
1236
+ }
1237
+ }
1117
1238
  controller.enqueue({
1118
1239
  type: "finish",
1119
1240
  finishReason,
@@ -1126,8 +1247,18 @@ var OpenAIChatLanguageModel = class {
1126
1247
  request: { body },
1127
1248
  response: { headers: responseHeaders }
1128
1249
  };
1250
+ return result;
1129
1251
  }
1130
1252
  };
1253
+ function isOpenAIChatOutputChunk(chunk) {
1254
+ if ("error" in chunk) {
1255
+ return false;
1256
+ }
1257
+ return chunk.choices.some((choice) => {
1258
+ const delta = choice.delta;
1259
+ return (delta == null ? void 0 : delta.content) != null && delta.content.length > 0 || (delta == null ? void 0 : delta.tool_calls) != null && delta.tool_calls.length > 0 || (delta == null ? void 0 : delta.annotations) != null && delta.annotations.length > 0;
1260
+ });
1261
+ }
1131
1262
 
1132
1263
  // src/completion/openai-completion-language-model.ts
1133
1264
  import {
@@ -1534,11 +1665,12 @@ var OpenAICompletionLanguageModel = class {
1534
1665
  include_usage: true
1535
1666
  }
1536
1667
  };
1668
+ const url = this.config.url({
1669
+ path: "/completions",
1670
+ modelId: this.modelId
1671
+ });
1537
1672
  const { responseHeaders, value: response } = await postJsonToApi2({
1538
- url: this.config.url({
1539
- path: "/completions",
1540
- modelId: this.modelId
1541
- }),
1673
+ url,
1542
1674
  headers: combineHeaders2(this.config.headers(), options.headers),
1543
1675
  body,
1544
1676
  failedResponseHandler: openaiFailedResponseHandler,
@@ -1548,6 +1680,14 @@ var OpenAICompletionLanguageModel = class {
1548
1680
  abortSignal: options.abortSignal,
1549
1681
  fetch: this.config.fetch
1550
1682
  });
1683
+ const checkedResponse = await throwIfOpenAIStreamErrorBeforeOutput({
1684
+ stream: response,
1685
+ getError: (chunk) => "error" in chunk ? chunk.error : void 0,
1686
+ isOutputChunk: isOpenAICompletionOutputChunk,
1687
+ url,
1688
+ requestBodyValues: body,
1689
+ responseHeaders
1690
+ });
1551
1691
  let finishReason = {
1552
1692
  unified: "other",
1553
1693
  raw: void 0
@@ -1555,8 +1695,8 @@ var OpenAICompletionLanguageModel = class {
1555
1695
  const providerMetadata = { openai: {} };
1556
1696
  let usage = void 0;
1557
1697
  let isFirstChunk = true;
1558
- return {
1559
- stream: response.pipeThrough(
1698
+ const result = {
1699
+ stream: checkedResponse.pipeThrough(
1560
1700
  new TransformStream({
1561
1701
  start(controller) {
1562
1702
  controller.enqueue({ type: "stream-start", warnings });
@@ -1621,8 +1761,12 @@ var OpenAICompletionLanguageModel = class {
1621
1761
  request: { body },
1622
1762
  response: { headers: responseHeaders }
1623
1763
  };
1764
+ return result;
1624
1765
  }
1625
1766
  };
1767
+ function isOpenAICompletionOutputChunk(chunk) {
1768
+ return !("error" in chunk) && chunk.choices.some((choice) => choice.text.length > 0);
1769
+ }
1626
1770
 
1627
1771
  // src/embedding/openai-embedding-model.ts
1628
1772
  import {
@@ -2762,7 +2906,7 @@ var openaiTools = {
2762
2906
 
2763
2907
  // src/responses/openai-responses-language-model.ts
2764
2908
  import {
2765
- APICallError
2909
+ APICallError as APICallError2
2766
2910
  } from "@ai-sdk/provider";
2767
2911
  import {
2768
2912
  combineHeaders as combineHeaders5,
@@ -3300,7 +3444,7 @@ async function convertToOpenAIResponsesInput({
3300
3444
  outputValue = output.value;
3301
3445
  break;
3302
3446
  case "execution-denied":
3303
- outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
3447
+ outputValue = (_v = output.reason) != null ? _v : "Tool call execution denied.";
3304
3448
  break;
3305
3449
  case "json":
3306
3450
  case "error-json":
@@ -3361,7 +3505,7 @@ async function convertToOpenAIResponsesInput({
3361
3505
  contentValue = output.value;
3362
3506
  break;
3363
3507
  case "execution-denied":
3364
- contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
3508
+ contentValue = (_w = output.reason) != null ? _w : "Tool call execution denied.";
3365
3509
  break;
3366
3510
  case "json":
3367
3511
  case "error-json":
@@ -3478,6 +3622,23 @@ var jsonValueSchema2 = z22.lazy(
3478
3622
  z22.record(z22.string(), jsonValueSchema2.optional())
3479
3623
  ])
3480
3624
  );
3625
+ var openaiResponsesNestedErrorChunkSchema = z22.object({
3626
+ type: z22.literal("error"),
3627
+ sequence_number: z22.number(),
3628
+ error: z22.object({
3629
+ type: z22.string(),
3630
+ code: z22.string(),
3631
+ message: z22.string(),
3632
+ param: z22.string().nullish()
3633
+ })
3634
+ });
3635
+ var openaiResponsesErrorChunkSchema = z22.object({
3636
+ type: z22.literal("error"),
3637
+ sequence_number: z22.number(),
3638
+ code: z22.string().nullish(),
3639
+ message: z22.string(),
3640
+ param: z22.string().nullish()
3641
+ });
3481
3642
  var openaiResponsesChunkSchema = lazySchema20(
3482
3643
  () => zodSchema20(
3483
3644
  z22.union([
@@ -3520,6 +3681,7 @@ var openaiResponsesChunkSchema = lazySchema20(
3520
3681
  }),
3521
3682
  z22.object({
3522
3683
  type: z22.literal("response.failed"),
3684
+ sequence_number: z22.number(),
3523
3685
  response: z22.object({
3524
3686
  error: z22.object({
3525
3687
  code: z22.string().nullish(),
@@ -4008,16 +4170,8 @@ var openaiResponsesChunkSchema = lazySchema20(
4008
4170
  output_index: z22.number(),
4009
4171
  diff: z22.string()
4010
4172
  }),
4011
- z22.object({
4012
- type: z22.literal("error"),
4013
- sequence_number: z22.number(),
4014
- error: z22.object({
4015
- type: z22.string(),
4016
- code: z22.string(),
4017
- message: z22.string(),
4018
- param: z22.string().nullish()
4019
- })
4020
- }),
4173
+ openaiResponsesNestedErrorChunkSchema,
4174
+ openaiResponsesErrorChunkSchema,
4021
4175
  z22.object({ type: z22.string() }).loose().transform((value) => ({
4022
4176
  type: "unknown_chunk",
4023
4177
  message: value.type
@@ -4381,7 +4535,11 @@ var openaiResponsesReasoningModelIds = [
4381
4535
  "gpt-5.4-pro",
4382
4536
  "gpt-5.4-pro-2026-03-05",
4383
4537
  "gpt-5.5",
4384
- "gpt-5.5-2026-04-23"
4538
+ "gpt-5.5-2026-04-23",
4539
+ "gpt-5.6",
4540
+ "gpt-5.6-luna",
4541
+ "gpt-5.6-sol",
4542
+ "gpt-5.6-terra"
4385
4543
  ];
4386
4544
  var openaiResponsesModelIds = [
4387
4545
  "gpt-4.1",
@@ -5215,7 +5373,7 @@ var OpenAIResponsesLanguageModel = class {
5215
5373
  fetch: this.config.fetch
5216
5374
  });
5217
5375
  if (response.error) {
5218
- throw new APICallError({
5376
+ throw new APICallError2({
5219
5377
  message: response.error.message,
5220
5378
  url,
5221
5379
  requestBodyValues: body,
@@ -5688,6 +5846,14 @@ var OpenAIResponsesLanguageModel = class {
5688
5846
  abortSignal: options.abortSignal,
5689
5847
  fetch: this.config.fetch
5690
5848
  });
5849
+ const checkedResponse = await throwIfOpenAIStreamErrorBeforeOutput({
5850
+ stream: response,
5851
+ getError: (chunk) => isErrorChunk(chunk) || isResponseFailedChunk(chunk) && chunk.response.error != null ? chunk : void 0,
5852
+ isOutputChunk: isResponseOutputChunk,
5853
+ url,
5854
+ requestBodyValues: body,
5855
+ responseHeaders
5856
+ });
5691
5857
  const self = this;
5692
5858
  const approvalRequestIdToDummyToolCallIdFromPrompt = extractApprovalRequestIdToToolCallIdMapping(options.prompt);
5693
5859
  const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
@@ -5705,8 +5871,9 @@ var OpenAIResponsesLanguageModel = class {
5705
5871
  const activeReasoning = {};
5706
5872
  let serviceTier;
5707
5873
  const hostedToolSearchCallIds = [];
5708
- return {
5709
- stream: response.pipeThrough(
5874
+ let encounteredStreamError = false;
5875
+ const result = {
5876
+ stream: checkedResponse.pipeThrough(
5710
5877
  new TransformStream({
5711
5878
  start(controller) {
5712
5879
  controller.enqueue({ type: "stream-start", warnings });
@@ -6026,12 +6193,12 @@ var OpenAIResponsesLanguageModel = class {
6026
6193
  toolName: toolNameMapping.toCustomToolName("file_search"),
6027
6194
  result: {
6028
6195
  queries: value.item.queries,
6029
- results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result) => ({
6030
- attributes: result.attributes,
6031
- fileId: result.file_id,
6032
- filename: result.filename,
6033
- score: result.score,
6034
- text: result.text
6196
+ results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result2) => ({
6197
+ attributes: result2.attributes,
6198
+ fileId: result2.file_id,
6199
+ filename: result2.filename,
6200
+ score: result2.score,
6201
+ text: result2.text
6035
6202
  }))) != null ? _f : null
6036
6203
  }
6037
6204
  });
@@ -6464,6 +6631,21 @@ var OpenAIResponsesLanguageModel = class {
6464
6631
  raw: incompleteReason != null ? incompleteReason : "error"
6465
6632
  };
6466
6633
  usage = (_z = value.response.usage) != null ? _z : void 0;
6634
+ if (!encounteredStreamError && value.response.error != null) {
6635
+ encounteredStreamError = true;
6636
+ controller.enqueue({
6637
+ type: "error",
6638
+ error: {
6639
+ type: "response.failed",
6640
+ sequence_number: value.sequence_number,
6641
+ response: {
6642
+ error: value.response.error,
6643
+ incomplete_details: value.response.incomplete_details,
6644
+ service_tier: value.response.service_tier
6645
+ }
6646
+ }
6647
+ });
6648
+ }
6467
6649
  } else if (isResponseAnnotationAddedChunk(value)) {
6468
6650
  ongoingAnnotations.push(value.annotation);
6469
6651
  if (value.annotation.type === "url_citation") {
@@ -6524,6 +6706,8 @@ var OpenAIResponsesLanguageModel = class {
6524
6706
  });
6525
6707
  }
6526
6708
  } else if (isErrorChunk(value)) {
6709
+ encounteredStreamError = true;
6710
+ finishReason = { unified: "error", raw: "error" };
6527
6711
  controller.enqueue({ type: "error", error: value });
6528
6712
  }
6529
6713
  },
@@ -6547,13 +6731,14 @@ var OpenAIResponsesLanguageModel = class {
6547
6731
  request: { body },
6548
6732
  response: { headers: responseHeaders }
6549
6733
  };
6734
+ return result;
6550
6735
  }
6551
6736
  };
6552
6737
  function isTextDeltaChunk(chunk) {
6553
6738
  return chunk.type === "response.output_text.delta";
6554
6739
  }
6555
6740
  function isOpenAIChatCompletionChunk(value) {
6556
- const chunk = asRecord(value);
6741
+ const chunk = asRecord2(value);
6557
6742
  return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
6558
6743
  }
6559
6744
  function createOpenAIResponsesChatCompletionsMismatchError({
@@ -6563,7 +6748,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
6563
6748
  requestBodyValues,
6564
6749
  responseHeaders
6565
6750
  }) {
6566
- return new APICallError({
6751
+ return new APICallError2({
6567
6752
  message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
6568
6753
  url,
6569
6754
  requestBodyValues,
@@ -6574,7 +6759,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
6574
6759
  isRetryable: false
6575
6760
  });
6576
6761
  }
6577
- function asRecord(value) {
6762
+ function asRecord2(value) {
6578
6763
  return typeof value === "object" && value != null ? value : void 0;
6579
6764
  }
6580
6765
  function isResponseOutputItemDoneChunk(chunk) {
@@ -6619,6 +6804,9 @@ function isResponseAnnotationAddedChunk(chunk) {
6619
6804
  function isErrorChunk(chunk) {
6620
6805
  return chunk.type === "error";
6621
6806
  }
6807
+ function isResponseOutputChunk(chunk) {
6808
+ return !(chunk.type === "response.created" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
6809
+ }
6622
6810
  function mapWebSearchOutput(action) {
6623
6811
  var _a;
6624
6812
  if (action == null) {
@@ -7022,7 +7210,7 @@ var OpenAITranscriptionModel = class {
7022
7210
  };
7023
7211
 
7024
7212
  // src/version.ts
7025
- var VERSION = true ? "3.0.81" : "0.0.0-test";
7213
+ var VERSION = true ? "3.0.83" : "0.0.0-test";
7026
7214
 
7027
7215
  // src/openai-provider.ts
7028
7216
  function createOpenAI(options = {}) {