Paygent

The cost control layer for AI agents.

Track what every user costs you. Set spending limits. Get alerted before margins go negative.

Why AI agents bleed money

Every agent invocation is a black box of unpredictable, per-user cost.

You can't see what each user costs

A single prompt triggers chains of model calls, retries, and tool executions across multiple providers. You have no visibility into per-user, per-model cost.

No way to stop runaway spend

Your heaviest users burn 10x more than they pay for. There's no automated way to cap, throttle, or gate them before they eat your margin.

Billing has no idea what happened

Your billing charges a flat fee. Your actual costs vary per user, per session, per model. These two systems never talk to each other.

User Prompt Agent LLM x N Tools x N Rising Cost

Where Paygent sits in your stack

Your Agent / App
Paygent
Meter Guard Alert Sync
OpenAI · Anthropic · Other

Visibility. Limits. Alerts.

The runtime layer between your AI agent and your margin.

01

Cost Visibility

Problem

A single user prompt can trigger a chain of model calls, retries, and sub-agents. You have no idea what any individual user actually costs you.

Benefit

See per-user, per-model cost in real time. A built-in dashboard shows spend trends, model breakdown, top users, and gate activity — live, out of the box.

from paygent import Paygent, paygent_context

pg = Paygent.init(api_key="pg_live_...")

with paygent_context(user_id="user_123"):
    # Every LLM call inside this block is
    # automatically metered per user per model
    response = openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": query}],
    )
user_123 Pro Plan
gpt-4o 31,200 tokens
claude-sonnet 8,400 tokens
gpt-4o-mini 12,100 tokens
Period cost $23.47
02

Spending Limits

Problem

You charge every user the same flat fee, but some cost you 10x more than others. Without per-user limits, your best plan subsidizes your worst margins.

Benefit

Set per-user spend limits and per-model token caps. When a user hits their threshold, Paygent fires a soft gate (warn) or hard gate (block) — your rules, enforced at runtime.

# Soft gate: warn when approaching limit
def on_approaching_limit(result):
    notify_user(f"Used {result.usage_pct:.0%} of plan")

pg.on_soft_gate(on_approaching_limit)

# Hard gate: block when limit is hit
def on_limit_hit(result):
    raise PaygentLimitExceeded(result.message)

pg.on_hard_gate(on_limit_hit)
Pro Plan $49/mo
usage 87%
soft gate → warn user
hard gate → block call
→ trigger upgrade flow
03

Real-time Alerts

Problem

When a user gets blocked or crosses a spending threshold, you find out hours later — if at all. No way to react in real time.

Benefit

Webhooks deliver event data to your stack the moment something happens — gate fired, user hit 80% of their limit, call blocked. Trigger upgrade flows, Slack alerts, or billing sync instantly.

{
  "type": "gate_event.hard_gate",
  "data": {
    "user_id": "user_123",
    "gate_reason": "total_spend",
    "current_value": 49.50,
    "limit_value": 49.00,
    "blocked": true
  }
}
POST https://api.yourapp.com/webhooks 200 OK
Subscribed events
gate_event.hard_gate usage.threshold.80 gate_event.soft_gate
delivered · signed · 142ms just now

See your costs before they surprise you

Per-user spend, per-model breakdown, gate activity, top users — live, out of the box. No extra setup.

app.paygent.to/dashboard
Total Cost
$2,847.32
Total Tokens
4.2M
Active Users
156
Hard Gates
12
Spend over time Jun 10–23
1011121314151617181920212223
Cost by model
gpt-4o $1,684
claude-sonnet $712
gpt-4o-mini $318
claude-haiku $133
Top users
user_8821 $214.90
user_1043 $176.20
user_5567 $148.75
user_2290 $121.40

Get set up in five steps

Create a product, define your plans, add users, drop in the SDK — and you're metered.

01

Create your product

Sign up to the dashboard and get your Paygent API key. A product is one agent or app you're metering.

02

Configure a plan

Define spend limits, per-model token caps, and cost rates — the tiers you sell, like Free, Pro, and Scale.

03

Add your users

Register each end user by your own ID and assign them to a plan. Their limits and billing window come from the plan.

04

Drop in the SDK

Install Paygent (Python or TypeScript), call init() once, and wrap your LLM calls with the user context.

05

Go live

Every call is metered and gated automatically. Watch spend, gates, and top users on the dashboard — and get webhooks in real time.

POST /products → product + pg_live_… API key
POST /config/plans spend limits · token caps · cost rates
POST /users + subscription user_123 → assigned to Pro plan
Paygent.init() + paygent_context(user_id) your LLM calls, unchanged
Live metered · gated · dashboard + webhooks

Your margins, before and after

Without Paygent

Subscription Revenue $999
Actual AI Cost $1,340
Net Margin -34%

Costs exceed revenue. Margin is negative.

With Paygent

Recommended
Subscription Revenue $999
Controlled AI Cost $719
Net Margin +28%

Gating keeps costs within budget.

In most AI products, the top 5% of users drive over half the cost. Without per-user visibility and limits, they erode everyone else's margin.

Example based on a 100-user SaaS with mixed model usage and a small group of power users.

Get started in 5 minutes

from paygent import Paygent, paygent_context

# 1. Initialize
pg = Paygent.init(api_key="pg_live_...")

# 2. Wrap your request handler
with paygent_context(user_id="user_123"):
    response = openai.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": query}],
    )

# That's it. Every LLM call is now:
#   ✓ Metered (tokens, cost, per model)
#   ✓ Guarded (soft warnings + hard blocks)
#   ✓ Synced (to Paygent backend, automatically)
Supports OpenAI Anthropic LangChain CrewAI Vercel AI SDK

Built to stay out of your way

Quick setup

One init call and a context wrapper. You're live in minutes — your existing LLM code stays exactly as it is.

Not a proxy

Paygent runs in-process as an SDK, not a gateway in front of your traffic. No extra hop, no new point of failure.

No added latency

Guard checks are in-memory — single-digit milliseconds. Metering and sync run in the background, off the request path.

Adapts at runtime

Change a plan's limits, rates, or model caps and the SDK picks them up at runtime. No redeploy, no restart.

Know what every user costs. Control what they spend.

Free while we're in beta. Set up in 5 minutes.