llm-prices 1.2.0__py3-none-any.whl
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.
- llm_prices/__init__.py +59 -0
- llm_prices/_core.py +871 -0
- llm_prices/_data.py +150 -0
- llm_prices/py.typed +0 -0
- llm_prices-1.2.0.dist-info/METADATA +44 -0
- llm_prices-1.2.0.dist-info/RECORD +8 -0
- llm_prices-1.2.0.dist-info/WHEEL +4 -0
- llm_prices-1.2.0.dist-info/licenses/LICENSE +21 -0
llm_prices/__init__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Dated, source-cited LLM API prices, with no dependencies and no network access.
|
|
2
|
+
|
|
3
|
+
The same table as the Rust crate ``llm-prices``, generated from
|
|
4
|
+
`prices.json <https://github.com/Mattbusel/llm-prices/blob/main/prices.json>`_: Anthropic,
|
|
5
|
+
OpenAI, Google Gemini and DeepSeek (re-read from their pricing pages every day) plus Mistral,
|
|
6
|
+
xAI, Cohere, Groq, Together AI and Fireworks AI. Every row carries the provider's official
|
|
7
|
+
pricing page and the date the price was read from it. Prices are USD per 1M tokens.
|
|
8
|
+
|
|
9
|
+
>>> import llm_prices
|
|
10
|
+
>>> p = llm_prices.lookup("claude-sonnet-5-5")
|
|
11
|
+
>>> p.input, p.cache_read
|
|
12
|
+
(2.0, 0.1)
|
|
13
|
+
>>> llm_prices.lookup("gpt-4o-2024-08-06").model
|
|
14
|
+
'gpt-4o'
|
|
15
|
+
>>> llm_prices.lookup_provider("groq", "openai/gpt-oss-120b").provider
|
|
16
|
+
'groq'
|
|
17
|
+
|
|
18
|
+
Price a whole response, prompt-cache reads and writes, batch discounts and the
|
|
19
|
+
long-context switch included, in floats or in exact decimals:
|
|
20
|
+
|
|
21
|
+
>>> from llm_prices import Usage
|
|
22
|
+
>>> usage = Usage(input=2_048, cache_read=45_000, cache_write_5m=3_500, output=1_024)
|
|
23
|
+
>>> llm_prices.lookup("claude-sonnet-4-6").cost_usage(usage, exact=True).total
|
|
24
|
+
Decimal('0.048129')
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from ._core import (
|
|
28
|
+
GENERATED,
|
|
29
|
+
CostBreakdown,
|
|
30
|
+
DecimalCostBreakdown,
|
|
31
|
+
LongContext,
|
|
32
|
+
Price,
|
|
33
|
+
Provider,
|
|
34
|
+
RateName,
|
|
35
|
+
Usage,
|
|
36
|
+
all_prices,
|
|
37
|
+
lookup,
|
|
38
|
+
lookup_provider,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
#: Same as :func:`all_prices`, named like the Rust crate's ``llm_prices::all``. Not exported
|
|
42
|
+
#: by ``from llm_prices import *``, where it would hide the builtin ``all``.
|
|
43
|
+
all = all_prices
|
|
44
|
+
|
|
45
|
+
__version__ = "1.2.0"
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"GENERATED",
|
|
49
|
+
"CostBreakdown",
|
|
50
|
+
"DecimalCostBreakdown",
|
|
51
|
+
"LongContext",
|
|
52
|
+
"Price",
|
|
53
|
+
"Provider",
|
|
54
|
+
"RateName",
|
|
55
|
+
"Usage",
|
|
56
|
+
"all_prices",
|
|
57
|
+
"lookup",
|
|
58
|
+
"lookup_provider",
|
|
59
|
+
]
|