@ai-sdk/openai 2.0.128 → 2.0.129

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.
@@ -374,6 +374,9 @@ var openaiChatResponseSchema = lazyValidator(
374
374
  message: z2.object({
375
375
  role: z2.literal("assistant").nullish(),
376
376
  content: z2.string().nullish(),
377
+ audio: z2.object({
378
+ transcript: z2.string().nullish()
379
+ }).nullish(),
377
380
  tool_calls: z2.array(
378
381
  z2.object({
379
382
  id: z2.string().nullish(),
@@ -914,7 +917,7 @@ var OpenAIChatLanguageModel = class {
914
917
  };
915
918
  }
916
919
  async doGenerate(options) {
917
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
920
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
918
921
  const { args: body, warnings } = await this.getArgs(options);
919
922
  const {
920
923
  responseHeaders,
@@ -942,19 +945,19 @@ var OpenAIChatLanguageModel = class {
942
945
  });
943
946
  }
944
947
  const content = [];
945
- const text = choice.message.content;
948
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
946
949
  if (text != null && text.length > 0) {
947
950
  content.push({ type: "text", text });
948
951
  }
949
- for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
952
+ for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
950
953
  content.push({
951
954
  type: "tool-call",
952
- toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
955
+ toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
953
956
  toolName: toolCall.function.name,
954
957
  input: toolCall.function.arguments
955
958
  });
956
959
  }
957
- for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
960
+ for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
958
961
  content.push({
959
962
  type: "source",
960
963
  sourceType: "url",
@@ -963,8 +966,8 @@ var OpenAIChatLanguageModel = class {
963
966
  title: annotation.url_citation.title
964
967
  });
965
968
  }
966
- const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
967
- const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
969
+ const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
970
+ const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
968
971
  const providerMetadata = { openai: {} };
969
972
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
970
973
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -977,18 +980,18 @@ var OpenAIChatLanguageModel = class {
977
980
  cacheWriteTokens: promptTokenDetails.cache_write_tokens
978
981
  };
979
982
  }
980
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
983
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
981
984
  providerMetadata.openai.logprobs = choice.logprobs.content;
982
985
  }
983
986
  return {
984
987
  content,
985
988
  finishReason: mapOpenAIFinishReason(choice.finish_reason),
986
989
  usage: {
987
- inputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.prompt_tokens) != null ? _h : void 0,
988
- outputTokens: (_j = (_i = response.usage) == null ? void 0 : _i.completion_tokens) != null ? _j : void 0,
989
- totalTokens: (_l = (_k = response.usage) == null ? void 0 : _k.total_tokens) != null ? _l : void 0,
990
- reasoningTokens: (_m = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _m : void 0,
991
- cachedInputTokens: (_n = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _n : void 0
990
+ inputTokens: (_i = (_h = response.usage) == null ? void 0 : _h.prompt_tokens) != null ? _i : void 0,
991
+ outputTokens: (_k = (_j = response.usage) == null ? void 0 : _j.completion_tokens) != null ? _k : void 0,
992
+ totalTokens: (_m = (_l = response.usage) == null ? void 0 : _l.total_tokens) != null ? _m : void 0,
993
+ reasoningTokens: (_n = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _n : void 0,
994
+ cachedInputTokens: (_o = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _o : void 0
992
995
  },
993
996
  request: { body },
994
997
  response: {
@@ -4713,7 +4716,7 @@ var OpenAIResponsesLanguageModel = class {
4713
4716
  providerExecuted: true
4714
4717
  });
4715
4718
  } else if (value.item.type === "message") {
4716
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
4719
+ ongoingAnnotations.splice(0);
4717
4720
  activeMessagePhase = (_a2 = value.item.phase) != null ? _a2 : void 0;
4718
4721
  controller.enqueue({
4719
4722
  type: "text-start",