Skip to main content

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

Metadata

Release files for neuforge-pay 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neuforge-pay 0.3.0
File Size Uploaded Provenance Actions
neuforge_pay-0.3.0.tar.gz 8.9 kB Without provenance Details for neuforge_pay-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neuforge-pay 0.3.0
File Interpreter ABI Platform Actions
neuforge_pay-0.3.0-py3-none-any.whl Python 3 none any Details for neuforge_pay-0.3.0-py3-none-any.whl

Total release size: 18.9 kB

Release files / neuforge_pay-0.3.0.tar.gz

Download URL neuforge_pay-0.3.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
55842cd4df5ea679eb8e40337589f613287319c0d448e5f8762ad21e68286603
BLAKE2b-256 checksum
How to use checksums
ba19620cc6a23575ff41eaa6ba83c44bd14eeff1f8966791d2814b4398b3f1fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / neuforge_pay-0.3.0-py3-none-any.whl

Download URL neuforge_pay-0.3.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07c2b742b63ee8d805254293f7eb801ac0898d56d9d476adbc462074a84ce573
BLAKE2b-256 checksum
How to use checksums
ee2cdfef39c7577330e8f0549d05c4bc56b197e5f4006d26c4f6edf5b45de001
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for neuforge-pay 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page