@ai-sdk/openai 2.0.91 → 2.0.92

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
@@ -1771,42 +1771,50 @@ var OpenAIImageModel = class {
1771
1771
  },
1772
1772
  providerMetadata: {
1773
1773
  openai: {
1774
- images: response.data.map((item, index) => {
1775
- var _a2;
1776
- return {
1777
- ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
1778
- ...response.created != null ? { created: response.created } : {},
1779
- ...response.size != null ? { size: response.size } : {},
1780
- ...response.quality != null ? { quality: response.quality } : {},
1781
- ...response.background != null ? { background: response.background } : {},
1782
- ...response.output_format != null ? { outputFormat: response.output_format } : {},
1783
- ...distributeTokenDetails(
1784
- (_a2 = response.usage) == null ? void 0 : _a2.input_tokens_details,
1785
- index,
1786
- response.data.length
1787
- )
1788
- };
1789
- })
1774
+ images: response.data.map((item, index) => ({
1775
+ ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
1776
+ ...response.created != null ? { created: response.created } : {},
1777
+ ...response.size != null ? { size: response.size } : {},
1778
+ ...response.quality != null ? { quality: response.quality } : {},
1779
+ ...response.background != null ? { background: response.background } : {},
1780
+ ...response.output_format != null ? { outputFormat: response.output_format } : {},
1781
+ ...distributeTokenDetails(
1782
+ response.usage,
1783
+ index,
1784
+ response.data.length
1785
+ )
1786
+ }))
1790
1787
  }
1791
1788
  }
1792
1789
  };
1793
1790
  }
1794
1791
  };
1795
- function distributeTokenDetails(details, index, total) {
1796
- if (details == null) {
1792
+ function distributeTokenDetails(usage, index, total) {
1793
+ if (usage == null) {
1797
1794
  return {};
1798
1795
  }
1799
1796
  const result = {};
1800
- if (details.image_tokens != null) {
1797
+ const details = usage.input_tokens_details;
1798
+ if ((details == null ? void 0 : details.image_tokens) != null) {
1801
1799
  const base = Math.floor(details.image_tokens / total);
1802
1800
  const remainder = details.image_tokens - base * (total - 1);
1803
1801
  result.imageTokens = index === total - 1 ? remainder : base;
1804
1802
  }
1805
- if (details.text_tokens != null) {
1803
+ if ((details == null ? void 0 : details.text_tokens) != null) {
1806
1804
  const base = Math.floor(details.text_tokens / total);
1807
1805
  const remainder = details.text_tokens - base * (total - 1);
1808
1806
  result.textTokens = index === total - 1 ? remainder : base;
1809
1807
  }
1808
+ if (usage.input_tokens != null) {
1809
+ const base = Math.floor(usage.input_tokens / total);
1810
+ const remainder = usage.input_tokens - base * (total - 1);
1811
+ result.inputTokens = index === total - 1 ? remainder : base;
1812
+ }
1813
+ if (usage.output_tokens != null) {
1814
+ const base = Math.floor(usage.output_tokens / total);
1815
+ const remainder = usage.output_tokens - base * (total - 1);
1816
+ result.outputTokens = index === total - 1 ? remainder : base;
1817
+ }
1810
1818
  return result;
1811
1819
  }
1812
1820
 
@@ -4681,7 +4689,7 @@ var OpenAITranscriptionModel = class {
4681
4689
  };
4682
4690
 
4683
4691
  // src/version.ts
4684
- var VERSION = true ? "2.0.91" : "0.0.0-test";
4692
+ var VERSION = true ? "2.0.92" : "0.0.0-test";
4685
4693
 
4686
4694
  // src/openai-provider.ts
4687
4695
  function createOpenAI(options = {}) {