Metadata-Version: 2.5
Name: langchain-llm-prices
Version: 0.1.0
Summary: LLM cost tracking for LangChain across every provider: get_cost_callback (get_openai_callback for Anthropic, Gemini, Bedrock, Vertex, Groq, Mistral, DeepSeek...) and CostCapMiddleware, a dollar budget for create_agent. Priced by llm-prices.
Project-URL: Homepage, https://github.com/Mattbusel/langchain-llm-prices
Project-URL: Documentation, https://github.com/Mattbusel/langchain-llm-prices/blob/main/docs/index.md
Project-URL: Changelog, https://github.com/Mattbusel/langchain-llm-prices/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/Mattbusel/langchain-llm-prices/issues
Project-URL: Prices, https://github.com/Mattbusel/llm-prices
Author: Matthew Busel
License-Expression: MIT
License-File: LICENSE
Keywords: anthropic,budget,callbacks,cost,gemini,langchain,llm,middleware,openai,pricing,tokens
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: langchain-core<2,>=1.0
Requires-Dist: langchain<2,>=1.0
Requires-Dist: llm-prices<2,>=1.3
Description-Content-Type: text/markdown

# langchain-llm-prices

Know what your LangChain app spends, for every provider, and stop an agent before it spends
too much. Prices come from [`llm-prices`](https://pypi.org/project/llm-prices/): dated,
source-cited list prices for Anthropic, OpenAI, Google (AI Studio and Vertex), Bedrock,
Azure, DeepSeek, Mistral, Groq, Together, Fireworks, xAI, Cohere and OpenRouter, with prompt
cache reads and writes at their own rates.

```bash
pip install -U langchain-llm-prices
```

**`get_cost_callback()`**: `get_openai_callback`, but for every provider.

```python
from langchain.chat_models import init_chat_model
from langchain_llm_prices import get_cost_callback

with get_cost_callback() as cb:
    init_chat_model("anthropic:claude-sonnet-4-6").invoke("Tell me a joke")
    init_chat_model("google_genai:gemini-2.5-flash").invoke("Tell me a joke")
print(cb.total_cost, cb.cost_by_model)
```

**`CostCapMiddleware`**: a dollar budget for `create_agent`, per run and per thread.

```python
from langchain.agents import create_agent
from langchain_llm_prices import CostCapMiddleware

agent = create_agent(
    "anthropic:claude-sonnet-4-6",
    tools=[...],
    middleware=[CostCapMiddleware(max_usd_per_run=0.50, max_usd_per_thread=5.00)],
)
```

Models with no listed price (local models, private deployments) are reported as unpriced,
never counted as $0 without telling you.

Docs: https://github.com/Mattbusel/langchain-llm-prices/blob/main/docs/index.md
