@ai-sdk/openai 3.0.134 → 3.0.136

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,23 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.136
4
+
5
+ ### Patch Changes
6
+
7
+ - d900e58: fix(openai): preserve valid JSON string tool arguments and serialize BigInt and cycles in tool calls and results, retaining malformed argument replay fallbacks
8
+ - d900e58: Forward `languages` and `keywords` transcription hints as repeated multipart fields instead of silently dropping them.
9
+ - Updated dependencies [d900e58]
10
+ - Updated dependencies [d900e58]
11
+ - Updated dependencies [d900e58]
12
+ - @ai-sdk/provider-utils@4.0.64
13
+
14
+ ## 3.0.135
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [28252da]
19
+ - @ai-sdk/provider-utils@4.0.63
20
+
3
21
  ## 3.0.134
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1154,6 +1154,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
1154
1154
  declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
1155
1155
  include?: string[] | undefined;
1156
1156
  language?: string | undefined;
1157
+ languages?: string[] | undefined;
1158
+ keywords?: string[] | undefined;
1157
1159
  prompt?: string | undefined;
1158
1160
  temperature?: number | undefined;
1159
1161
  timestampGranularities?: ("word" | "segment")[] | undefined;
package/dist/index.d.ts CHANGED
@@ -1154,6 +1154,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
1154
1154
  declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
1155
1155
  include?: string[] | undefined;
1156
1156
  language?: string | undefined;
1157
+ languages?: string[] | undefined;
1158
+ keywords?: string[] | undefined;
1157
1159
  prompt?: string | undefined;
1158
1160
  temperature?: number | undefined;
1159
1161
  timestampGranularities?: ("word" | "segment")[] | undefined;
package/dist/index.js CHANGED
@@ -379,7 +379,18 @@ function convertOpenAIChatUsage(usage) {
379
379
  var import_provider2 = require("@ai-sdk/provider");
380
380
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
381
381
  function serializeToolCallArguments(input) {
382
- return JSON.stringify(
382
+ if (typeof input === "string") {
383
+ try {
384
+ const parsed = (0, import_provider_utils2.secureJsonParse)(input);
385
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
386
+ return "{}";
387
+ }
388
+ return input;
389
+ } catch (e) {
390
+ return "{}";
391
+ }
392
+ }
393
+ return (0, import_provider_utils2.stringifyWithBigIntAndCycles)(
383
394
  typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
384
395
  );
385
396
  }
@@ -607,7 +618,7 @@ function convertToOpenAIChatMessages({
607
618
  case "content":
608
619
  case "json":
609
620
  case "error-json":
610
- contentValue = JSON.stringify(output.value);
621
+ contentValue = (0, import_provider_utils2.stringifyWithBigIntAndCycles)(output.value);
611
622
  break;
612
623
  }
613
624
  messages.push({
@@ -3461,7 +3472,15 @@ async function expandParallelToolCall({
3461
3472
 
3462
3473
  // src/responses/convert-to-openai-responses-input.ts
3463
3474
  function serializeToolCallArguments2(input) {
3464
- return JSON.stringify(input === void 0 ? {} : input);
3475
+ if (typeof input === "string") {
3476
+ try {
3477
+ (0, import_provider_utils28.secureJsonParse)(input);
3478
+ return input;
3479
+ } catch (e) {
3480
+ return (0, import_provider_utils28.stringifyWithBigIntAndCycles)(input);
3481
+ }
3482
+ }
3483
+ return (0, import_provider_utils28.stringifyWithBigIntAndCycles)(input === void 0 ? {} : input);
3465
3484
  }
3466
3485
  async function convertWebSearchToolResultOutput({
3467
3486
  output,
@@ -3539,7 +3558,7 @@ async function convertFunctionToolResultOutput({
3539
3558
  }
3540
3559
  case "json":
3541
3560
  case "error-json":
3542
- return convertScalarOutput(JSON.stringify(output.value));
3561
+ return convertScalarOutput((0, import_provider_utils28.stringifyWithBigIntAndCycles)(output.value));
3543
3562
  case "content":
3544
3563
  return output.value.map((item) => {
3545
3564
  var _a3, _b, _c, _d, _e, _f, _g;
@@ -4042,7 +4061,7 @@ async function convertToOpenAIResponsesInput({
4042
4061
  type: "custom_tool_call",
4043
4062
  call_id: part.toolCallId,
4044
4063
  name: resolvedToolName,
4045
- input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
4064
+ input: typeof part.input === "string" ? part.input : (0, import_provider_utils28.stringifyWithBigIntAndCycles)(part.input),
4046
4065
  ...isAsync != null && { async: isAsync },
4047
4066
  id
4048
4067
  });
@@ -4168,7 +4187,7 @@ async function convertToOpenAIResponsesInput({
4168
4187
  } else if (reasoningMessage !== void 0) {
4169
4188
  warnings.push({
4170
4189
  type: "other",
4171
- message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
4190
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${(0, import_provider_utils28.stringifyWithBigIntAndCycles)(part)}.`
4172
4191
  });
4173
4192
  }
4174
4193
  if (reasoningMessage === void 0) {
@@ -4204,7 +4223,7 @@ async function convertToOpenAIResponsesInput({
4204
4223
  } else {
4205
4224
  warnings.push({
4206
4225
  type: "other",
4207
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
4226
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${(0, import_provider_utils28.stringifyWithBigIntAndCycles)(part)}.`
4208
4227
  });
4209
4228
  }
4210
4229
  }
@@ -4270,7 +4289,7 @@ async function convertToOpenAIResponsesInput({
4270
4289
  })
4271
4290
  );
4272
4291
  const serializedToolOutputs = toolOutputs.map(
4273
- ({ output: output2 }) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
4292
+ ({ output: output2 }) => typeof output2 === "string" ? output2 : (0, import_provider_utils28.stringifyWithBigIntAndCycles)(output2)
4274
4293
  );
4275
4294
  const hasPromptCacheBreakpoint = toolOutputs.some(
4276
4295
  ({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
@@ -4386,7 +4405,9 @@ ${text}`,
4386
4405
  break;
4387
4406
  case "json":
4388
4407
  case "error-json":
4389
- outputValue = convertScalarOutput(JSON.stringify(output.value));
4408
+ outputValue = convertScalarOutput(
4409
+ (0, import_provider_utils28.stringifyWithBigIntAndCycles)(output.value)
4410
+ );
4390
4411
  break;
4391
4412
  case "content":
4392
4413
  outputValue = output.value.map((item) => {
@@ -8153,6 +8174,16 @@ var openAITranscriptionModelOptions = (0, import_provider_utils35.lazySchema)(
8153
8174
  * The language of the input audio in ISO-639-1 format.
8154
8175
  */
8155
8176
  language: import_v426.z.string().optional(),
8177
+ /**
8178
+ * Expected languages for REST transcription, e.g. with gpt-transcribe.
8179
+ * Use this instead of language. The API validates model support.
8180
+ */
8181
+ languages: import_v426.z.array(import_v426.z.string()).optional(),
8182
+ /**
8183
+ * Vocabulary hints for REST transcription, e.g. names or technical terms.
8184
+ * The API validates model support.
8185
+ */
8186
+ keywords: import_v426.z.array(import_v426.z.string()).optional(),
8156
8187
  /**
8157
8188
  * An optional text to guide the model's style or continue a previous audio segment.
8158
8189
  */
@@ -8264,6 +8295,8 @@ var OpenAITranscriptionModel = class {
8264
8295
  const transcriptionModelOptions = {
8265
8296
  include: openAIOptions.include,
8266
8297
  language: openAIOptions.language,
8298
+ languages: openAIOptions.languages,
8299
+ keywords: openAIOptions.keywords,
8267
8300
  prompt: openAIOptions.prompt,
8268
8301
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
8269
8302
  // prefer verbose_json to get segments for models that support it
@@ -8340,7 +8373,7 @@ var OpenAITranscriptionModel = class {
8340
8373
  };
8341
8374
 
8342
8375
  // src/version.ts
8343
- var VERSION = true ? "3.0.134" : "0.0.0-test";
8376
+ var VERSION = true ? "3.0.136" : "0.0.0-test";
8344
8377
 
8345
8378
  // src/openai-provider.ts
8346
8379
  function createOpenAI(options = {}) {