@pydantic/genai-prices 0.0.50 → 0.0.52

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
@@ -1,4 +1,4 @@
1
- const B = [
1
+ const I = [
2
2
  {
3
3
  id: "anthropic",
4
4
  name: "Anthropic",
@@ -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",
@@ -9524,6 +9059,12 @@ Compared to other leading proprietary and open-weights models Command A delivers
9524
9059
  },
9525
9060
  {
9526
9061
  equals: "gpt-5-2-chat-latest"
9062
+ },
9063
+ {
9064
+ equals: "gpt-5.2-codex"
9065
+ },
9066
+ {
9067
+ equals: "gpt-5-2-codex"
9527
9068
  }
9528
9069
  ]
9529
9070
  },
@@ -9545,9 +9086,6 @@ Compared to other leading proprietary and open-weights models Command A delivers
9545
9086
  {
9546
9087
  equals: "gpt-5.2-pro-2025-12-11"
9547
9088
  },
9548
- {
9549
- equals: "gpt-5-2"
9550
- },
9551
9089
  {
9552
9090
  equals: "gpt-5-2-pro-2025-12-11"
9553
9091
  }
@@ -10264,6 +9802,96 @@ Compared to other leading proprietary and open-weights models Command A delivers
10264
9802
  output_mtok: 15
10265
9803
  }
10266
9804
  },
9805
+ {
9806
+ id: "anthropic/claude-haiku-4.5",
9807
+ match: {
9808
+ or: [
9809
+ {
9810
+ equals: "anthropic/claude-haiku-4.5"
9811
+ },
9812
+ {
9813
+ equals: "anthropic/claude-haiku-4.5:beta"
9814
+ }
9815
+ ]
9816
+ },
9817
+ prices: {
9818
+ input_mtok: 1,
9819
+ cache_write_mtok: 1.25,
9820
+ cache_read_mtok: 0.1,
9821
+ output_mtok: 5
9822
+ }
9823
+ },
9824
+ {
9825
+ id: "anthropic/claude-opus-4.5",
9826
+ match: {
9827
+ or: [
9828
+ {
9829
+ equals: "anthropic/claude-opus-4.5"
9830
+ },
9831
+ {
9832
+ equals: "anthropic/claude-opus-4.5:beta"
9833
+ }
9834
+ ]
9835
+ },
9836
+ prices: {
9837
+ input_mtok: 5,
9838
+ cache_write_mtok: 6.25,
9839
+ cache_read_mtok: 0.5,
9840
+ output_mtok: 25
9841
+ }
9842
+ },
9843
+ {
9844
+ id: "anthropic/claude-sonnet-4.5",
9845
+ match: {
9846
+ or: [
9847
+ {
9848
+ equals: "anthropic/claude-sonnet-4.5"
9849
+ },
9850
+ {
9851
+ equals: "anthropic/claude-sonnet-4.5:beta"
9852
+ }
9853
+ ]
9854
+ },
9855
+ context_window: 1e6,
9856
+ prices: {
9857
+ input_mtok: {
9858
+ base: 3,
9859
+ tiers: [
9860
+ {
9861
+ start: 2e5,
9862
+ price: 6
9863
+ }
9864
+ ]
9865
+ },
9866
+ cache_write_mtok: {
9867
+ base: 3.75,
9868
+ tiers: [
9869
+ {
9870
+ start: 2e5,
9871
+ price: 7.5
9872
+ }
9873
+ ]
9874
+ },
9875
+ cache_read_mtok: {
9876
+ base: 0.3,
9877
+ tiers: [
9878
+ {
9879
+ start: 2e5,
9880
+ price: 0.6
9881
+ }
9882
+ ]
9883
+ },
9884
+ output_mtok: {
9885
+ base: 15,
9886
+ tiers: [
9887
+ {
9888
+ start: 2e5,
9889
+ price: 22.5
9890
+ }
9891
+ ]
9892
+ }
9893
+ }
9894
+ },
10267
9895
  {
10268
9896
  id: "anubis-pro-105b-v1",
10269
9897
  name: "Anubis Pro 105B V1",
@@ -13915,6 +13543,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
13915
13543
  output_mtok: 1.2
13916
13544
  }
13917
13545
  },
13546
+ {
13547
+ id: "moonshotai/kimi-k2.5",
13548
+ name: "Kimi K2.5",
13549
+ match: {
13550
+ equals: "moonshotai/kimi-k2.5"
13551
+ },
13552
+ prices: {
13553
+ input_mtok: 0.6,
13554
+ output_mtok: 3
13555
+ }
13556
+ },
13918
13557
  {
13919
13558
  id: "moonshotai/kimi-vl-a3b-thinking:free",
13920
13559
  match: {
@@ -15341,6 +14980,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
15341
14980
  },
15342
14981
  prices: {}
15343
14982
  },
14983
+ {
14984
+ id: "qwen/qwen3-max-thinking",
14985
+ name: "Qwen 3 Max Thinking",
14986
+ match: {
14987
+ equals: "qwen/qwen3-max-thinking"
14988
+ },
14989
+ prices: {
14990
+ input_mtok: 1.2,
14991
+ output_mtok: 6
14992
+ }
14993
+ },
15344
14994
  {
15345
14995
  id: "qwen/qwq-32b",
15346
14996
  match: {
@@ -17628,6 +17278,51 @@ Compared to other leading proprietary and open-weights models Command A delivers
17628
17278
  output_mtok: 0.5
17629
17279
  }
17630
17280
  },
17281
+ {
17282
+ id: "grok-4-fast-non-reasoning",
17283
+ name: "Grok 4 Fast Non-Reasoning",
17284
+ description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
17285
+ match: {
17286
+ or: [
17287
+ {
17288
+ equals: "grok-4-fast-non-reasoning"
17289
+ },
17290
+ {
17291
+ equals: "grok-4-fast-non-reasoning-latest"
17292
+ }
17293
+ ]
17294
+ },
17295
+ context_window: 2e6,
17296
+ prices: {
17297
+ input_mtok: 0.2,
17298
+ cache_read_mtok: 0.05,
17299
+ output_mtok: 0.5
17300
+ }
17301
+ },
17302
+ {
17303
+ id: "grok-4-fast-reasoning",
17304
+ name: "Grok 4 Fast Reasoning",
17305
+ description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
17306
+ match: {
17307
+ or: [
17308
+ {
17309
+ equals: "grok-4-fast"
17310
+ },
17311
+ {
17312
+ equals: "grok-4-fast-reasoning"
17313
+ },
17314
+ {
17315
+ equals: "grok-4-fast-reasoning-latest"
17316
+ }
17317
+ ]
17318
+ },
17319
+ context_window: 2e6,
17320
+ prices: {
17321
+ input_mtok: 0.2,
17322
+ cache_read_mtok: 0.05,
17323
+ output_mtok: 0.5
17324
+ }
17325
+ },
17631
17326
  {
17632
17327
  id: "grok-code-fast-1",
17633
17328
  name: "Grok Code Fast 1",
@@ -17655,223 +17350,243 @@ Compared to other leading proprietary and open-weights models Command A delivers
17655
17350
  ]
17656
17351
  }
17657
17352
  ];
17658
- function y(t, e, a) {
17353
+ function L(t, e, i) {
17659
17354
  if (e <= 0) return 0;
17660
- let i = t.base;
17355
+ let a = t.base;
17661
17356
  for (const o of t.tiers)
17662
- a > o.start && (i = o.price);
17663
- return i * e / 1e6;
17357
+ i > o.start && (a = o.price);
17358
+ return a * e / 1e6;
17664
17359
  }
17665
- 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);
17360
+ function l(t, e, i, a) {
17361
+ return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e, a);
17667
17362
  }
17668
- function L(t, e) {
17669
- 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)
17363
+ function Q(t, e) {
17364
+ let i = 0, a = 0;
17365
+ 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;
17366
+ let u = t.input_audio_tokens ?? 0;
17367
+ if (u -= n, u < 0)
17673
17368
  throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
17674
17369
  let p = t.input_tokens ?? 0;
17675
- if (p -= r, p -= u, p -= m, p < 0)
17370
+ if (p -= s, p -= m, p -= u, p < 0)
17676
17371
  throw new Error("Uncached text input tokens cannot be negative");
17677
- let k = r;
17678
- if (k -= n, k < 0)
17372
+ let c = s;
17373
+ if (c -= n, c < 0)
17679
17374
  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);
17681
- let q = t.output_tokens ?? 0;
17682
- if (q -= s, q < 0)
17375
+ i += l(e.input_mtok, p, "input_mtok", o), i += l(e.cache_read_mtok, c, "cache_read_mtok", o), i += l(e.cache_write_mtok, m, "cache_write_mtok", o), i += l(e.input_audio_mtok, u, "input_audio_mtok", o), i += l(e.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
17376
+ let _ = t.output_tokens ?? 0;
17377
+ if (_ -= r, _ < 0)
17683
17378
  throw new Error("output_audio_tokens cannot be greater than output_tokens");
17684
- i += c(e.output_mtok, q, "output_mtok", o), i += c(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
17685
- let v = a + i;
17686
- return e.requests_kcount !== void 0 && (v += e.requests_kcount / 1e3), {
17687
- input_price: a,
17688
- output_price: i,
17689
- total_price: v
17379
+ a += l(e.output_mtok, _, "output_mtok", o), a += l(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
17380
+ let x = i + a;
17381
+ return e.requests_kcount !== void 0 && (x += e.requests_kcount / 1e3), {
17382
+ input_price: i,
17383
+ output_price: a,
17384
+ total_price: x
17690
17385
  };
17691
17386
  }
17692
- function Q(t, e) {
17387
+ function T(t, e) {
17693
17388
  if (!Array.isArray(t.prices))
17694
17389
  return t.prices;
17695
- for (let a = t.prices.length - 1; a >= 0; a--) {
17696
- const i = t.prices[a], o = i.constraint;
17390
+ for (let i = t.prices.length - 1; i >= 0; i--) {
17391
+ const a = t.prices[i], o = a.constraint;
17697
17392
  if (o === void 0)
17698
- return i.prices;
17393
+ return a.prices;
17699
17394
  if (o.type === "start_date") {
17700
17395
  if (e >= new Date(o.start_date))
17701
- return i.prices;
17396
+ return a.prices;
17702
17397
  } 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)
17706
- return i.prices;
17707
- } else if (r >= u && r < n)
17708
- return i.prices;
17398
+ const s = e.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
17399
+ if (n < m) {
17400
+ if (s >= m || s < n)
17401
+ return a.prices;
17402
+ } else if (s >= m && s < n)
17403
+ return a.prices;
17709
17404
  }
17710
17405
  }
17711
17406
  return t.prices[0].prices;
17712
17407
  }
17713
- function _(t, e) {
17714
- 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;
17408
+ function g(t, e) {
17409
+ return "or" in t ? t.or.some((i) => g(i, e)) : "and" in t ? t.and.every((i) => g(i, 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
17410
  }
17716
- function T(t, e) {
17717
- const a = e.toLowerCase().trim(), i = t.find((o) => o.id === a);
17718
- return i || t.find((o) => o.provider_match && _(o.provider_match, a));
17411
+ function P(t, e) {
17412
+ const i = e.toLowerCase().trim(), a = t.find((o) => o.id === i);
17413
+ return a || t.find((o) => o.provider_match && g(o.provider_match, i));
17719
17414
  }
17720
- function I(t, { modelId: e, providerApiUrl: a, providerId: i }) {
17415
+ function b(t, { modelId: e, providerApiUrl: i, providerId: a }) {
17416
+ if (a) {
17417
+ const o = P(t, a);
17418
+ if (o || a.toLowerCase() !== "litellm")
17419
+ return o;
17420
+ }
17721
17421
  if (i)
17722
- return T(t, i);
17723
- if (a)
17724
- return t.find((o) => new RegExp(o.api_pattern).test(a));
17422
+ return t.find((o) => new RegExp(o.api_pattern).test(i));
17725
17423
  if (e)
17726
- return t.find((o) => o.model_match && _(o.model_match, e));
17424
+ return t.find((o) => o.model_match && g(o.model_match, e));
17727
17425
  }
17728
- function P(t, e) {
17729
- return t.find((a) => _(a.match, e));
17426
+ function S(t, e) {
17427
+ return t.find((i) => g(i.match, e));
17730
17428
  }
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));
17429
+ function M(t, e, i) {
17430
+ const a = S(t.models, e);
17431
+ if (a) return a;
17432
+ if (t.fallback_model_providers && i)
17433
+ for (const o of t.fallback_model_providers) {
17434
+ const s = i.find((m) => m.id === o);
17435
+ if (s) {
17436
+ const m = M(s, e);
17437
+ if (m) return m;
17438
+ }
17439
+ }
17737
17440
  }
17441
+ const A = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
17442
+ let h = I, f = Promise.resolve(I), v = null;
17738
17443
  function G(t) {
17739
- f = t;
17444
+ t !== null && ("then" in t ? (f = t, t.then((e) => {
17445
+ e !== null && (h = e);
17446
+ })) : (f = Promise.resolve(t), h = t));
17740
17447
  }
17741
- function C(t) {
17448
+ function R(t) {
17449
+ v = t;
17450
+ }
17451
+ function N(t) {
17742
17452
  t({
17743
- onCalc: G,
17744
- remoteDataUrl: S,
17745
- setProviderData: A
17453
+ onCalc: R,
17454
+ remoteDataUrl: A,
17455
+ setProviderData: G
17746
17456
  });
17747
17457
  }
17748
- function N() {
17749
- return b;
17458
+ function V() {
17459
+ return f;
17750
17460
  }
17751
- function V(t, e, a) {
17752
- f?.();
17753
- const i = e.toLowerCase().trim(), o = a?.provider ?? I(g, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17754
- 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);
17461
+ function E(t, e, i) {
17462
+ v?.();
17463
+ let a = e.toLowerCase().trim(), o = i?.providerId;
17464
+ if (o && o.toLowerCase() === "litellm" && a.includes("/")) {
17465
+ const p = a.indexOf("/"), c = a.slice(0, p), _ = a.slice(p + 1);
17466
+ c && _ && b(h, { providerId: c }) && (o = c, a = _);
17467
+ }
17468
+ const s = i?.provider ?? b(h, { modelId: a, providerApiUrl: i?.providerApiUrl, providerId: o });
17469
+ if (!s) return null;
17470
+ const m = M(s, a, h);
17471
+ if (!m) return null;
17472
+ const n = i?.timestamp ?? /* @__PURE__ */ new Date(), r = T(m, n), u = Q(t, r);
17758
17473
  return {
17759
17474
  auto_update_timestamp: void 0,
17760
- model: r,
17761
- model_price: n,
17762
- provider: o,
17763
- ...s
17475
+ model: m,
17476
+ model_price: r,
17477
+ provider: s,
17478
+ ...u
17764
17479
  };
17765
17480
  }
17766
- function E(t) {
17767
- return f?.(), I(g, t);
17481
+ function O(t) {
17482
+ return v?.(), b(h, t);
17768
17483
  }
17769
- function O(t, e, a) {
17770
- if (a = a ?? "default", !t.extractors)
17484
+ function F(t, e, i) {
17485
+ if (i = i ?? "default", !t.extractors)
17771
17486
  throw new Error("No extraction logic defined for this provider");
17772
- const i = t.extractors.find((s) => s.api_flavor === a);
17773
- if (!i) {
17774
- const s = t.extractors.map((m) => m.api_flavor).join(", ");
17775
- throw new Error(`Unknown apiFlavor '${a}', allowed values: ${s}`);
17487
+ const a = t.extractors.find((r) => r.api_flavor === i);
17488
+ if (!a) {
17489
+ const r = t.extractors.map((u) => u.api_flavor).join(", ");
17490
+ throw new Error(`Unknown apiFlavor '${i}', allowed values: ${r}`);
17776
17491
  }
17777
- if (!h.guard(e))
17778
- 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;
17492
+ if (!q.guard(e))
17493
+ throw new Error(`Expected response data to be a mapping object, got ${d(e)}`);
17494
+ const o = w(a.model_path, e, C, !1, []), s = y(a.root), m = w(s, e, q, !0, []), n = {};
17495
+ for (const r of a.mappings) {
17496
+ const u = w(r.path, m, z, r.required, s);
17497
+ if (u !== null) {
17498
+ const p = n[r.dest] ?? 0;
17499
+ n[r.dest] = p + u;
17785
17500
  }
17786
17501
  }
17787
17502
  if (!Object.keys(n).length)
17788
- throw new Error(`No usage information found at ${JSON.stringify(i.root)}`);
17503
+ throw new Error(`No usage information found at ${JSON.stringify(a.root)}`);
17789
17504
  return { model: o, usage: n };
17790
17505
  }
17791
- 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();
17506
+ function w(t, e, i, a, o) {
17507
+ const [s, ...m] = y(t).reverse();
17508
+ if (typeof s != "string")
17509
+ throw new Error(`Expected last step of path to be a string, got ${d(s)}`);
17510
+ m.reverse();
17796
17511
  let n = e;
17797
- const s = [];
17798
- for (const p of u) {
17799
- if (s.push(p), typeof p == "object")
17512
+ const r = [];
17513
+ for (const p of m) {
17514
+ if (r.push(p), typeof p == "object")
17800
17515
  if (Array.isArray(n))
17801
- n = R(p, n);
17516
+ n = D(p, n);
17802
17517
  else {
17803
- if (i)
17804
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17518
+ if (a)
17519
+ throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
17805
17520
  return null;
17806
17521
  }
17807
- else if (h.guard(n))
17522
+ else if (q.guard(n))
17808
17523
  n = n[p];
17809
17524
  else {
17810
- if (i)
17811
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17525
+ if (a)
17526
+ throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
17812
17527
  return null;
17813
17528
  }
17814
17529
  if (typeof n > "u")
17815
- if (i) {
17816
- const k = typeof p == "object" ? "Unable to find item" : "Missing value";
17817
- throw new Error(`${k} at \`${d(o, s)}\``);
17530
+ if (a) {
17531
+ const c = typeof p == "object" ? "Unable to find item" : "Missing value";
17532
+ throw new Error(`${c} at \`${k(o, r)}\``);
17818
17533
  } else
17819
17534
  return null;
17820
17535
  }
17821
- if (!h.guard(n)) {
17822
- if (i)
17823
- throw new Error(`Expected \`${d(o, s)}\` value to be a mapping, got ${l(n)}`);
17536
+ if (!q.guard(n)) {
17537
+ if (a)
17538
+ throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
17824
17539
  return null;
17825
17540
  }
17826
- const m = n[r];
17827
- if (typeof m > "u") {
17828
- if (i)
17829
- throw s.push(r), new Error(`Missing value at \`${d(o, s)}\``);
17541
+ const u = n[s];
17542
+ if (typeof u > "u") {
17543
+ if (a)
17544
+ throw r.push(s), new Error(`Missing value at \`${k(o, r)}\``);
17830
17545
  return null;
17831
17546
  }
17832
- if (a.guard(m))
17833
- return m;
17834
- if (i)
17835
- throw s.push(r), new Error(`Expected \`${d(o, s)}\` value to be a ${a.name}, got ${l(m)}`);
17547
+ if (i.guard(u))
17548
+ return u;
17549
+ if (a)
17550
+ throw r.push(s), new Error(`Expected \`${k(o, r)}\` value to be a ${i.name}, got ${d(u)}`);
17836
17551
  return null;
17837
17552
  }
17838
- function R(t, e) {
17839
- for (const a of e)
17840
- if (h.guard(a)) {
17841
- const i = a[t.field];
17842
- if (typeof i == "string" && _(t.match, i))
17843
- return a;
17553
+ function D(t, e) {
17554
+ for (const i of e)
17555
+ if (q.guard(i)) {
17556
+ const a = i[t.field];
17557
+ if (typeof a == "string" && g(t.match, a))
17558
+ return i;
17844
17559
  }
17845
17560
  }
17846
- function M(t) {
17561
+ function y(t) {
17847
17562
  return Array.isArray(t) ? [...t] : [t];
17848
17563
  }
17849
- function l(t) {
17564
+ function d(t) {
17850
17565
  return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
17851
17566
  }
17852
- const h = {
17853
- guard: (t) => l(t) === "mapping",
17567
+ const q = {
17568
+ guard: (t) => d(t) === "mapping",
17854
17569
  name: "mapping"
17855
- }, D = {
17570
+ }, C = {
17856
17571
  guard: (t) => typeof t == "string",
17857
17572
  name: "string"
17858
17573
  }, z = {
17859
17574
  guard: (t) => typeof t == "number",
17860
17575
  name: "number"
17861
- }, d = (t, e) => [...t.map(x), ...e.map(x)].join("."), x = (t) => typeof t == "string" ? t : JSON.stringify(t);
17862
- class F {
17576
+ }, k = (t, e) => [...t.map(B), ...e.map(B)].join("."), B = (t) => typeof t == "string" ? t : JSON.stringify(t);
17577
+ class j {
17863
17578
  base;
17864
17579
  tiers;
17865
17580
  constructor(e) {
17866
- this.base = e.base, this.tiers = [...e.tiers].sort((a, i) => a.start - i.start);
17581
+ this.base = e.base, this.tiers = [...e.tiers].sort((i, a) => i.start - a.start);
17867
17582
  }
17868
17583
  }
17869
17584
  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
17585
+ A as REMOTE_DATA_JSON_URL,
17586
+ j as TieredPrices,
17587
+ E as calcPrice,
17588
+ F as extractUsage,
17589
+ O as findProvider,
17590
+ N as updatePrices,
17591
+ V as waitForUpdate
17877
17592
  };