Metadata-Version: 2.5
Name: neuforge-langchain
Version: 1.0.1
Summary: NeuForge x402 Token Metering for LangChain
Project-URL: Documentation, https://github.com/titansignal/neuforge-langchain#readme
Project-URL: Issues, https://github.com/titansignal/neuforge-langchain/issues
Project-URL: Source, https://github.com/titansignal/neuforge-langchain
Author-email: Gary Chen <gchen12016@gmail.com>
License-Expression: Apache-2.0
Keywords: langchain,metering,neuforge,x402
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.9
Requires-Dist: langchain-core>=0.2.0
Description-Content-Type: text/markdown

# NeuForge Pay for LangChain (`neuforge-langchain`)

A LangChain callback handler that natively implements the Bounded Overshoot x402 token metering protocol.

> **⚠️ Pricing & Metering Disclosure**
> This SDK requires an active API key from [neuforge.app](https://neuforge.app). 
> It acts as a cloud-metered gateway that tracks your LLM token usage and synchronizes it synchronously with the NeuForge backend via HTTP. 
> 
> **Important:** If your NeuForge account balance drops below zero or your budget is exceeded, this SDK will intentionally halt your execution by throwing an `HTTP 402 Payment Required` exception. You must manage your billing on neuforge.app to ensure uninterrupted service.

## Usage

```python
from neuforge_langchain import NeuForgeCallbackHandler
from langchain_openai import ChatOpenAI

# Initialize with your API Key from neuforge.app
handler = NeuForgeCallbackHandler(api_key="nf_live_your_api_key_here")
llm = ChatOpenAI(callbacks=[handler])

# This generation will hit the NeuForge cloud backend to sync token usage.
# If your account runs out of budget, a PaymentRequiredException is thrown!
response = llm.invoke("Write a very long story.")
```
