@pydantic/genai-prices 0.0.49 → 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
@@ -1,4 +1,4 @@
1
- const x = [
1
+ const B = [
2
2
  {
3
3
  id: "anthropic",
4
4
  name: "Anthropic",
@@ -1404,6 +1404,7 @@ const x = [
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 x = [
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"
3064
2608
  },
3065
2609
  {
3066
- equals: "gemini-2.0-flash-lite-001"
2610
+ contains: "gemini-2.0-flash-0"
3067
2611
  },
3068
2612
  {
3069
- equals: "gemini-2.0-flash-001"
2613
+ contains: "gemini-2.0-flash-exp"
3070
2614
  },
3071
2615
  {
3072
- equals: "gemini-2.0-flash-exp:free"
2616
+ contains: "gemini-2.0-flash-thinking"
2617
+ },
2618
+ {
2619
+ contains: "gemini-2.0-flash-latest"
3073
2620
  }
3074
2621
  ]
3075
2622
  },
@@ -3238,6 +2785,51 @@ Compared to other leading proprietary and open-weights models Command A delivers
3238
2785
  }
3239
2786
  }
3240
2787
  },
2788
+ {
2789
+ id: "gemini-3-flash-preview",
2790
+ name: "Gemini 3 Flash Preview",
2791
+ description: "Google's ultra-fast frontier model optimized for speed and efficiency. Delivers state-of-the-art performance while maintaining low latency and cost, with improved reasoning and coding capabilities.",
2792
+ match: {
2793
+ or: [
2794
+ {
2795
+ equals: "gemini-3-flash-preview"
2796
+ },
2797
+ {
2798
+ starts_with: "gemini-3-flash-preview-"
2799
+ }
2800
+ ]
2801
+ },
2802
+ context_window: 1e6,
2803
+ price_comments: "See https://ai.google.dev/gemini-api/docs/pricing. Standard pricing shown; Batch API offers 50% discount on input/output.",
2804
+ prices: {
2805
+ input_mtok: 0.5,
2806
+ cache_read_mtok: 0.05,
2807
+ output_mtok: 3,
2808
+ input_audio_mtok: 1,
2809
+ cache_audio_read_mtok: 0.1
2810
+ }
2811
+ },
2812
+ {
2813
+ id: "gemini-3-pro-image-preview",
2814
+ name: "Gemini 3 Pro Image Preview",
2815
+ description: "Google's image generation model optimized for high-quality image generation. Supports 1K/2K and 4K resolution outputs with flexible pricing based on image dimensions.",
2816
+ match: {
2817
+ or: [
2818
+ {
2819
+ starts_with: "gemini-3-pro-image-preview"
2820
+ },
2821
+ {
2822
+ equals: "gemini-3-pro-image-preview"
2823
+ }
2824
+ ]
2825
+ },
2826
+ context_window: 1e6,
2827
+ price_comments: "See https://ai.google.dev/gemini-api/docs/pricing#gemini-3-pro-image. Image output is priced at $120 per 1M tokens, with each 1K/2K image = 1120 tokens = $0.134/image and each 4K image = 2000 tokens = $0.24/image.",
2828
+ prices: {
2829
+ input_mtok: 2,
2830
+ output_mtok: 120
2831
+ }
2832
+ },
3241
2833
  {
3242
2834
  id: "gemini-3-pro-preview",
3243
2835
  name: "Gemini 3 Pro Preview",
@@ -3248,7 +2840,7 @@ Compared to other leading proprietary and open-weights models Command A delivers
3248
2840
  starts_with: "gemini-3-pro-preview"
3249
2841
  },
3250
2842
  {
3251
- starts_with: "gemini-3-pro-image-preview"
2843
+ equals: "gemini-3-pro-text-preview"
3252
2844
  }
3253
2845
  ]
3254
2846
  },
@@ -8091,18 +7683,6 @@ Compared to other leading proprietary and open-weights models Command A delivers
8091
7683
  output_mtok: 0.6
8092
7684
  }
8093
7685
  },
8094
- {
8095
- id: "mistral-small",
8096
- name: "Mistral Small",
8097
- 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.",
8098
- match: {
8099
- starts_with: "mistral-small"
8100
- },
8101
- prices: {
8102
- input_mtok: 0.2,
8103
- output_mtok: 0.6
8104
- }
8105
- },
8106
7686
  {
8107
7687
  id: "mistral-small-24b-instruct-2501",
8108
7688
  name: "Mistral Small 3",
@@ -9500,9 +9080,6 @@ Compared to other leading proprietary and open-weights models Command A delivers
9500
9080
  {
9501
9081
  equals: "gpt-5.2-pro-2025-12-11"
9502
9082
  },
9503
- {
9504
- equals: "gpt-5-2"
9505
- },
9506
9083
  {
9507
9084
  equals: "gpt-5-2-pro-2025-12-11"
9508
9085
  }
@@ -10219,6 +9796,96 @@ Compared to other leading proprietary and open-weights models Command A delivers
10219
9796
  output_mtok: 15
10220
9797
  }
10221
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
+ },
10222
9889
  {
10223
9890
  id: "anubis-pro-105b-v1",
10224
9891
  name: "Anubis Pro 105B V1",
@@ -17537,49 +17204,114 @@ Compared to other leading proprietary and open-weights models Command A delivers
17537
17204
  cache_read_mtok: 0.75,
17538
17205
  output_mtok: 15
17539
17206
  }
17207
+ },
17208
+ {
17209
+ id: "grok-4-1-fast-non-reasoning",
17210
+ name: "Grok 4.1 Fast Non-Reasoning",
17211
+ description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
17212
+ match: {
17213
+ or: [
17214
+ {
17215
+ equals: "grok-4-1-fast-non-reasoning"
17216
+ },
17217
+ {
17218
+ equals: "grok-4-1-fast-non-reasoning-latest"
17219
+ }
17220
+ ]
17221
+ },
17222
+ context_window: 2e6,
17223
+ prices: {
17224
+ input_mtok: 0.2,
17225
+ cache_read_mtok: 0.05,
17226
+ output_mtok: 0.5
17227
+ }
17228
+ },
17229
+ {
17230
+ id: "grok-4-1-fast-reasoning",
17231
+ name: "Grok 4.1 Fast Reasoning",
17232
+ description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
17233
+ match: {
17234
+ or: [
17235
+ {
17236
+ equals: "grok-4-1-fast"
17237
+ },
17238
+ {
17239
+ equals: "grok-4-1-fast-reasoning"
17240
+ },
17241
+ {
17242
+ equals: "grok-4-1-fast-reasoning-latest"
17243
+ }
17244
+ ]
17245
+ },
17246
+ context_window: 2e6,
17247
+ prices: {
17248
+ input_mtok: 0.2,
17249
+ cache_read_mtok: 0.05,
17250
+ output_mtok: 0.5
17251
+ }
17252
+ },
17253
+ {
17254
+ id: "grok-code-fast-1",
17255
+ name: "Grok Code Fast 1",
17256
+ description: "A speedy and economical reasoning model that excels at agentic coding.",
17257
+ match: {
17258
+ or: [
17259
+ {
17260
+ equals: "grok-code-fast"
17261
+ },
17262
+ {
17263
+ equals: "grok-code-fast-1"
17264
+ },
17265
+ {
17266
+ equals: "grok-code-fast-1-0825"
17267
+ }
17268
+ ]
17269
+ },
17270
+ context_window: 256e3,
17271
+ prices: {
17272
+ input_mtok: 0.2,
17273
+ cache_read_mtok: 0.02,
17274
+ output_mtok: 1.5
17275
+ }
17540
17276
  }
17541
17277
  ]
17542
17278
  }
17543
17279
  ];
17544
- function M(t, e) {
17280
+ function L(t, e, a) {
17545
17281
  if (e <= 0) return 0;
17546
- let a = 0;
17547
- const i = [...t.tiers].sort((m, n) => m.start - n.start), o = i[0]?.start ?? e, r = Math.min(e, o);
17548
- a += r * t.base / 1e6;
17549
- for (let m = 0; m < i.length; m++) {
17550
- const n = i[m], s = i[m + 1]?.start ?? 1 / 0, u = Math.max(0, Math.min(e, s) - n.start);
17551
- u > 0 && (a += u * n.price / 1e6);
17552
- }
17553
- return a;
17282
+ let i = t.base;
17283
+ for (const o of t.tiers)
17284
+ a > o.start && (i = o.price);
17285
+ return i * e / 1e6;
17554
17286
  }
17555
- function c(t, e, a) {
17556
- return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : M(t, e);
17287
+ function c(t, e, a, i) {
17288
+ return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e, i);
17557
17289
  }
17558
- function L(t, e) {
17290
+ function Q(t, e) {
17559
17291
  let a = 0, i = 0;
17560
- const o = t.cache_read_tokens ?? 0, r = t.cache_write_tokens ?? 0, m = t.cache_audio_read_tokens ?? 0, n = t.output_audio_tokens ?? 0;
17561
- let s = t.input_audio_tokens ?? 0;
17562
- if (s -= m, s < 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)
17563
17295
  throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
17564
- let u = t.input_tokens ?? 0;
17565
- if (u -= o, u -= r, u -= s, u < 0)
17296
+ let p = t.input_tokens ?? 0;
17297
+ if (p -= s, p -= m, p -= u, p < 0)
17566
17298
  throw new Error("Uncached text input tokens cannot be negative");
17567
- let p = o;
17568
- if (p -= m, p < 0)
17569
- throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
17570
- a += c(e.input_mtok, u), a += c(e.cache_read_mtok, p), a += c(e.cache_write_mtok, r), a += c(e.input_audio_mtok, s), a += c(e.cache_audio_read_mtok, m);
17571
- let k = t.output_tokens ?? 0;
17299
+ let k = s;
17572
17300
  if (k -= n, k < 0)
17301
+ throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
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);
17303
+ let q = t.output_tokens ?? 0;
17304
+ if (q -= r, q < 0)
17573
17305
  throw new Error("output_audio_tokens cannot be greater than output_tokens");
17574
- i += c(e.output_mtok, k), i += c(e.output_audio_mtok, t.output_audio_tokens);
17575
- let f = a + i;
17576
- return e.requests_kcount !== void 0 && (f += e.requests_kcount / 1e3), {
17306
+ i += c(e.output_mtok, q, "output_mtok", o), i += c(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
17307
+ let v = a + i;
17308
+ return e.requests_kcount !== void 0 && (v += e.requests_kcount / 1e3), {
17577
17309
  input_price: a,
17578
17310
  output_price: i,
17579
- total_price: f
17311
+ total_price: v
17580
17312
  };
17581
17313
  }
17582
- function y(t, e) {
17314
+ function T(t, e) {
17583
17315
  if (!Array.isArray(t.prices))
17584
17316
  return t.prices;
17585
17317
  for (let a = t.prices.length - 1; a >= 0; a--) {
@@ -17590,11 +17322,11 @@ function y(t, e) {
17590
17322
  if (e >= new Date(o.start_date))
17591
17323
  return i.prices;
17592
17324
  } else {
17593
- const r = e.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
17325
+ const s = e.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
17594
17326
  if (n < m) {
17595
- if (r >= m || r < n)
17327
+ if (s >= m || s < n)
17596
17328
  return i.prices;
17597
- } else if (r >= m && r < n)
17329
+ } else if (s >= m && s < n)
17598
17330
  return i.prices;
17599
17331
  }
17600
17332
  }
@@ -17603,157 +17335,177 @@ function y(t, e) {
17603
17335
  function _(t, e) {
17604
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;
17605
17337
  }
17606
- function Q(t, e) {
17338
+ function P(t, e) {
17607
17339
  const a = e.toLowerCase().trim(), i = t.find((o) => o.id === a);
17608
17340
  return i || t.find((o) => o.provider_match && _(o.provider_match, a));
17609
17341
  }
17610
- function B(t, { modelId: e, providerApiUrl: a, providerId: i }) {
17342
+ function I(t, { modelId: e, providerApiUrl: a, providerId: i }) {
17611
17343
  if (i)
17612
- return Q(t, i);
17344
+ return P(t, i);
17613
17345
  if (a)
17614
17346
  return t.find((o) => new RegExp(o.api_pattern).test(a));
17615
17347
  if (e)
17616
17348
  return t.find((o) => o.model_match && _(o.model_match, e));
17617
17349
  }
17618
- function T(t, e) {
17350
+ function S(t, e) {
17619
17351
  return t.find((a) => _(a.match, e));
17620
17352
  }
17621
- const P = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
17622
- let g = x, w = Promise.resolve(x), b = null;
17623
- function S(t) {
17624
- t !== null && ("then" in t ? (w = t, t.then((e) => {
17625
- e !== null && (g = e);
17626
- })) : (w = 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
+ }
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;
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));
17627
17371
  }
17628
- function A(t) {
17629
- b = t;
17372
+ function R(t) {
17373
+ f = t;
17630
17374
  }
17631
- function C(t) {
17375
+ function N(t) {
17632
17376
  t({
17633
- onCalc: A,
17634
- remoteDataUrl: P,
17635
- setProviderData: S
17377
+ onCalc: R,
17378
+ remoteDataUrl: A,
17379
+ setProviderData: G
17636
17380
  });
17637
17381
  }
17638
- function z() {
17639
- return w;
17382
+ function V() {
17383
+ return b;
17640
17384
  }
17641
- function N(t, e, a) {
17642
- b?.();
17643
- const i = e.toLowerCase().trim(), o = a?.provider ?? B(g, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17385
+ function E(t, e, a) {
17386
+ f?.();
17387
+ const i = e.toLowerCase().trim(), o = a?.provider ?? I(h, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17644
17388
  if (!o) return null;
17645
- const r = T(o.models, i);
17646
- if (!r) return null;
17647
- const m = a?.timestamp ?? /* @__PURE__ */ new Date(), n = y(r, m), 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);
17648
17392
  return {
17649
17393
  auto_update_timestamp: void 0,
17650
- model: r,
17394
+ model: s,
17651
17395
  model_price: n,
17652
17396
  provider: o,
17653
- ...s
17397
+ ...r
17654
17398
  };
17655
17399
  }
17656
- function V(t) {
17657
- return b?.(), B(g, t);
17400
+ function O(t) {
17401
+ return f?.(), I(h, t);
17658
17402
  }
17659
- function E(t, e, a) {
17403
+ function F(t, e, a) {
17660
17404
  if (a = a ?? "default", !t.extractors)
17661
17405
  throw new Error("No extraction logic defined for this provider");
17662
- const i = t.extractors.find((s) => s.api_flavor === a);
17406
+ const i = t.extractors.find((r) => r.api_flavor === a);
17663
17407
  if (!i) {
17664
- const s = t.extractors.map((u) => u.api_flavor).join(", ");
17665
- 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}`);
17666
17410
  }
17667
- if (!h.guard(e))
17411
+ if (!g.guard(e))
17668
17412
  throw new Error(`Expected response data to be a mapping object, got ${l(e)}`);
17669
- const o = q(i.model_path, e, R, !1, []), r = I(i.root), m = q(r, e, h, !0, []), n = {};
17670
- for (const s of i.mappings) {
17671
- const u = q(s.path, m, D, s.required, r);
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);
17672
17416
  if (u !== null) {
17673
- const p = n[s.dest] ?? 0;
17674
- n[s.dest] = p + u;
17417
+ const p = n[r.dest] ?? 0;
17418
+ n[r.dest] = p + u;
17675
17419
  }
17676
17420
  }
17677
17421
  if (!Object.keys(n).length)
17678
17422
  throw new Error(`No usage information found at ${JSON.stringify(i.root)}`);
17679
17423
  return { model: o, usage: n };
17680
17424
  }
17681
- function q(t, e, a, i, o) {
17682
- const [r, ...m] = I(t).reverse();
17683
- if (typeof r != "string")
17684
- throw new Error(`Expected last step of path to be a string, got ${l(r)}`);
17425
+ function w(t, e, a, i, o) {
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)}`);
17685
17429
  m.reverse();
17686
17430
  let n = e;
17687
- const s = [];
17431
+ const r = [];
17688
17432
  for (const p of m) {
17689
- if (s.push(p), typeof p == "object")
17433
+ if (r.push(p), typeof p == "object")
17690
17434
  if (Array.isArray(n))
17691
- n = G(p, n);
17435
+ n = D(p, n);
17692
17436
  else {
17693
17437
  if (i)
17694
- 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)}`);
17695
17439
  return null;
17696
17440
  }
17697
- else if (h.guard(n))
17441
+ else if (g.guard(n))
17698
17442
  n = n[p];
17699
17443
  else {
17700
17444
  if (i)
17701
- 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)}`);
17702
17446
  return null;
17703
17447
  }
17704
17448
  if (typeof n > "u")
17705
17449
  if (i) {
17706
17450
  const k = typeof p == "object" ? "Unable to find item" : "Missing value";
17707
- throw new Error(`${k} at \`${d(o, s)}\``);
17451
+ throw new Error(`${k} at \`${d(o, r)}\``);
17708
17452
  } else
17709
17453
  return null;
17710
17454
  }
17711
- if (!h.guard(n)) {
17455
+ if (!g.guard(n)) {
17712
17456
  if (i)
17713
- 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)}`);
17714
17458
  return null;
17715
17459
  }
17716
- const u = n[r];
17460
+ const u = n[s];
17717
17461
  if (typeof u > "u") {
17718
17462
  if (i)
17719
- 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)}\``);
17720
17464
  return null;
17721
17465
  }
17722
17466
  if (a.guard(u))
17723
17467
  return u;
17724
17468
  if (i)
17725
- throw s.push(r), new Error(`Expected \`${d(o, s)}\` value to be a ${a.name}, got ${l(u)}`);
17469
+ throw r.push(s), new Error(`Expected \`${d(o, r)}\` value to be a ${a.name}, got ${l(u)}`);
17726
17470
  return null;
17727
17471
  }
17728
- function G(t, e) {
17472
+ function D(t, e) {
17729
17473
  for (const a of e)
17730
- if (h.guard(a)) {
17474
+ if (g.guard(a)) {
17731
17475
  const i = a[t.field];
17732
17476
  if (typeof i == "string" && _(t.match, i))
17733
17477
  return a;
17734
17478
  }
17735
17479
  }
17736
- function I(t) {
17480
+ function y(t) {
17737
17481
  return Array.isArray(t) ? [...t] : [t];
17738
17482
  }
17739
17483
  function l(t) {
17740
17484
  return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
17741
17485
  }
17742
- const h = {
17486
+ const g = {
17743
17487
  guard: (t) => l(t) === "mapping",
17744
17488
  name: "mapping"
17745
- }, R = {
17489
+ }, C = {
17746
17490
  guard: (t) => typeof t == "string",
17747
17491
  name: "string"
17748
- }, D = {
17492
+ }, z = {
17749
17493
  guard: (t) => typeof t == "number",
17750
17494
  name: "number"
17751
- }, d = (t, e) => [...t.map(v), ...e.map(v)].join("."), v = (t) => typeof t == "string" ? t : JSON.stringify(t);
17495
+ }, d = (t, e) => [...t.map(x), ...e.map(x)].join("."), x = (t) => typeof t == "string" ? t : JSON.stringify(t);
17496
+ class j {
17497
+ base;
17498
+ tiers;
17499
+ constructor(e) {
17500
+ this.base = e.base, this.tiers = [...e.tiers].sort((a, i) => a.start - i.start);
17501
+ }
17502
+ }
17752
17503
  export {
17753
- P as REMOTE_DATA_JSON_URL,
17754
- N as calcPrice,
17755
- E as extractUsage,
17756
- V as findProvider,
17757
- C as updatePrices,
17758
- z 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
17759
17511
  };