@ai-sdk/openai 3.0.105 → 3.0.107

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
@@ -76,6 +76,22 @@ function getGptVersion(modelId) {
76
76
 
77
77
  // src/openai-stream-error.ts
78
78
  import { APICallError } from "@ai-sdk/provider";
79
+ function createOpenAIProviderStreamError(frame) {
80
+ var _a2, _b;
81
+ const streamError = parseStreamError(frame);
82
+ if (streamError == null) {
83
+ return void 0;
84
+ }
85
+ const statusCode = getStatusCode(streamError);
86
+ return {
87
+ message: streamError.message,
88
+ type: (_a2 = streamError.type) != null ? _a2 : void 0,
89
+ code: (_b = streamError.code) != null ? _b : void 0,
90
+ statusCode,
91
+ isRetryable: isRetryableStreamError(streamError, statusCode),
92
+ data: frame
93
+ };
94
+ }
79
95
  async function throwIfOpenAIStreamErrorBeforeOutput({
80
96
  stream,
81
97
  getError,
@@ -147,16 +163,14 @@ function parseStreamError(frame) {
147
163
  return typeof (responseError == null ? void 0 : responseError.message) === "string" ? {
148
164
  message: responseError.message,
149
165
  code: getStringOrNumber(responseError.code),
150
- type: "response.failed",
151
- frame
166
+ type: "response.failed"
152
167
  } : void 0;
153
168
  }
154
169
  const error = (_a2 = asRecord(value.error)) != null ? _a2 : value;
155
170
  return typeof error.message === "string" && (asRecord(value.error) != null || typeof error.type === "string" || "code" in error || "param" in error) ? {
156
171
  message: error.message,
157
172
  code: getStringOrNumber(error.code),
158
- type: typeof error.type === "string" ? error.type : void 0,
159
- frame
173
+ type: typeof error.type === "string" ? error.type : void 0
160
174
  } : void 0;
161
175
  }
162
176
  function getStatusCode(error) {
@@ -196,6 +210,15 @@ function getStringOrNumber(value) {
196
210
  function isHttpErrorStatusCode(value) {
197
211
  return Number.isInteger(value) && value >= 400 && value <= 599;
198
212
  }
213
+ function isRetryableStatusCode(statusCode) {
214
+ return statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500;
215
+ }
216
+ function isRetryableStreamError(error, statusCode) {
217
+ if (error.code === "insufficient_quota" || error.type === "insufficient_quota") {
218
+ return false;
219
+ }
220
+ return isRetryableStatusCode(statusCode);
221
+ }
199
222
 
200
223
  // src/chat/convert-openai-chat-usage.ts
201
224
  function convertOpenAIChatUsage(usage) {
@@ -3165,23 +3188,34 @@ function serializeToolCallArguments2(input) {
3165
3188
  }
3166
3189
  async function convertFunctionToolResultOutput({
3167
3190
  output,
3191
+ promptCacheBreakpoint,
3168
3192
  providerOptionsName,
3169
3193
  warnings
3170
3194
  }) {
3171
3195
  var _a2;
3196
+ const convertScalarOutput = (value) => promptCacheBreakpoint == null ? value : [
3197
+ {
3198
+ type: "input_text",
3199
+ text: value,
3200
+ prompt_cache_breakpoint: promptCacheBreakpoint
3201
+ }
3202
+ ];
3172
3203
  switch (output.type) {
3173
3204
  case "text":
3174
3205
  case "error-text":
3175
- return output.value;
3176
- case "execution-denied":
3177
- return (_a2 = output.reason) != null ? _a2 : "Tool call execution denied.";
3206
+ return convertScalarOutput(output.value);
3207
+ case "execution-denied": {
3208
+ return convertScalarOutput(
3209
+ (_a2 = output.reason) != null ? _a2 : "Tool call execution denied."
3210
+ );
3211
+ }
3178
3212
  case "json":
3179
3213
  case "error-json":
3180
- return JSON.stringify(output.value);
3214
+ return convertScalarOutput(JSON.stringify(output.value));
3181
3215
  case "content":
3182
3216
  return output.value.map((item) => {
3183
3217
  var _a3, _b, _c, _d, _e;
3184
- const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3218
+ const promptCacheBreakpoint2 = getPromptCacheBreakpoint2(
3185
3219
  item.providerOptions,
3186
3220
  providerOptionsName
3187
3221
  );
@@ -3190,8 +3224,8 @@ async function convertFunctionToolResultOutput({
3190
3224
  return {
3191
3225
  type: "input_text",
3192
3226
  text: item.text,
3193
- ...promptCacheBreakpoint != null && {
3194
- prompt_cache_breakpoint: promptCacheBreakpoint
3227
+ ...promptCacheBreakpoint2 != null && {
3228
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3195
3229
  }
3196
3230
  };
3197
3231
  }
@@ -3200,8 +3234,8 @@ async function convertFunctionToolResultOutput({
3200
3234
  type: "input_image",
3201
3235
  image_url: `data:${item.mediaType};base64,${item.data}`,
3202
3236
  detail: (_b = (_a3 = item.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b.imageDetail,
3203
- ...promptCacheBreakpoint != null && {
3204
- prompt_cache_breakpoint: promptCacheBreakpoint
3237
+ ...promptCacheBreakpoint2 != null && {
3238
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3205
3239
  }
3206
3240
  };
3207
3241
  }
@@ -3210,8 +3244,8 @@ async function convertFunctionToolResultOutput({
3210
3244
  type: "input_image",
3211
3245
  image_url: item.url,
3212
3246
  detail: (_d = (_c = item.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.imageDetail,
3213
- ...promptCacheBreakpoint != null && {
3214
- prompt_cache_breakpoint: promptCacheBreakpoint
3247
+ ...promptCacheBreakpoint2 != null && {
3248
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3215
3249
  }
3216
3250
  };
3217
3251
  }
@@ -3220,8 +3254,8 @@ async function convertFunctionToolResultOutput({
3220
3254
  type: "input_file",
3221
3255
  filename: (_e = item.filename) != null ? _e : "data",
3222
3256
  file_data: `data:${item.mediaType};base64,${item.data}`,
3223
- ...promptCacheBreakpoint != null && {
3224
- prompt_cache_breakpoint: promptCacheBreakpoint
3257
+ ...promptCacheBreakpoint2 != null && {
3258
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3225
3259
  }
3226
3260
  };
3227
3261
  }
@@ -3229,8 +3263,8 @@ async function convertFunctionToolResultOutput({
3229
3263
  return {
3230
3264
  type: "input_file",
3231
3265
  file_url: item.url,
3232
- ...promptCacheBreakpoint != null && {
3233
- prompt_cache_breakpoint: promptCacheBreakpoint
3266
+ ...promptCacheBreakpoint2 != null && {
3267
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3234
3268
  }
3235
3269
  };
3236
3270
  }
@@ -3306,6 +3340,17 @@ function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
3306
3340
  var _a2;
3307
3341
  return (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.promptCacheBreakpoint;
3308
3342
  }
3343
+ function getScalarToolResultPromptCacheBreakpoint({
3344
+ output,
3345
+ toolResultProviderOptions,
3346
+ providerOptionsName
3347
+ }) {
3348
+ var _a2;
3349
+ return output.type === "content" ? void 0 : (_a2 = getPromptCacheBreakpoint2(output.providerOptions, providerOptionsName)) != null ? _a2 : getPromptCacheBreakpoint2(
3350
+ toolResultProviderOptions,
3351
+ providerOptionsName
3352
+ );
3353
+ }
3309
3354
  function isFileId(data, prefixes) {
3310
3355
  if (!prefixes) return false;
3311
3356
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -3806,22 +3851,41 @@ async function convertToOpenAIResponsesInput({
3806
3851
  parallelToolResultGroup.metadata.toolCallId
3807
3852
  );
3808
3853
  const toolOutputs = await Promise.all(
3809
- parallelToolResultGroup.results.map(
3810
- async (result) => convertFunctionToolResultOutput({
3854
+ parallelToolResultGroup.results.map(async (result) => {
3855
+ const promptCacheBreakpoint = getScalarToolResultPromptCacheBreakpoint({
3811
3856
  output: result.output,
3812
- providerOptionsName,
3813
- warnings
3814
- })
3815
- )
3857
+ toolResultProviderOptions: result.providerOptions,
3858
+ providerOptionsName
3859
+ });
3860
+ return {
3861
+ output: await convertFunctionToolResultOutput({
3862
+ output: result.output,
3863
+ providerOptionsName,
3864
+ warnings
3865
+ }),
3866
+ promptCacheBreakpoint
3867
+ };
3868
+ })
3869
+ );
3870
+ const serializedToolOutputs = toolOutputs.map(
3871
+ ({ output: output2 }) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
3872
+ );
3873
+ const hasPromptCacheBreakpoint = toolOutputs.some(
3874
+ ({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
3816
3875
  );
3817
3876
  input.push({
3818
3877
  type: "function_call_output",
3819
3878
  call_id: parallelToolResultGroup.metadata.toolCallId,
3820
3879
  // The internal wrapper returns one output containing the child
3821
3880
  // results in the same order as the original tool_uses array.
3822
- output: toolOutputs.map(
3823
- (output2) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
3824
- ).join("\n")
3881
+ output: hasPromptCacheBreakpoint ? serializedToolOutputs.map((text, index) => ({
3882
+ type: "input_text",
3883
+ text: index === 0 ? text : `
3884
+ ${text}`,
3885
+ ...toolOutputs[index].promptCacheBreakpoint != null && {
3886
+ prompt_cache_breakpoint: toolOutputs[index].promptCacheBreakpoint
3887
+ }
3888
+ })) : serializedToolOutputs.join("\n")
3825
3889
  });
3826
3890
  }
3827
3891
  continue;
@@ -3895,23 +3959,37 @@ async function convertToOpenAIResponsesInput({
3895
3959
  continue;
3896
3960
  }
3897
3961
  if (customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) {
3962
+ const promptCacheBreakpoint = getScalarToolResultPromptCacheBreakpoint({
3963
+ output,
3964
+ toolResultProviderOptions: part.providerOptions,
3965
+ providerOptionsName
3966
+ });
3967
+ const convertScalarOutput = (value) => promptCacheBreakpoint == null ? value : [
3968
+ {
3969
+ type: "input_text",
3970
+ text: value,
3971
+ prompt_cache_breakpoint: promptCacheBreakpoint
3972
+ }
3973
+ ];
3898
3974
  let outputValue;
3899
3975
  switch (output.type) {
3900
3976
  case "text":
3901
3977
  case "error-text":
3902
- outputValue = output.value;
3978
+ outputValue = convertScalarOutput(output.value);
3903
3979
  break;
3904
3980
  case "execution-denied":
3905
- outputValue = (_y = output.reason) != null ? _y : "Tool call execution denied.";
3981
+ outputValue = convertScalarOutput(
3982
+ (_y = output.reason) != null ? _y : "Tool call execution denied."
3983
+ );
3906
3984
  break;
3907
3985
  case "json":
3908
3986
  case "error-json":
3909
- outputValue = JSON.stringify(output.value);
3987
+ outputValue = convertScalarOutput(JSON.stringify(output.value));
3910
3988
  break;
3911
3989
  case "content":
3912
3990
  outputValue = output.value.map((item) => {
3913
3991
  var _a3, _b2, _c2, _d2, _e2;
3914
- const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3992
+ const promptCacheBreakpoint2 = getPromptCacheBreakpoint2(
3915
3993
  item.providerOptions,
3916
3994
  providerOptionsName
3917
3995
  );
@@ -3920,8 +3998,8 @@ async function convertToOpenAIResponsesInput({
3920
3998
  return {
3921
3999
  type: "input_text",
3922
4000
  text: item.text,
3923
- ...promptCacheBreakpoint != null && {
3924
- prompt_cache_breakpoint: promptCacheBreakpoint
4001
+ ...promptCacheBreakpoint2 != null && {
4002
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3925
4003
  }
3926
4004
  };
3927
4005
  case "image-data":
@@ -3929,8 +4007,8 @@ async function convertToOpenAIResponsesInput({
3929
4007
  type: "input_image",
3930
4008
  image_url: `data:${item.mediaType};base64,${item.data}`,
3931
4009
  detail: (_b2 = (_a3 = item.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3932
- ...promptCacheBreakpoint != null && {
3933
- prompt_cache_breakpoint: promptCacheBreakpoint
4010
+ ...promptCacheBreakpoint2 != null && {
4011
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3934
4012
  }
3935
4013
  };
3936
4014
  case "image-url":
@@ -3938,8 +4016,8 @@ async function convertToOpenAIResponsesInput({
3938
4016
  type: "input_image",
3939
4017
  image_url: item.url,
3940
4018
  detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3941
- ...promptCacheBreakpoint != null && {
3942
- prompt_cache_breakpoint: promptCacheBreakpoint
4019
+ ...promptCacheBreakpoint2 != null && {
4020
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3943
4021
  }
3944
4022
  };
3945
4023
  case "file-data":
@@ -3947,16 +4025,16 @@ async function convertToOpenAIResponsesInput({
3947
4025
  type: "input_file",
3948
4026
  filename: (_e2 = item.filename) != null ? _e2 : "data",
3949
4027
  file_data: `data:${item.mediaType};base64,${item.data}`,
3950
- ...promptCacheBreakpoint != null && {
3951
- prompt_cache_breakpoint: promptCacheBreakpoint
4028
+ ...promptCacheBreakpoint2 != null && {
4029
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3952
4030
  }
3953
4031
  };
3954
4032
  case "file-url":
3955
4033
  return {
3956
4034
  type: "input_file",
3957
4035
  file_url: item.url,
3958
- ...promptCacheBreakpoint != null && {
3959
- prompt_cache_breakpoint: promptCacheBreakpoint
4036
+ ...promptCacheBreakpoint2 != null && {
4037
+ prompt_cache_breakpoint: promptCacheBreakpoint2
3960
4038
  }
3961
4039
  };
3962
4040
  default:
@@ -3980,6 +4058,11 @@ async function convertToOpenAIResponsesInput({
3980
4058
  }
3981
4059
  const contentValue = await convertFunctionToolResultOutput({
3982
4060
  output,
4061
+ promptCacheBreakpoint: getScalarToolResultPromptCacheBreakpoint({
4062
+ output,
4063
+ toolResultProviderOptions: part.providerOptions,
4064
+ providerOptionsName
4065
+ }),
3983
4066
  providerOptionsName,
3984
4067
  warnings
3985
4068
  });
@@ -4049,6 +4132,31 @@ var jsonValueSchema2 = z22.lazy(
4049
4132
  z22.record(z22.string(), jsonValueSchema2.optional())
4050
4133
  ])
4051
4134
  );
4135
+ var jsonObjectSchema = z22.record(z22.string(), jsonValueSchema2.optional());
4136
+ var openaiResponsesUsageSchema = z22.intersection(
4137
+ jsonObjectSchema,
4138
+ z22.object({
4139
+ input_tokens: z22.number(),
4140
+ input_tokens_details: z22.intersection(
4141
+ jsonObjectSchema,
4142
+ z22.object({
4143
+ cached_tokens: z22.number().nullish(),
4144
+ cache_write_tokens: z22.number().nullish(),
4145
+ orchestration_input_tokens: z22.number().nullish(),
4146
+ orchestration_input_cached_tokens: z22.number().nullish()
4147
+ })
4148
+ ).nullish(),
4149
+ output_tokens: z22.number(),
4150
+ output_tokens_details: z22.intersection(
4151
+ jsonObjectSchema,
4152
+ z22.object({
4153
+ reasoning_tokens: z22.number().nullish(),
4154
+ orchestration_output_tokens: z22.number().nullish()
4155
+ })
4156
+ ).nullish(),
4157
+ total_tokens: z22.number().optional()
4158
+ })
4159
+ );
4052
4160
  function isRecord(value) {
4053
4161
  return value != null && typeof value === "object" && !Array.isArray(value);
4054
4162
  }
@@ -4160,20 +4268,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4160
4268
  type: z22.enum(["response.completed", "response.incomplete"]),
4161
4269
  response: z22.object({
4162
4270
  incomplete_details: z22.object({ reason: z22.string() }).nullish(),
4163
- usage: z22.object({
4164
- input_tokens: z22.number(),
4165
- input_tokens_details: z22.object({
4166
- cached_tokens: z22.number().nullish(),
4167
- cache_write_tokens: z22.number().nullish(),
4168
- orchestration_input_tokens: z22.number().nullish(),
4169
- orchestration_input_cached_tokens: z22.number().nullish()
4170
- }).nullish(),
4171
- output_tokens: z22.number(),
4172
- output_tokens_details: z22.object({
4173
- reasoning_tokens: z22.number().nullish(),
4174
- orchestration_output_tokens: z22.number().nullish()
4175
- }).nullish()
4176
- }),
4271
+ usage: openaiResponsesUsageSchema.nullish(),
4177
4272
  reasoning: z22.object({
4178
4273
  context: z22.string().nullish()
4179
4274
  }).nullish(),
@@ -4189,20 +4284,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4189
4284
  message: z22.string()
4190
4285
  }).nullish(),
4191
4286
  incomplete_details: z22.object({ reason: z22.string() }).nullish(),
4192
- usage: z22.object({
4193
- input_tokens: z22.number(),
4194
- input_tokens_details: z22.object({
4195
- cached_tokens: z22.number().nullish(),
4196
- cache_write_tokens: z22.number().nullish(),
4197
- orchestration_input_tokens: z22.number().nullish(),
4198
- orchestration_input_cached_tokens: z22.number().nullish()
4199
- }).nullish(),
4200
- output_tokens: z22.number(),
4201
- output_tokens_details: z22.object({
4202
- reasoning_tokens: z22.number().nullish(),
4203
- orchestration_output_tokens: z22.number().nullish()
4204
- }).nullish()
4205
- }).nullish(),
4287
+ usage: openaiResponsesUsageSchema.nullish(),
4206
4288
  reasoning: z22.object({
4207
4289
  context: z22.string().nullish()
4208
4290
  }).nullish(),
@@ -4968,20 +5050,7 @@ var openaiResponsesResponseSchema = lazySchema20(
4968
5050
  context: z22.string().nullish()
4969
5051
  }).nullish(),
4970
5052
  incomplete_details: z22.object({ reason: z22.string() }).nullish(),
4971
- usage: z22.object({
4972
- input_tokens: z22.number(),
4973
- input_tokens_details: z22.object({
4974
- cached_tokens: z22.number().nullish(),
4975
- cache_write_tokens: z22.number().nullish(),
4976
- orchestration_input_tokens: z22.number().nullish(),
4977
- orchestration_input_cached_tokens: z22.number().nullish()
4978
- }).nullish(),
4979
- output_tokens: z22.number(),
4980
- output_tokens_details: z22.object({
4981
- reasoning_tokens: z22.number().nullish(),
4982
- orchestration_output_tokens: z22.number().nullish()
4983
- }).nullish()
4984
- }).optional()
5053
+ usage: openaiResponsesUsageSchema.nullish()
4985
5054
  })
4986
5055
  )
4987
5056
  );
@@ -6573,7 +6642,7 @@ var OpenAIResponsesLanguageModel = class {
6573
6642
  controller.enqueue({ type: "stream-start", warnings });
6574
6643
  },
6575
6644
  transform(chunk, controller) {
6576
- var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
6645
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S;
6577
6646
  if (options.includeRawChunks) {
6578
6647
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6579
6648
  }
@@ -7394,15 +7463,15 @@ var OpenAIResponsesLanguageModel = class {
7394
7463
  raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7395
7464
  };
7396
7465
  }
7397
- usage = value.response.usage;
7466
+ usage = (_A = value.response.usage) != null ? _A : void 0;
7398
7467
  if (typeof value.response.service_tier === "string") {
7399
7468
  serviceTier = value.response.service_tier;
7400
7469
  }
7401
- if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
7470
+ if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7402
7471
  reasoningContext = value.response.reasoning.context;
7403
7472
  }
7404
7473
  } else if (isResponseFailedChunk(value)) {
7405
- const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
7474
+ const incompleteReason = (_C = value.response.incomplete_details) == null ? void 0 : _C.reason;
7406
7475
  finishReason = {
7407
7476
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
7408
7477
  finishReason: incompleteReason,
@@ -7410,23 +7479,24 @@ var OpenAIResponsesLanguageModel = class {
7410
7479
  }) : "error",
7411
7480
  raw: incompleteReason != null ? incompleteReason : "error"
7412
7481
  };
7413
- usage = (_C = value.response.usage) != null ? _C : void 0;
7414
- if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
7482
+ usage = (_D = value.response.usage) != null ? _D : void 0;
7483
+ if (((_E = value.response.reasoning) == null ? void 0 : _E.context) != null) {
7415
7484
  reasoningContext = value.response.reasoning.context;
7416
7485
  }
7417
7486
  if (!encounteredStreamError && value.response.error != null) {
7418
7487
  encounteredStreamError = true;
7488
+ const error = {
7489
+ type: "response.failed",
7490
+ sequence_number: value.sequence_number,
7491
+ response: {
7492
+ error: value.response.error,
7493
+ incomplete_details: value.response.incomplete_details,
7494
+ service_tier: value.response.service_tier
7495
+ }
7496
+ };
7419
7497
  controller.enqueue({
7420
7498
  type: "error",
7421
- error: {
7422
- type: "response.failed",
7423
- sequence_number: value.sequence_number,
7424
- response: {
7425
- error: value.response.error,
7426
- incomplete_details: value.response.incomplete_details,
7427
- service_tier: value.response.service_tier
7428
- }
7429
- }
7499
+ error: (_F = createOpenAIProviderStreamError(error)) != null ? _F : error
7430
7500
  });
7431
7501
  }
7432
7502
  } else if (isResponseAnnotationAddedChunk(value)) {
@@ -7435,7 +7505,7 @@ var OpenAIResponsesLanguageModel = class {
7435
7505
  controller.enqueue({
7436
7506
  type: "source",
7437
7507
  sourceType: "url",
7438
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : generateId2(),
7508
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
7439
7509
  url: value.annotation.url,
7440
7510
  title: value.annotation.title
7441
7511
  });
@@ -7443,7 +7513,7 @@ var OpenAIResponsesLanguageModel = class {
7443
7513
  controller.enqueue({
7444
7514
  type: "source",
7445
7515
  sourceType: "document",
7446
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : generateId2(),
7516
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
7447
7517
  mediaType: "text/plain",
7448
7518
  title: value.annotation.filename,
7449
7519
  filename: value.annotation.filename,
@@ -7459,7 +7529,7 @@ var OpenAIResponsesLanguageModel = class {
7459
7529
  controller.enqueue({
7460
7530
  type: "source",
7461
7531
  sourceType: "document",
7462
- id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : generateId2(),
7532
+ id: (_O = (_N = (_M = self.config).generateId) == null ? void 0 : _N.call(_M)) != null ? _O : generateId2(),
7463
7533
  mediaType: "text/plain",
7464
7534
  title: value.annotation.filename,
7465
7535
  filename: value.annotation.filename,
@@ -7475,7 +7545,7 @@ var OpenAIResponsesLanguageModel = class {
7475
7545
  controller.enqueue({
7476
7546
  type: "source",
7477
7547
  sourceType: "document",
7478
- id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : generateId2(),
7548
+ id: (_R = (_Q = (_P = self.config).generateId) == null ? void 0 : _Q.call(_P)) != null ? _R : generateId2(),
7479
7549
  mediaType: "application/octet-stream",
7480
7550
  title: value.annotation.file_id,
7481
7551
  filename: value.annotation.file_id,
@@ -7491,7 +7561,10 @@ var OpenAIResponsesLanguageModel = class {
7491
7561
  } else if (isErrorChunk(value)) {
7492
7562
  encounteredStreamError = true;
7493
7563
  finishReason = { unified: "error", raw: "error" };
7494
- controller.enqueue({ type: "error", error: value });
7564
+ controller.enqueue({
7565
+ type: "error",
7566
+ error: (_S = createOpenAIProviderStreamError(value)) != null ? _S : value
7567
+ });
7495
7568
  }
7496
7569
  },
7497
7570
  flush(controller) {
@@ -8012,7 +8085,7 @@ var OpenAITranscriptionModel = class {
8012
8085
  };
8013
8086
 
8014
8087
  // src/version.ts
8015
- var VERSION = true ? "3.0.105" : "0.0.0-test";
8088
+ var VERSION = true ? "3.0.107" : "0.0.0-test";
8016
8089
 
8017
8090
  // src/openai-provider.ts
8018
8091
  function createOpenAI(options = {}) {