@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/dist/index.mjs CHANGED
@@ -370,9 +370,24 @@ function convertOpenAIChatUsage(usage) {
370
370
  import {
371
371
  UnsupportedFunctionalityError
372
372
  } from "@ai-sdk/provider";
373
- import { convertToBase64 } from "@ai-sdk/provider-utils";
373
+ import {
374
+ secureJsonParse,
375
+ stringifyWithBigIntAndCycles,
376
+ convertToBase64
377
+ } from "@ai-sdk/provider-utils";
374
378
  function serializeToolCallArguments(input) {
375
- return JSON.stringify(
379
+ if (typeof input === "string") {
380
+ try {
381
+ const parsed = secureJsonParse(input);
382
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
383
+ return "{}";
384
+ }
385
+ return input;
386
+ } catch (e) {
387
+ return "{}";
388
+ }
389
+ }
390
+ return stringifyWithBigIntAndCycles(
376
391
  typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
377
392
  );
378
393
  }
@@ -600,7 +615,7 @@ function convertToOpenAIChatMessages({
600
615
  case "content":
601
616
  case "json":
602
617
  case "error-json":
603
- contentValue = JSON.stringify(output.value);
618
+ contentValue = stringifyWithBigIntAndCycles(output.value);
604
619
  break;
605
620
  }
606
621
  messages.push({
@@ -3174,6 +3189,8 @@ import {
3174
3189
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
3175
3190
  } from "@ai-sdk/provider";
3176
3191
  import {
3192
+ secureJsonParse as secureJsonParse2,
3193
+ stringifyWithBigIntAndCycles as stringifyWithBigIntAndCycles2,
3177
3194
  lazySchema as lazySchema22,
3178
3195
  zodSchema as zodSchema22,
3179
3196
  convertToBase64 as convertToBase642,
@@ -3571,7 +3588,15 @@ async function expandParallelToolCall({
3571
3588
 
3572
3589
  // src/responses/convert-to-openai-responses-input.ts
3573
3590
  function serializeToolCallArguments2(input) {
3574
- return JSON.stringify(input === void 0 ? {} : input);
3591
+ if (typeof input === "string") {
3592
+ try {
3593
+ secureJsonParse2(input);
3594
+ return input;
3595
+ } catch (e) {
3596
+ return stringifyWithBigIntAndCycles2(input);
3597
+ }
3598
+ }
3599
+ return stringifyWithBigIntAndCycles2(input === void 0 ? {} : input);
3575
3600
  }
3576
3601
  async function convertWebSearchToolResultOutput({
3577
3602
  output,
@@ -3649,7 +3674,7 @@ async function convertFunctionToolResultOutput({
3649
3674
  }
3650
3675
  case "json":
3651
3676
  case "error-json":
3652
- return convertScalarOutput(JSON.stringify(output.value));
3677
+ return convertScalarOutput(stringifyWithBigIntAndCycles2(output.value));
3653
3678
  case "content":
3654
3679
  return output.value.map((item) => {
3655
3680
  var _a3, _b, _c, _d, _e, _f, _g;
@@ -4152,7 +4177,7 @@ async function convertToOpenAIResponsesInput({
4152
4177
  type: "custom_tool_call",
4153
4178
  call_id: part.toolCallId,
4154
4179
  name: resolvedToolName,
4155
- input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
4180
+ input: typeof part.input === "string" ? part.input : stringifyWithBigIntAndCycles2(part.input),
4156
4181
  ...isAsync != null && { async: isAsync },
4157
4182
  id
4158
4183
  });
@@ -4278,7 +4303,7 @@ async function convertToOpenAIResponsesInput({
4278
4303
  } else if (reasoningMessage !== void 0) {
4279
4304
  warnings.push({
4280
4305
  type: "other",
4281
- message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
4306
+ message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${stringifyWithBigIntAndCycles2(part)}.`
4282
4307
  });
4283
4308
  }
4284
4309
  if (reasoningMessage === void 0) {
@@ -4314,7 +4339,7 @@ async function convertToOpenAIResponsesInput({
4314
4339
  } else {
4315
4340
  warnings.push({
4316
4341
  type: "other",
4317
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
4342
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${stringifyWithBigIntAndCycles2(part)}.`
4318
4343
  });
4319
4344
  }
4320
4345
  }
@@ -4380,7 +4405,7 @@ async function convertToOpenAIResponsesInput({
4380
4405
  })
4381
4406
  );
4382
4407
  const serializedToolOutputs = toolOutputs.map(
4383
- ({ output: output2 }) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
4408
+ ({ output: output2 }) => typeof output2 === "string" ? output2 : stringifyWithBigIntAndCycles2(output2)
4384
4409
  );
4385
4410
  const hasPromptCacheBreakpoint = toolOutputs.some(
4386
4411
  ({ promptCacheBreakpoint }) => promptCacheBreakpoint != null
@@ -4496,7 +4521,9 @@ ${text}`,
4496
4521
  break;
4497
4522
  case "json":
4498
4523
  case "error-json":
4499
- outputValue = convertScalarOutput(JSON.stringify(output.value));
4524
+ outputValue = convertScalarOutput(
4525
+ stringifyWithBigIntAndCycles2(output.value)
4526
+ );
4500
4527
  break;
4501
4528
  case "content":
4502
4529
  outputValue = output.value.map((item) => {
@@ -8286,6 +8313,16 @@ var openAITranscriptionModelOptions = lazySchema26(
8286
8313
  * The language of the input audio in ISO-639-1 format.
8287
8314
  */
8288
8315
  language: z26.string().optional(),
8316
+ /**
8317
+ * Expected languages for REST transcription, e.g. with gpt-transcribe.
8318
+ * Use this instead of language. The API validates model support.
8319
+ */
8320
+ languages: z26.array(z26.string()).optional(),
8321
+ /**
8322
+ * Vocabulary hints for REST transcription, e.g. names or technical terms.
8323
+ * The API validates model support.
8324
+ */
8325
+ keywords: z26.array(z26.string()).optional(),
8289
8326
  /**
8290
8327
  * An optional text to guide the model's style or continue a previous audio segment.
8291
8328
  */
@@ -8397,6 +8434,8 @@ var OpenAITranscriptionModel = class {
8397
8434
  const transcriptionModelOptions = {
8398
8435
  include: openAIOptions.include,
8399
8436
  language: openAIOptions.language,
8437
+ languages: openAIOptions.languages,
8438
+ keywords: openAIOptions.keywords,
8400
8439
  prompt: openAIOptions.prompt,
8401
8440
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
8402
8441
  // prefer verbose_json to get segments for models that support it
@@ -8473,7 +8512,7 @@ var OpenAITranscriptionModel = class {
8473
8512
  };
8474
8513
 
8475
8514
  // src/version.ts
8476
- var VERSION = true ? "3.0.134" : "0.0.0-test";
8515
+ var VERSION = true ? "3.0.136" : "0.0.0-test";
8477
8516
 
8478
8517
  // src/openai-provider.ts
8479
8518
  function createOpenAI(options = {}) {