@ai-sdk/openai 2.0.90 → 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.
@@ -1763,19 +1763,52 @@ var OpenAIImageModel = class {
1763
1763
  },
1764
1764
  providerMetadata: {
1765
1765
  openai: {
1766
- images: response.data.map((item) => ({
1766
+ images: response.data.map((item, index) => ({
1767
1767
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
1768
1768
  ...response.created != null ? { created: response.created } : {},
1769
1769
  ...response.size != null ? { size: response.size } : {},
1770
1770
  ...response.quality != null ? { quality: response.quality } : {},
1771
1771
  ...response.background != null ? { background: response.background } : {},
1772
- ...response.output_format != null ? { outputFormat: response.output_format } : {}
1772
+ ...response.output_format != null ? { outputFormat: response.output_format } : {},
1773
+ ...distributeTokenDetails(
1774
+ response.usage,
1775
+ index,
1776
+ response.data.length
1777
+ )
1773
1778
  }))
1774
1779
  }
1775
1780
  }
1776
1781
  };
1777
1782
  }
1778
1783
  };
1784
+ function distributeTokenDetails(usage, index, total) {
1785
+ if (usage == null) {
1786
+ return {};
1787
+ }
1788
+ const result = {};
1789
+ const details = usage.input_tokens_details;
1790
+ if ((details == null ? void 0 : details.image_tokens) != null) {
1791
+ const base = Math.floor(details.image_tokens / total);
1792
+ const remainder = details.image_tokens - base * (total - 1);
1793
+ result.imageTokens = index === total - 1 ? remainder : base;
1794
+ }
1795
+ if ((details == null ? void 0 : details.text_tokens) != null) {
1796
+ const base = Math.floor(details.text_tokens / total);
1797
+ const remainder = details.text_tokens - base * (total - 1);
1798
+ result.textTokens = index === total - 1 ? remainder : base;
1799
+ }
1800
+ if (usage.input_tokens != null) {
1801
+ const base = Math.floor(usage.input_tokens / total);
1802
+ const remainder = usage.input_tokens - base * (total - 1);
1803
+ result.inputTokens = index === total - 1 ? remainder : base;
1804
+ }
1805
+ if (usage.output_tokens != null) {
1806
+ const base = Math.floor(usage.output_tokens / total);
1807
+ const remainder = usage.output_tokens - base * (total - 1);
1808
+ result.outputTokens = index === total - 1 ? remainder : base;
1809
+ }
1810
+ return result;
1811
+ }
1779
1812
 
1780
1813
  // src/transcription/openai-transcription-model.ts
1781
1814
  import {