Skip to content
PALM SOUQ

Billing

Stripe Billing logoPALM SOUQ for Stripe Billing

Turn metered LLM usage into Stripe meter events automatically. PALM SOUQ maps each tenant to a Stripe customer, aggregates tokens or dollars per billing window and posts idempotent meter events your prices already understand.

Configured in the console · runs off the request path
stripe-billing · setup
# palmsouq.yaml  (billing sync)
billing:
  provider: stripe
  secret_ref: vault://stripe/restricted_key   # rk_live key with meter write scope
  customer_mapping:
    source: tenant_metadata
    field: stripe_customer_id
  meters:
    - event_name: llm_overage_tokens
      value: billable_tokens            # tokens above plan allowance
      allowance_by_tier:
        pro: 5_000_000
        team: 25_000_000
    - event_name: llm_cost_cents
      value: cost_cents
      markup: 1.3
  flush_every: 60s
  idempotency: "{tenant}:{meter}:{window_start}"

From gateway usage to a Stripe invoice line

Stripe's usage-based billing is built on Meters. You create a meter with an event name and an aggregation (sum, count or last), attach a metered price to it, and send meter events carrying a Stripe customer id and a value. Stripe aggregates the events over the billing period and prices them on the invoice.

PALM SOUQ does the sending. In the console you connect a restricted Stripe key, map your tenant id to the Stripe customer id (by metadata field, by a lookup webhook, or by uploading a mapping), and choose what each meter counts: raw tokens, billable tokens after your allowance, or cost in cents with a markup. The gateway batches usage per tenant per minute and posts meter events with a deterministic identifier, so retries never double-bill.

Allowances, overages and credits

The common hybrid plan is a flat subscription that includes an allowance of tokens, with overage billed per million tokens beyond it. PALM SOUQ tracks the allowance per tenant in real time and only emits meter events for usage above it, so the overage price on Stripe stays simple and the subscription price stays the subscription price.

For prepaid credit plans, PALM SOUQ can also draw down a Stripe customer credit balance and, when the balance reaches a threshold you set, fire a webhook to your app so you can prompt the customer to top up before the quota engine starts degrading or blocking.

Reconciliation and margin

Because PALM SOUQ knows both sides of each request, it can join what you charged (from Stripe subscriptions and meter events) with what you paid the model provider. The result is a per-customer revenue versus COGS view that updates through the month instead of once the invoice closes.

If a Stripe API call fails, events are queued in the PALM SOUQ region that metered them and retried with backoff. The console shows any tenant whose events are behind, with the count of pending events and the oldest timestamp.

Rolling it out safely

Connect a Stripe test mode key first. PALM SOUQ sends meter events to test mode exactly as it would in live mode, so you can open a test customer's upcoming invoice and see the overage line take shape while you generate traffic in staging.

When the invoice preview looks right, swap in a restricted live key with meter event write access only. Keep the key restricted: PALM SOUQ has no reason to read payment methods, create charges or edit subscriptions, and a restricted key makes that explicit.

Govern Stripe Billing usage per tenant, starting today.

Route your agent traffic through PALM SOUQ in 2 minutes. Change one base URL, pass a tenant header, and every token is attributed and governed.

14-day free production trial · 100k requests included · no card required