@pydantic/genai-prices 0.0.50 → 0.0.51

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.js CHANGED
@@ -1404,6 +1404,7 @@ const B = [
1404
1404
  ]
1405
1405
  }
1406
1406
  ],
1407
+ fallback_model_providers: ["openai", "anthropic"],
1407
1408
  models: [
1408
1409
  {
1409
1410
  id: "ada",
@@ -1484,464 +1485,6 @@ const B = [
1484
1485
  input_mtok: 2
1485
1486
  }
1486
1487
  },
1487
- {
1488
- id: "gpt-3.5-turbo",
1489
- match: {
1490
- or: [
1491
- {
1492
- equals: "gpt-3.5-turbo"
1493
- },
1494
- {
1495
- equals: "gpt-3.5-turbo-0301"
1496
- },
1497
- {
1498
- equals: "gpt-3.5-turbo-0613"
1499
- },
1500
- {
1501
- equals: "gpt-3.5-turbo-instruct"
1502
- },
1503
- {
1504
- equals: "gpt-3.5-turbo-instruct-0914"
1505
- }
1506
- ]
1507
- },
1508
- prices: {
1509
- input_mtok: 1.5,
1510
- output_mtok: 2
1511
- }
1512
- },
1513
- {
1514
- id: "gpt-3.5-turbo-0125",
1515
- match: {
1516
- equals: "gpt-3.5-turbo-0125"
1517
- },
1518
- prices: {
1519
- input_mtok: 0.5,
1520
- output_mtok: 1.5
1521
- }
1522
- },
1523
- {
1524
- id: "gpt-3.5-turbo-1106",
1525
- match: {
1526
- equals: "gpt-3.5-turbo-1106"
1527
- },
1528
- prices: {
1529
- input_mtok: 1,
1530
- output_mtok: 2
1531
- }
1532
- },
1533
- {
1534
- id: "gpt-3.5-turbo-16k-0613",
1535
- match: {
1536
- equals: "gpt-3.5-turbo-16k-0613"
1537
- },
1538
- prices: {
1539
- input_mtok: 3,
1540
- output_mtok: 4
1541
- }
1542
- },
1543
- {
1544
- id: "gpt-35-16k",
1545
- match: {
1546
- equals: "gpt-35-16k"
1547
- },
1548
- prices: {
1549
- input_mtok: 3,
1550
- output_mtok: 4
1551
- }
1552
- },
1553
- {
1554
- id: "gpt-35-turbo",
1555
- match: {
1556
- or: [
1557
- {
1558
- equals: "gpt-35-turbo"
1559
- },
1560
- {
1561
- equals: "gpt-35-turbo-0613"
1562
- },
1563
- {
1564
- equals: "gpt-35-turbo-1106"
1565
- }
1566
- ]
1567
- },
1568
- prices: {
1569
- input_mtok: 1.5,
1570
- output_mtok: 2
1571
- }
1572
- },
1573
- {
1574
- id: "gpt-35-turbo-16k",
1575
- match: {
1576
- or: [
1577
- {
1578
- equals: "gpt-35-turbo-16k"
1579
- },
1580
- {
1581
- equals: "gpt-35-turbo-16k-0613"
1582
- }
1583
- ]
1584
- },
1585
- prices: {
1586
- input_mtok: 3,
1587
- output_mtok: 4
1588
- }
1589
- },
1590
- {
1591
- id: "gpt-4",
1592
- match: {
1593
- or: [
1594
- {
1595
- equals: "gpt-4"
1596
- },
1597
- {
1598
- equals: "gpt-4-0314"
1599
- },
1600
- {
1601
- equals: "gpt-4-0613"
1602
- }
1603
- ]
1604
- },
1605
- prices: {
1606
- input_mtok: 30,
1607
- output_mtok: 60
1608
- }
1609
- },
1610
- {
1611
- id: "gpt-4-0125-preview",
1612
- match: {
1613
- equals: "gpt-4-0125-preview"
1614
- },
1615
- prices: {
1616
- input_mtok: 10,
1617
- output_mtok: 30
1618
- }
1619
- },
1620
- {
1621
- id: "gpt-4-1106-preview",
1622
- match: {
1623
- equals: "gpt-4-1106-preview"
1624
- },
1625
- prices: {
1626
- input_mtok: 10,
1627
- output_mtok: 30
1628
- }
1629
- },
1630
- {
1631
- id: "gpt-4-1106-vision-preview",
1632
- match: {
1633
- equals: "gpt-4-1106-vision-preview"
1634
- },
1635
- prices: {
1636
- input_mtok: 10,
1637
- output_mtok: 30
1638
- }
1639
- },
1640
- {
1641
- id: "gpt-4-32k",
1642
- match: {
1643
- or: [
1644
- {
1645
- equals: "gpt-4-32k"
1646
- },
1647
- {
1648
- equals: "gpt-4-32k-0314"
1649
- },
1650
- {
1651
- equals: "gpt-4-32k-0613"
1652
- }
1653
- ]
1654
- },
1655
- prices: {
1656
- input_mtok: 60,
1657
- output_mtok: 120
1658
- }
1659
- },
1660
- {
1661
- id: "gpt-4-preview-1106",
1662
- match: {
1663
- equals: "gpt-4-preview-1106"
1664
- },
1665
- prices: {
1666
- input_mtok: 10,
1667
- output_mtok: 30
1668
- }
1669
- },
1670
- {
1671
- id: "gpt-4-turbo",
1672
- match: {
1673
- or: [
1674
- {
1675
- equals: "gpt-4-turbo"
1676
- },
1677
- {
1678
- equals: "gpt-4-turbo-0125-preview"
1679
- },
1680
- {
1681
- equals: "gpt-4-turbo-2024-04-09"
1682
- },
1683
- {
1684
- equals: "gpt-4-turbo-preview"
1685
- }
1686
- ]
1687
- },
1688
- prices: {
1689
- input_mtok: 10,
1690
- output_mtok: 30
1691
- }
1692
- },
1693
- {
1694
- id: "gpt-4-vision",
1695
- match: {
1696
- or: [
1697
- {
1698
- equals: "gpt-4-vision"
1699
- },
1700
- {
1701
- equals: "gpt-4-vision-preview"
1702
- }
1703
- ]
1704
- },
1705
- prices: {
1706
- input_mtok: 10,
1707
- output_mtok: 30
1708
- }
1709
- },
1710
- {
1711
- id: "gpt-4.1",
1712
- match: {
1713
- or: [
1714
- {
1715
- equals: "gpt-4.1"
1716
- },
1717
- {
1718
- equals: "gpt-4.1-2025-04-14"
1719
- }
1720
- ]
1721
- },
1722
- prices: {
1723
- input_mtok: 2,
1724
- cache_read_mtok: 0.5,
1725
- output_mtok: 8
1726
- }
1727
- },
1728
- {
1729
- id: "gpt-4.1-mini",
1730
- match: {
1731
- or: [
1732
- {
1733
- equals: "gpt-4.1-mini"
1734
- },
1735
- {
1736
- equals: "gpt-4.1-mini-2025-04-14"
1737
- }
1738
- ]
1739
- },
1740
- prices: {
1741
- input_mtok: 0.4,
1742
- cache_read_mtok: 0.1,
1743
- output_mtok: 1.6
1744
- }
1745
- },
1746
- {
1747
- id: "gpt-4.1-nano",
1748
- match: {
1749
- or: [
1750
- {
1751
- equals: "gpt-4.1-nano"
1752
- },
1753
- {
1754
- equals: "gpt-4.1-nano-2025-04-14"
1755
- }
1756
- ]
1757
- },
1758
- prices: {
1759
- input_mtok: 0.1,
1760
- cache_read_mtok: 0.03,
1761
- output_mtok: 0.4
1762
- }
1763
- },
1764
- {
1765
- id: "gpt-4o-2024-0513",
1766
- match: {
1767
- or: [
1768
- {
1769
- equals: "gpt-4o-2024-05-13"
1770
- },
1771
- {
1772
- equals: "gpt-4o-2024-0513"
1773
- }
1774
- ]
1775
- },
1776
- prices: {
1777
- input_mtok: 5,
1778
- output_mtok: 15
1779
- }
1780
- },
1781
- {
1782
- id: "gpt-4o-2024-08-06",
1783
- match: {
1784
- equals: "gpt-4o-2024-08-06"
1785
- },
1786
- prices: {
1787
- input_mtok: 2.5,
1788
- cache_read_mtok: 1.25,
1789
- output_mtok: 10
1790
- }
1791
- },
1792
- {
1793
- id: "gpt-4o-2024-1120",
1794
- match: {
1795
- or: [
1796
- {
1797
- equals: "gpt-4o-2024-1120"
1798
- },
1799
- {
1800
- equals: "gpt-4o-2024-11-20"
1801
- }
1802
- ]
1803
- },
1804
- prices: {
1805
- input_mtok: 2.5,
1806
- cache_read_mtok: 1.25,
1807
- output_mtok: 10
1808
- }
1809
- },
1810
- {
1811
- id: "gpt-4o-mini",
1812
- match: {
1813
- or: [
1814
- {
1815
- equals: "gpt-4o-mini"
1816
- },
1817
- {
1818
- equals: "gpt-4o-mini-0718"
1819
- },
1820
- {
1821
- starts_with: "gpt-4o-mini-audio"
1822
- }
1823
- ]
1824
- },
1825
- context_window: 128e3,
1826
- prices: {
1827
- input_mtok: 0.15,
1828
- cache_read_mtok: 0.075,
1829
- output_mtok: 0.6,
1830
- input_audio_mtok: 10,
1831
- output_audio_mtok: 20
1832
- }
1833
- },
1834
- {
1835
- id: "gpt-4o-mini-realtime",
1836
- match: {
1837
- starts_with: "gpt-4o-mini-realtime"
1838
- },
1839
- prices: {
1840
- input_mtok: 0.6,
1841
- cache_read_mtok: 0.3,
1842
- output_mtok: 2.4,
1843
- input_audio_mtok: 10,
1844
- cache_audio_read_mtok: 0.3,
1845
- output_audio_mtok: 20
1846
- }
1847
- },
1848
- {
1849
- id: "gpt-4o-realtime",
1850
- match: {
1851
- starts_with: "gpt-4o-realtime"
1852
- },
1853
- prices: {
1854
- input_mtok: 5,
1855
- cache_read_mtok: 2.5,
1856
- output_mtok: 20,
1857
- input_audio_mtok: 40,
1858
- cache_audio_read_mtok: 2.5,
1859
- output_audio_mtok: 80
1860
- }
1861
- },
1862
- {
1863
- id: "gpt-5",
1864
- name: "GPT-5",
1865
- description: "GPT-5 is OpenAI's flagship model for coding, reasoning, and agentic tasks across domains.",
1866
- match: {
1867
- or: [
1868
- {
1869
- equals: "gpt-5"
1870
- },
1871
- {
1872
- equals: "gpt-5-2025-08-07"
1873
- }
1874
- ]
1875
- },
1876
- context_window: 4e5,
1877
- prices: {
1878
- input_mtok: 1.25,
1879
- cache_read_mtok: 0.125,
1880
- output_mtok: 10
1881
- }
1882
- },
1883
- {
1884
- id: "gpt-5-mini",
1885
- name: "GPT-5 mini",
1886
- description: "GPT-5 mini is a faster, more cost-efficient version of GPT-5. It's great for well-defined tasks and precise prompts.",
1887
- match: {
1888
- or: [
1889
- {
1890
- equals: "gpt-5-mini"
1891
- },
1892
- {
1893
- equals: "gpt-5-mini-2025-08-07"
1894
- }
1895
- ]
1896
- },
1897
- context_window: 4e5,
1898
- prices: {
1899
- input_mtok: 0.25,
1900
- cache_read_mtok: 0.025,
1901
- output_mtok: 2
1902
- }
1903
- },
1904
- {
1905
- id: "gpt-5-nano",
1906
- name: "GPT-5 nano",
1907
- description: "GPT-5 Nano is OpenAI's fastest, cheapest version of GPT-5. It's great for summarization and classification tasks.",
1908
- match: {
1909
- or: [
1910
- {
1911
- equals: "gpt-5-nano"
1912
- },
1913
- {
1914
- equals: "gpt-5-nano-2025-04-14"
1915
- }
1916
- ]
1917
- },
1918
- context_window: 4e5,
1919
- prices: {
1920
- input_mtok: 0.05,
1921
- cache_read_mtok: 5e-3,
1922
- output_mtok: 0.4
1923
- }
1924
- },
1925
- {
1926
- id: "gpt35",
1927
- match: {
1928
- equals: "gpt35"
1929
- },
1930
- prices: {
1931
- input_mtok: 1.5,
1932
- output_mtok: 2
1933
- }
1934
- },
1935
- {
1936
- id: "gpt4-turbo-preview",
1937
- match: {
1938
- equals: "gpt4-turbo-preview"
1939
- },
1940
- prices: {
1941
- input_mtok: 10,
1942
- output_mtok: 30
1943
- }
1944
- },
1945
1488
  {
1946
1489
  id: "mai-ds-r1:free",
1947
1490
  name: "MAI DS R1 (free)",
@@ -2867,6 +2410,7 @@ Compared to other leading proprietary and open-weights models Command A delivers
2867
2410
  ]
2868
2411
  }
2869
2412
  ],
2413
+ fallback_model_providers: ["anthropic"],
2870
2414
  models: [
2871
2415
  {
2872
2416
  id: "claude-3-5-haiku",
@@ -3060,16 +2604,19 @@ Compared to other leading proprietary and open-weights models Command A delivers
3060
2604
  match: {
3061
2605
  or: [
3062
2606
  {
3063
- contains: "gemini-2.0-flash"
2607
+ ends_with: "gemini-2.0-flash"
2608
+ },
2609
+ {
2610
+ contains: "gemini-2.0-flash-0"
3064
2611
  },
3065
2612
  {
3066
- equals: "gemini-2.0-flash-lite-001"
2613
+ contains: "gemini-2.0-flash-exp"
3067
2614
  },
3068
2615
  {
3069
- equals: "gemini-2.0-flash-001"
2616
+ contains: "gemini-2.0-flash-thinking"
3070
2617
  },
3071
2618
  {
3072
- equals: "gemini-2.0-flash-exp:free"
2619
+ contains: "gemini-2.0-flash-latest"
3073
2620
  }
3074
2621
  ]
3075
2622
  },
@@ -8136,18 +7683,6 @@ Compared to other leading proprietary and open-weights models Command A delivers
8136
7683
  output_mtok: 0.6
8137
7684
  }
8138
7685
  },
8139
- {
8140
- id: "mistral-small",
8141
- name: "Mistral Small",
8142
- description: "With 22 billion parameters, Mistral Small v24.09 offers a convenient mid-point between (Mistral NeMo 12B)[/mistralai/mistral-nemo] and (Mistral Large 2)[/mistralai/mistral-large], providing a cost-effective solution that can be deployed across various platforms and environments. It has better reasoning, exhibits more capabilities, can produce and reason about code, and is multiligual, supporting English, French, German, Italian, and Spanish.",
8143
- match: {
8144
- starts_with: "mistral-small"
8145
- },
8146
- prices: {
8147
- input_mtok: 0.2,
8148
- output_mtok: 0.6
8149
- }
8150
- },
8151
7686
  {
8152
7687
  id: "mistral-small-24b-instruct-2501",
8153
7688
  name: "Mistral Small 3",
@@ -9545,9 +9080,6 @@ Compared to other leading proprietary and open-weights models Command A delivers
9545
9080
  {
9546
9081
  equals: "gpt-5.2-pro-2025-12-11"
9547
9082
  },
9548
- {
9549
- equals: "gpt-5-2"
9550
- },
9551
9083
  {
9552
9084
  equals: "gpt-5-2-pro-2025-12-11"
9553
9085
  }
@@ -10264,6 +9796,96 @@ Compared to other leading proprietary and open-weights models Command A delivers
10264
9796
  output_mtok: 15
10265
9797
  }
10266
9798
  },
9799
+ {
9800
+ id: "anthropic/claude-haiku-4.5",
9801
+ match: {
9802
+ or: [
9803
+ {
9804
+ equals: "anthropic/claude-haiku-4.5"
9805
+ },
9806
+ {
9807
+ equals: "anthropic/claude-haiku-4.5:beta"
9808
+ }
9809
+ ]
9810
+ },
9811
+ prices: {
9812
+ input_mtok: 1,
9813
+ cache_write_mtok: 1.25,
9814
+ cache_read_mtok: 0.1,
9815
+ output_mtok: 5
9816
+ }
9817
+ },
9818
+ {
9819
+ id: "anthropic/claude-opus-4.5",
9820
+ match: {
9821
+ or: [
9822
+ {
9823
+ equals: "anthropic/claude-opus-4.5"
9824
+ },
9825
+ {
9826
+ equals: "anthropic/claude-opus-4.5:beta"
9827
+ }
9828
+ ]
9829
+ },
9830
+ prices: {
9831
+ input_mtok: 5,
9832
+ cache_write_mtok: 6.25,
9833
+ cache_read_mtok: 0.5,
9834
+ output_mtok: 25
9835
+ }
9836
+ },
9837
+ {
9838
+ id: "anthropic/claude-sonnet-4.5",
9839
+ match: {
9840
+ or: [
9841
+ {
9842
+ equals: "anthropic/claude-sonnet-4.5"
9843
+ },
9844
+ {
9845
+ equals: "anthropic/claude-sonnet-4.5:beta"
9846
+ }
9847
+ ]
9848
+ },
9849
+ context_window: 1e6,
9850
+ prices: {
9851
+ input_mtok: {
9852
+ base: 3,
9853
+ tiers: [
9854
+ {
9855
+ start: 2e5,
9856
+ price: 6
9857
+ }
9858
+ ]
9859
+ },
9860
+ cache_write_mtok: {
9861
+ base: 3.75,
9862
+ tiers: [
9863
+ {
9864
+ start: 2e5,
9865
+ price: 7.5
9866
+ }
9867
+ ]
9868
+ },
9869
+ cache_read_mtok: {
9870
+ base: 0.3,
9871
+ tiers: [
9872
+ {
9873
+ start: 2e5,
9874
+ price: 0.6
9875
+ }
9876
+ ]
9877
+ },
9878
+ output_mtok: {
9879
+ base: 15,
9880
+ tiers: [
9881
+ {
9882
+ start: 2e5,
9883
+ price: 22.5
9884
+ }
9885
+ ]
9886
+ }
9887
+ }
9888
+ },
10267
9889
  {
10268
9890
  id: "anubis-pro-105b-v1",
10269
9891
  name: "Anubis Pro 105B V1",
@@ -17655,7 +17277,7 @@ Compared to other leading proprietary and open-weights models Command A delivers
17655
17277
  ]
17656
17278
  }
17657
17279
  ];
17658
- function y(t, e, a) {
17280
+ function L(t, e, a) {
17659
17281
  if (e <= 0) return 0;
17660
17282
  let i = t.base;
17661
17283
  for (const o of t.tiers)
@@ -17663,23 +17285,23 @@ function y(t, e, a) {
17663
17285
  return i * e / 1e6;
17664
17286
  }
17665
17287
  function c(t, e, a, i) {
17666
- return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : y(t, e, i);
17288
+ return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e, i);
17667
17289
  }
17668
- function L(t, e) {
17290
+ function Q(t, e) {
17669
17291
  let a = 0, i = 0;
17670
- const o = t.input_tokens ?? 0, r = t.cache_read_tokens ?? 0, u = t.cache_write_tokens ?? 0, n = t.cache_audio_read_tokens ?? 0, s = t.output_audio_tokens ?? 0;
17671
- let m = t.input_audio_tokens ?? 0;
17672
- if (m -= n, m < 0)
17292
+ const o = t.input_tokens ?? 0, s = t.cache_read_tokens ?? 0, m = t.cache_write_tokens ?? 0, n = t.cache_audio_read_tokens ?? 0, r = t.output_audio_tokens ?? 0;
17293
+ let u = t.input_audio_tokens ?? 0;
17294
+ if (u -= n, u < 0)
17673
17295
  throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
17674
17296
  let p = t.input_tokens ?? 0;
17675
- if (p -= r, p -= u, p -= m, p < 0)
17297
+ if (p -= s, p -= m, p -= u, p < 0)
17676
17298
  throw new Error("Uncached text input tokens cannot be negative");
17677
- let k = r;
17299
+ let k = s;
17678
17300
  if (k -= n, k < 0)
17679
17301
  throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
17680
- a += c(e.input_mtok, p, "input_mtok", o), a += c(e.cache_read_mtok, k, "cache_read_mtok", o), a += c(e.cache_write_mtok, u, "cache_write_mtok", o), a += c(e.input_audio_mtok, m, "input_audio_mtok", o), a += c(e.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
17302
+ a += c(e.input_mtok, p, "input_mtok", o), a += c(e.cache_read_mtok, k, "cache_read_mtok", o), a += c(e.cache_write_mtok, m, "cache_write_mtok", o), a += c(e.input_audio_mtok, u, "input_audio_mtok", o), a += c(e.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
17681
17303
  let q = t.output_tokens ?? 0;
17682
- if (q -= s, q < 0)
17304
+ if (q -= r, q < 0)
17683
17305
  throw new Error("output_audio_tokens cannot be greater than output_tokens");
17684
17306
  i += c(e.output_mtok, q, "output_mtok", o), i += c(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
17685
17307
  let v = a + i;
@@ -17689,7 +17311,7 @@ function L(t, e) {
17689
17311
  total_price: v
17690
17312
  };
17691
17313
  }
17692
- function Q(t, e) {
17314
+ function T(t, e) {
17693
17315
  if (!Array.isArray(t.prices))
17694
17316
  return t.prices;
17695
17317
  for (let a = t.prices.length - 1; a >= 0; a--) {
@@ -17700,11 +17322,11 @@ function Q(t, e) {
17700
17322
  if (e >= new Date(o.start_date))
17701
17323
  return i.prices;
17702
17324
  } else {
17703
- const r = e.toISOString().slice(11, 19), u = o.start_time, n = o.end_time;
17704
- if (n < u) {
17705
- if (r >= u || r < n)
17325
+ const s = e.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
17326
+ if (n < m) {
17327
+ if (s >= m || s < n)
17706
17328
  return i.prices;
17707
- } else if (r >= u && r < n)
17329
+ } else if (s >= m && s < n)
17708
17330
  return i.prices;
17709
17331
  }
17710
17332
  }
@@ -17713,75 +17335,87 @@ function Q(t, e) {
17713
17335
  function _(t, e) {
17714
17336
  return "or" in t ? t.or.some((a) => _(a, e)) : "and" in t ? t.and.every((a) => _(a, e)) : "equals" in t ? e === t.equals : "starts_with" in t ? e.startsWith(t.starts_with) : "ends_with" in t ? e.endsWith(t.ends_with) : "contains" in t ? e.includes(t.contains) : "regex" in t ? new RegExp(t.regex).test(e) : !1;
17715
17337
  }
17716
- function T(t, e) {
17338
+ function P(t, e) {
17717
17339
  const a = e.toLowerCase().trim(), i = t.find((o) => o.id === a);
17718
17340
  return i || t.find((o) => o.provider_match && _(o.provider_match, a));
17719
17341
  }
17720
17342
  function I(t, { modelId: e, providerApiUrl: a, providerId: i }) {
17721
17343
  if (i)
17722
- return T(t, i);
17344
+ return P(t, i);
17723
17345
  if (a)
17724
17346
  return t.find((o) => new RegExp(o.api_pattern).test(a));
17725
17347
  if (e)
17726
17348
  return t.find((o) => o.model_match && _(o.model_match, e));
17727
17349
  }
17728
- function P(t, e) {
17350
+ function S(t, e) {
17729
17351
  return t.find((a) => _(a.match, e));
17730
17352
  }
17731
- const S = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
17732
- let g = B, b = Promise.resolve(B), f = null;
17733
- function A(t) {
17734
- t !== null && ("then" in t ? (b = t, t.then((e) => {
17735
- e !== null && (g = e);
17736
- })) : (b = Promise.resolve(t), g = t));
17353
+ function M(t, e, a) {
17354
+ const i = S(t.models, e);
17355
+ if (i) return i;
17356
+ if (t.fallback_model_providers && a)
17357
+ for (const o of t.fallback_model_providers) {
17358
+ const s = a.find((m) => m.id === o);
17359
+ if (s) {
17360
+ const m = M(s, e);
17361
+ if (m) return m;
17362
+ }
17363
+ }
17737
17364
  }
17365
+ const A = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
17366
+ let h = B, b = Promise.resolve(B), f = null;
17738
17367
  function G(t) {
17368
+ t !== null && ("then" in t ? (b = t, t.then((e) => {
17369
+ e !== null && (h = e);
17370
+ })) : (b = Promise.resolve(t), h = t));
17371
+ }
17372
+ function R(t) {
17739
17373
  f = t;
17740
17374
  }
17741
- function C(t) {
17375
+ function N(t) {
17742
17376
  t({
17743
- onCalc: G,
17744
- remoteDataUrl: S,
17745
- setProviderData: A
17377
+ onCalc: R,
17378
+ remoteDataUrl: A,
17379
+ setProviderData: G
17746
17380
  });
17747
17381
  }
17748
- function N() {
17382
+ function V() {
17749
17383
  return b;
17750
17384
  }
17751
- function V(t, e, a) {
17385
+ function E(t, e, a) {
17752
17386
  f?.();
17753
- const i = e.toLowerCase().trim(), o = a?.provider ?? I(g, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17387
+ const i = e.toLowerCase().trim(), o = a?.provider ?? I(h, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17754
17388
  if (!o) return null;
17755
- const r = P(o.models, i);
17756
- if (!r) return null;
17757
- const u = a?.timestamp ?? /* @__PURE__ */ new Date(), n = Q(r, u), s = L(t, n);
17389
+ const s = M(o, i, h);
17390
+ if (!s) return null;
17391
+ const m = a?.timestamp ?? /* @__PURE__ */ new Date(), n = T(s, m), r = Q(t, n);
17758
17392
  return {
17759
17393
  auto_update_timestamp: void 0,
17760
- model: r,
17394
+ model: s,
17761
17395
  model_price: n,
17762
17396
  provider: o,
17763
- ...s
17397
+ ...r
17764
17398
  };
17765
17399
  }
17766
- function E(t) {
17767
- return f?.(), I(g, t);
17400
+ function O(t) {
17401
+ return f?.(), I(h, t);
17768
17402
  }
17769
- function O(t, e, a) {
17403
+ function F(t, e, a) {
17770
17404
  if (a = a ?? "default", !t.extractors)
17771
17405
  throw new Error("No extraction logic defined for this provider");
17772
- const i = t.extractors.find((s) => s.api_flavor === a);
17406
+ const i = t.extractors.find((r) => r.api_flavor === a);
17773
17407
  if (!i) {
17774
- const s = t.extractors.map((m) => m.api_flavor).join(", ");
17775
- throw new Error(`Unknown apiFlavor '${a}', allowed values: ${s}`);
17408
+ const r = t.extractors.map((u) => u.api_flavor).join(", ");
17409
+ throw new Error(`Unknown apiFlavor '${a}', allowed values: ${r}`);
17776
17410
  }
17777
- if (!h.guard(e))
17411
+ if (!g.guard(e))
17778
17412
  throw new Error(`Expected response data to be a mapping object, got ${l(e)}`);
17779
- const o = w(i.model_path, e, D, !1, []), r = M(i.root), u = w(r, e, h, !0, []), n = {};
17780
- for (const s of i.mappings) {
17781
- const m = w(s.path, u, z, s.required, r);
17782
- if (m !== null) {
17783
- const p = n[s.dest] ?? 0;
17784
- n[s.dest] = p + m;
17413
+ const o = w(i.model_path, e, C, !1, []), s = y(i.root), m = w(s, e, g, !0, []), n = {};
17414
+ for (const r of i.mappings) {
17415
+ const u = w(r.path, m, z, r.required, s);
17416
+ if (u !== null) {
17417
+ const p = n[r.dest] ?? 0;
17418
+ n[r.dest] = p + u;
17785
17419
  }
17786
17420
  }
17787
17421
  if (!Object.keys(n).length)
@@ -17789,77 +17423,77 @@ function O(t, e, a) {
17789
17423
  return { model: o, usage: n };
17790
17424
  }
17791
17425
  function w(t, e, a, i, o) {
17792
- const [r, ...u] = M(t).reverse();
17793
- if (typeof r != "string")
17794
- throw new Error(`Expected last step of path to be a string, got ${l(r)}`);
17795
- u.reverse();
17426
+ const [s, ...m] = y(t).reverse();
17427
+ if (typeof s != "string")
17428
+ throw new Error(`Expected last step of path to be a string, got ${l(s)}`);
17429
+ m.reverse();
17796
17430
  let n = e;
17797
- const s = [];
17798
- for (const p of u) {
17799
- if (s.push(p), typeof p == "object")
17431
+ const r = [];
17432
+ for (const p of m) {
17433
+ if (r.push(p), typeof p == "object")
17800
17434
  if (Array.isArray(n))
17801
- n = R(p, n);
17435
+ n = D(p, n);
17802
17436
  else {
17803
17437
  if (i)
17804
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17438
+ throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
17805
17439
  return null;
17806
17440
  }
17807
- else if (h.guard(n))
17441
+ else if (g.guard(n))
17808
17442
  n = n[p];
17809
17443
  else {
17810
17444
  if (i)
17811
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17445
+ throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
17812
17446
  return null;
17813
17447
  }
17814
17448
  if (typeof n > "u")
17815
17449
  if (i) {
17816
17450
  const k = typeof p == "object" ? "Unable to find item" : "Missing value";
17817
- throw new Error(`${k} at \`${d(o, s)}\``);
17451
+ throw new Error(`${k} at \`${d(o, r)}\``);
17818
17452
  } else
17819
17453
  return null;
17820
17454
  }
17821
- if (!h.guard(n)) {
17455
+ if (!g.guard(n)) {
17822
17456
  if (i)
17823
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17457
+ throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
17824
17458
  return null;
17825
17459
  }
17826
- const m = n[r];
17827
- if (typeof m > "u") {
17460
+ const u = n[s];
17461
+ if (typeof u > "u") {
17828
17462
  if (i)
17829
- throw s.push(r), new Error(`Missing value at \`${d(o, s)}\``);
17463
+ throw r.push(s), new Error(`Missing value at \`${d(o, r)}\``);
17830
17464
  return null;
17831
17465
  }
17832
- if (a.guard(m))
17833
- return m;
17466
+ if (a.guard(u))
17467
+ return u;
17834
17468
  if (i)
17835
- throw s.push(r), new Error(`Expected \`${d(o, s)}\` value to be a ${a.name}, got ${l(m)}`);
17469
+ throw r.push(s), new Error(`Expected \`${d(o, r)}\` value to be a ${a.name}, got ${l(u)}`);
17836
17470
  return null;
17837
17471
  }
17838
- function R(t, e) {
17472
+ function D(t, e) {
17839
17473
  for (const a of e)
17840
- if (h.guard(a)) {
17474
+ if (g.guard(a)) {
17841
17475
  const i = a[t.field];
17842
17476
  if (typeof i == "string" && _(t.match, i))
17843
17477
  return a;
17844
17478
  }
17845
17479
  }
17846
- function M(t) {
17480
+ function y(t) {
17847
17481
  return Array.isArray(t) ? [...t] : [t];
17848
17482
  }
17849
17483
  function l(t) {
17850
17484
  return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
17851
17485
  }
17852
- const h = {
17486
+ const g = {
17853
17487
  guard: (t) => l(t) === "mapping",
17854
17488
  name: "mapping"
17855
- }, D = {
17489
+ }, C = {
17856
17490
  guard: (t) => typeof t == "string",
17857
17491
  name: "string"
17858
17492
  }, z = {
17859
17493
  guard: (t) => typeof t == "number",
17860
17494
  name: "number"
17861
17495
  }, d = (t, e) => [...t.map(x), ...e.map(x)].join("."), x = (t) => typeof t == "string" ? t : JSON.stringify(t);
17862
- class F {
17496
+ class j {
17863
17497
  base;
17864
17498
  tiers;
17865
17499
  constructor(e) {
@@ -17867,11 +17501,11 @@ class F {
17867
17501
  }
17868
17502
  }
17869
17503
  export {
17870
- S as REMOTE_DATA_JSON_URL,
17871
- F as TieredPrices,
17872
- V as calcPrice,
17873
- O as extractUsage,
17874
- E as findProvider,
17875
- C as updatePrices,
17876
- N as waitForUpdate
17504
+ A as REMOTE_DATA_JSON_URL,
17505
+ j as TieredPrices,
17506
+ E as calcPrice,
17507
+ F as extractUsage,
17508
+ O as findProvider,
17509
+ N as updatePrices,
17510
+ V as waitForUpdate
17877
17511
  };