Metadata-Version: 2.4
Name: neuforge-pay
Version: 0.2.0
Summary: NeuForge Pay - Agentic Payments, Margin Guardrails, and MoR engine for AI developers.
Author-email: Gary Chen <gchen12016@gmail.com>
Project-URL: Homepage, https://neuforge.app
Project-URL: Bug Tracker, https://github.com/sophieamoure2026-ui/neuforge-pay/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: fastapi
Requires-Dist: pydantic

# NeuForge Pay Python SDK (`neuforge-pay`)

> **Real-Time AI Token Metering, Margin-Aware COGS Tracking, and Usage Billing for AI Developers & MCP Servers.**

`neuforge-pay` allows AI developers, micro-SaaS builders, and Model Context Protocol (MCP) server authors to add **real-time token metering**, **gross margin guardrails**, and **usage-based billing** to any FastAPI, Node.js, or MCP server in 3 lines of code.

---

## ⚡ Quick Start

### 1. Installation

```bash
pip install neuforge-pay
```

### 2. Add 3-Line Middleware to Your API / MCP Server

```python
from fastapi import FastAPI
from neuforge_pay import meter_endpoint

app = FastAPI()

@app.get("/v1/agent")
@meter_endpoint(
    price_charged_usd=0.05,        # Bill customer $0.05 per request
    model_name="claude-3-5-sonnet", # Calculate real COGS against Claude 3.5
    estimated_input_tokens=1500,
    estimated_output_tokens=600
)
async def run_ai_agent(customer_id: str):
    # Your AI Agent logic here...
    return {"status": "success", "result": "Agent completed task"}
```

---

## 📊 Live COGS & Margin Engine

`neuforge-pay` contains built-in 2026 pricing tables for:
* **OpenAI**: `gpt-4o`, `gpt-4o-mini`, `o1`, `o3-mini`
* **Anthropic**: `claude-3-5-sonnet`, `claude-3-5-haiku`, `claude-3-opus`
* **Google Gemini**: `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-3.5-flash`, `gemini-3.5-pro`
* **DeepSeek**: `deepseek-v3`, `deepseek-r1`

It automatically calculates:
$$\text{Realtime Gross Margin \%} = \frac{\text{Customer Revenue Billed} - \text{Vendor Model Cost}}{\text{Customer Revenue Billed}} \times 100$$

If a heavy user's LLM loop causes their account gross margin to drop below your threshold (e.g., `<35%`), `neuforge-pay` triggers an instant guardrail alert to prevent margin collapse.

---

## 🧪 Run Demo Simulation

```bash
python3 examples/fastapi_mcp_server.py
```
