@ai-sdk/openai 3.0.135 → 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.
@@ -178,6 +178,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
178
178
  declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
179
179
  include?: string[] | undefined;
180
180
  language?: string | undefined;
181
+ languages?: string[] | undefined;
182
+ keywords?: string[] | undefined;
181
183
  prompt?: string | undefined;
182
184
  temperature?: number | undefined;
183
185
  timestampGranularities?: ("word" | "segment")[] | undefined;
@@ -178,6 +178,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
178
178
  declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
179
179
  include?: string[] | undefined;
180
180
  language?: string | undefined;
181
+ languages?: string[] | undefined;
182
+ keywords?: string[] | undefined;
181
183
  prompt?: string | undefined;
182
184
  temperature?: number | undefined;
183
185
  timestampGranularities?: ("word" | "segment")[] | undefined;
@@ -419,7 +419,18 @@ function convertOpenAIChatUsage(usage) {
419
419
  var import_provider2 = require("@ai-sdk/provider");
420
420
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
421
421
  function serializeToolCallArguments(input) {
422
- return JSON.stringify(
422
+ if (typeof input === "string") {
423
+ try {
424
+ const parsed = (0, import_provider_utils2.secureJsonParse)(input);
425
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
426
+ return "{}";
427
+ }
428
+ return input;
429
+ } catch (e) {
430
+ return "{}";
431
+ }
432
+ }
433
+ return (0, import_provider_utils2.stringifyWithBigIntAndCycles)(
423
434
  typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
424
435
  );
425
436
  }
@@ -647,7 +658,7 @@ function convertToOpenAIChatMessages({
647
658
  case "content":
648
659
  case "json":
649
660
  case "error-json":
650
- contentValue = JSON.stringify(output.value);
661
+ contentValue = (0, import_provider_utils2.stringifyWithBigIntAndCycles)(output.value);
651
662
  break;
652
663
  }
653
664
  messages.push({
@@ -2482,6 +2493,16 @@ var openAITranscriptionModelOptions = (0, import_provider_utils16.lazySchema)(
2482
2493
  * The language of the input audio in ISO-639-1 format.
2483
2494
  */
2484
2495
  language: import_v411.z.string().optional(),
2496
+ /**
2497
+ * Expected languages for REST transcription, e.g. with gpt-transcribe.
2498
+ * Use this instead of language. The API validates model support.
2499
+ */
2500
+ languages: import_v411.z.array(import_v411.z.string()).optional(),
2501
+ /**
2502
+ * Vocabulary hints for REST transcription, e.g. names or technical terms.
2503
+ * The API validates model support.
2504
+ */
2505
+ keywords: import_v411.z.array(import_v411.z.string()).optional(),
2485
2506
  /**
2486
2507
  * An optional text to guide the model's style or continue a previous audio segment.
2487
2508
  */
@@ -2593,6 +2614,8 @@ var OpenAITranscriptionModel = class {
2593
2614
  const transcriptionModelOptions = {
2594
2615
  include: openAIOptions.include,
2595
2616
  language: openAIOptions.language,
2617
+ languages: openAIOptions.languages,
2618
+ keywords: openAIOptions.keywords,
2596
2619
  prompt: openAIOptions.prompt,
2597
2620
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
2598
2621
  // prefer verbose_json to get segments for models that support it
@@ -3471,7 +3494,15 @@ async function expandParallelToolCall({
3471
3494
 
3472
3495
  // src/responses/convert-to-openai-responses-input.ts
3473
3496
  function serializeToolCallArguments2(input) {
3474
- return JSON.stringify(input === void 0 ? {} : input);
3497
+ if (typeof input === "string") {
3498
+ try {
3499
+ (0, import_provider_utils27.secureJsonParse)(input);
3500
+ return input;
3501
+ } catch (e) {
3502
+ return (0, import_provider_utils27.stringifyWithBigIntAndCycles)(input);
3503
+ }
3504
+ }
3505
+ return (0, import_provider_utils27.stringifyWithBigIntAndCycles)(input === void 0 ? {} : input);
3475
3506
  }
3476
3507
  async function convertWebSearchToolResultOutput({
3477
3508
  output,
@@ -3549,7 +3580,7 @@ async function convertFunctionToolResultOutput({
3549
3580
  }
3550
3581
  case "json":
3551
3582
  case "error-json":
3552
- return convertScalarOutput(JSON.stringify(output.value));
3583
+ return convertScalarOutput((0, import_provider_utils27.stringifyWithBigIntAndCycles)(output.value));
3553
3584
  case "content":
3554
3585
  return output.value.map((item) => {
3555
3586
  var _a3, _b, _c, _d, _e, _f, _g;
@@ -4052,7 +4083,7 @@ async function convertToOpenAIResponsesInput({
4052
4083
  type: "custom_tool_call",
4053
4084
  call_id: part.toolCallId,
4054
4085
  name: resolvedToolName,
4055
- input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
4086
+ input: typeof part.input === "string" ? part.input : (0, import_provider_utils27.stringifyWithBigIntAndCycles)(part.input),
4056
4087
  ...isAsync != null && { async: isAsync },
4057
4088
  id
4058
4089
  });
@@ -4178,7 +4209,7 @@ async function convertToOpenAIResponsesInput({
4178
4209
  } else if (reasoningMessage !== void 0) {
4179
4210
  warnings.push({
4180
4211
  type: "other",
4181
- message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
4212
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${(0, import_provider_utils27.stringifyWithBigIntAndCycles)(part)}.`
4182
4213
  });
4183
4214
  }
4184
4215
  if (reasoningMessage === void 0) {
@@ -4214,7 +4245,7 @@ async function convertToOpenAIResponsesInput({
4214
4245
  } else {
4215
4246
  warnings.push({
4216
4247
  type: "other",
4217
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
4248
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${(0, import_provider_utils27.stringifyWithBigIntAndCycles)(part)}.`
4218
4249
  });
4219
4250
  }
4220
4251
  }
@@ -4280,7 +4311,7 @@ async function convertToOpenAIResponsesInput({
4280
4311
  })
4281
4312
  );
4282
4313
  const serializedToolOutputs = toolOutputs.map(
4283
- ({ output: output2 }) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
4314
+ ({ output: output2 }) => typeof output2 === "string" ? output2 : (0, import_provider_utils27.stringifyWithBigIntAndCycles)(output2)
4284
4315
  );
4285
4316
  const hasPromptCacheBreakpoint = toolOutputs.some(
4286
4317
  ({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
@@ -4396,7 +4427,9 @@ ${text}`,
4396
4427
  break;
4397
4428
  case "json":
4398
4429
  case "error-json":
4399
- outputValue = convertScalarOutput(JSON.stringify(output.value));
4430
+ outputValue = convertScalarOutput(
4431
+ (0, import_provider_utils27.stringifyWithBigIntAndCycles)(output.value)
4432
+ );
4400
4433
  break;
4401
4434
  case "content":
4402
4435
  outputValue = output.value.map((item) => {