@ai-sdk/openai-compatible 2.0.88 → 2.0.90

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ai-sdk/openai-compatible
2
2
 
3
+ ## 2.0.90
4
+
5
+ ### Patch Changes
6
+
7
+ - d900e58: fix(openai-compatible): preserve string tool call arguments and safely serialize BigInt and circular structures in tool calls and outputs
8
+ - Updated dependencies [d900e58]
9
+ - Updated dependencies [d900e58]
10
+ - Updated dependencies [d900e58]
11
+ - @ai-sdk/provider-utils@4.0.64
12
+
13
+ ## 2.0.89
14
+
15
+ ### Patch Changes
16
+
17
+ - 03066cf: fix(openai-compatible): send `reasoningEffort: null` as `"reasoning_effort": null`, and stop an unset `reasoningEffort` from overwriting a raw `reasoning_effort` provider option
18
+
3
19
  ## 2.0.88
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -21,7 +21,7 @@ type ProviderErrorStructure<T> = {
21
21
  type OpenAICompatibleChatModelId = string;
22
22
  declare const openaiCompatibleLanguageModelChatOptions: z.ZodObject<{
23
23
  user: z.ZodOptional<z.ZodString>;
24
- reasoningEffort: z.ZodOptional<z.ZodString>;
24
+ reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
25
  textVerbosity: z.ZodOptional<z.ZodString>;
26
26
  strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
27
27
  }, z.core.$strip>;
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ type ProviderErrorStructure<T> = {
21
21
  type OpenAICompatibleChatModelId = string;
22
22
  declare const openaiCompatibleLanguageModelChatOptions: z.ZodObject<{
23
23
  user: z.ZodOptional<z.ZodString>;
24
- reasoningEffort: z.ZodOptional<z.ZodString>;
24
+ reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
25
  textVerbosity: z.ZodOptional<z.ZodString>;
26
26
  strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
27
27
  }, z.core.$strip>;
package/dist/index.js CHANGED
@@ -121,6 +121,17 @@ function getAudioFormat(mediaType) {
121
121
  return null;
122
122
  }
123
123
  }
124
+ function serializeToolCallArguments(input) {
125
+ if (typeof input === "string") {
126
+ try {
127
+ (0, import_provider_utils.secureJsonParse)(input);
128
+ return input;
129
+ } catch (e) {
130
+ return JSON.stringify(input);
131
+ }
132
+ }
133
+ return (0, import_provider_utils.stringifyWithBigIntAndCycles)(input);
134
+ }
124
135
  function convertToOpenAICompatibleChatMessages(prompt) {
125
136
  var _a, _b, _c;
126
137
  const messages = [];
@@ -238,7 +249,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
238
249
  type: "function",
239
250
  function: {
240
251
  name: part.toolName,
241
- arguments: JSON.stringify(part.input)
252
+ arguments: serializeToolCallArguments(part.input)
242
253
  },
243
254
  ...partMetadata,
244
255
  // Include extra_content for Google Gemini thought signatures
@@ -281,7 +292,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
281
292
  case "content":
282
293
  case "json":
283
294
  case "error-json":
284
- contentValue = JSON.stringify(output.value);
295
+ contentValue = (0, import_provider_utils.stringifyWithBigIntAndCycles)(output.value);
285
296
  break;
286
297
  }
287
298
  const toolResponseMetadata = getOpenAIMetadata(toolResponse);
@@ -343,8 +354,11 @@ var openaiCompatibleLanguageModelChatOptions = import_v42.z.object({
343
354
  user: import_v42.z.string().optional(),
344
355
  /**
345
356
  * Reasoning effort for reasoning models. Defaults to `medium`.
357
+ *
358
+ * Set to `null` to send `"reasoning_effort": null`, for providers that treat
359
+ * an explicit `null` differently from an omitted field.
346
360
  */
347
- reasoningEffort: import_v42.z.string().optional(),
361
+ reasoningEffort: import_v42.z.string().nullish(),
348
362
  /**
349
363
  * Controls the verbosity of the generated text. Defaults to `medium`.
350
364
  */
@@ -552,7 +566,9 @@ var OpenAICompatibleChatLanguageModel = class {
552
566
  ).includes(key)
553
567
  )
554
568
  ),
555
- reasoning_effort: compatibleOptions.reasoningEffort,
569
+ // Preserve explicit null and avoid overwriting a raw reasoning_effort
570
+ // provider option when reasoningEffort is unset.
571
+ ...compatibleOptions.reasoningEffort !== void 0 ? { reasoning_effort: compatibleOptions.reasoningEffort } : {},
556
572
  verbosity: compatibleOptions.textVerbosity,
557
573
  // messages:
558
574
  messages: convertToOpenAICompatibleChatMessages(prompt),
@@ -1780,7 +1796,7 @@ async function fileToBlob(file) {
1780
1796
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1781
1797
 
1782
1798
  // src/version.ts
1783
- var VERSION = true ? "2.0.88" : "0.0.0-test";
1799
+ var VERSION = true ? "2.0.90" : "0.0.0-test";
1784
1800
 
1785
1801
  // src/openai-compatible-provider.ts
1786
1802
  function createOpenAICompatible(options) {