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
pip install neuforge-pay
2. Add 3-Line Middleware to Your API / MCP Server
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
python3 examples/fastapi_mcp_server.py
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuforge_pay-0.3.0.tar.gz.
File metadata
- Download URL: neuforge_pay-0.3.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55842cd4df5ea679eb8e40337589f613287319c0d448e5f8762ad21e68286603
|
|
| MD5 |
a61df57f93df7a8edeec8bf5001763e3
|
|
| BLAKE2b-256 |
ba19620cc6a23575ff41eaa6ba83c44bd14eeff1f8966791d2814b4398b3f1fb
|
File details
Details for the file neuforge_pay-0.3.0-py3-none-any.whl.
File metadata
- Download URL: neuforge_pay-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c2b742b63ee8d805254293f7eb801ac0898d56d9d476adbc462074a84ce573
|
|
| MD5 |
54c13bb890e4a73cb53478e59f457aa4
|
|
| BLAKE2b-256 |
ee2cdfef39c7577330e8f0549d05c4bc56b197e5f4006d26c4f6edf5b45de001
|