How It Works

Four steps to budget enforcement

From payment provider connection to live API verification in minutes.

Enforcement: 402 Hard Stop
Verification: <50ms
Budget Model: Dollars

Implementation Steps

Connect your payment provider

One-click OAuth with Polar. Subscriptions and plans sync automatically.

  • Automatic webhook registration
  • Sync existing subscriptions
  • Stripe & LemonSqueezy in beta

Create API keys with budgets

Issue keys with dollar-based budgets, scopes, and environment separation.

  • Prefixed keys (hk_live_, hk_test_)
  • Dollar-based budget limits
  • Per-environment isolation

Verify requests in < 50ms

Call POST /v1/verify from your middleware. Get validity, remaining budget, and entitlements.

  • Sub-50ms response times
  • remaining_budget_usd for enforcement
  • Entitlements from subscription plans

Enforce with 402

Return 402 Payment Required when budget is exceeded. No more runaway costs.

  • Hard stop at budget limit
  • Audit trail for all decisions
  • Usage tracked automatically

Integration

Add to your middleware

A few lines of code to verify every request and enforce budgets.

middleware.ts
const result = await holdify.verify({
  key: apiKey,
  resource: 'chat.completions',
});

if (!result.valid) {
  return res.status(401).json({ error: 'Invalid key' });
}

if (result.remaining_budget_usd <= 0) {
  return res.status(402).json({
    error: 'budget_exceeded',
    message: 'Payment Required',
    resetAt: result.reset_at
  });
}

// Budget verified - proceed with request
const completion = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: req.body.messages
});

Ready to protect your AI revenue?

Start free with 150K tokens/month. No credit card required. Setup in under 5 minutes.