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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuforge_pay-0.2.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neuforge_pay-0.2.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file neuforge_pay-0.2.0.tar.gz.

File metadata

  • Download URL: neuforge_pay-0.2.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for neuforge_pay-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aa40b18a7ae77bff3e103f3fbb189f992e26c02c2021a0f2d16efd34bca0e8a1
MD5 09fbe5dab37f181ea30749f088784fc7
BLAKE2b-256 57c156991fcbbf926a2928c8ad3d22e8b156da43f3d7364c4ed65e1623d6ebd0

See more details on using hashes here.

File details

Details for the file neuforge_pay-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: neuforge_pay-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for neuforge_pay-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2015d31d5ca1d5884e6b3f706b1c037d88520e5a24fd06263f3b0f13357a709a
MD5 86e5a34b3fa3dad75bf9c7484a5dd2f2
BLAKE2b-256 f1402603680c5a3e2dd04cb91bb6cc7487801366a0b9892a96b97b48d4d6ae4c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page