Skip to content

Billing & Monetization


Overview

Traylinx uses a credit-based billing system that enables:

  1. Developers to monetize their agents
  2. Users to pay for exactly what they use
  3. Platform to take a sustainable commission

The Credit System

How It Works

┌─────────────────────────────────────────────────────────────────────────────┐
│                           CREDIT LIFECYCLE                                   │
└─────────────────────────────────────────────────────────────────────────────┘

   USER                    PLATFORM                    DEVELOPER
     │                        │                            │
     │  1. Buy Credits        │                            │
     │  $10 → 10,000 CREDITS  │                            │
     │───────────────────────▶│                            │
     │                        │                            │
     │  2. Use Agent          │                            │
     │  (50 credits/request)  │                            │
     │───────────────────────▶│                            │
     │                        │  3. Deduct from user       │
     │                        │     Add to developer       │
     │                        │     (minus 20% fee)        │
     │                        │───────────────────────────▶│
     │                        │                            │
     │                        │  4. Monthly payout         │
     │                        │     Credits → $USD         │
     │                        │───────────────────────────▶│

Why Credits?

Benefit Explanation
Micro-transactions Charge $0.001 per call without payment fees
Unified billing One invoice for 100 different agents
Prepaid safety No risk of unpaid bills
Currency agnostic Works globally

Pricing Models

1. Usage-Based (Default)

pricing:
  model: "usage_based"
  currency: "CREDITS"
  rates:
    - metric: "request"
      amount: 50
    - metric: "compute_minute"
      amount: 10

Flow: User pays per request/minute of compute.

2. Subscription

pricing:
  model: "subscription"
  subscription_tiers:
    - name: "starter"
      credits_per_month: 1000
      price_usd: 9.99
    - name: "pro"
      credits_per_month: 10000
      price_usd: 49.99

Flow: User pays fixed monthly fee for credit allowance.

3. Free

pricing:
  model: "free"

Flow: No charges, developer absorbs costs.


Revenue Sharing

Party Share Description
Developer 80% Goes to developer wallet
Platform 20% Traylinx commission

Example: - User pays 100 credits - Developer receives 80 credits - Platform receives 20 credits


Billing Service Architecture

Database Schema

┌──────────────────────────────────────────────────────────────────────────┐
│                         BILLING SERVICE SCHEMA                            │
└──────────────────────────────────────────────────────────────────────────┘

┌─────────────────────┐     ┌─────────────────────┐     ┌─────────────────┐
│      wallets        │     │    transactions     │     │   usage_events  │
├─────────────────────┤     ├─────────────────────┤     ├─────────────────┤
│ id (PK)             │     │ id (PK)             │     │ id (PK)         │
│ owner_type (enum)   │────▶│ wallet_id (FK)      │     │ agent_id        │
│ owner_id            │     │ amount              │     │ caller_id       │
│ balance             │     │ type (credit/debit) │     │ metric          │
│ currency            │     │ reference_id        │     │ value           │
│ created_at          │     │ created_at          │     │ credits_charged │
└─────────────────────┘     └─────────────────────┘     │ timestamp       │
                                                         └─────────────────┘

┌─────────────────────┐     ┌─────────────────────┐
│      payouts        │     │   pricing_plans     │
├─────────────────────┤     ├─────────────────────┤
│ id (PK)             │     │ id (PK)             │
│ developer_id        │     │ agent_id            │
│ amount_credits      │     │ model               │
│ amount_usd          │     │ rates (JSONB)       │
│ stripe_transfer_id  │     │ subscription_tiers  │
│ status              │     │ effective_from      │
│ created_at          │     └─────────────────────┘
└─────────────────────┘

Integration Points

Router Agent (Usage Metering)

The Router Agent enforces credit checks and logs usage:

Request Flow:
1. User calls Router with Agent request
2. Router checks user's credit balance
3. If sufficient → forward request
4. After response → log usage event
5. Billing Service deducts credits

Stripe Integration

For credit purchases and developer payouts:

Credit Purchase:
  User → Stripe Checkout → Webhook → Add credits to wallet

Developer Payout:
  Monthly job → Calculate earnings → Stripe Transfer → Mark paid

API Endpoints (Planned)

Wallet Management

Endpoint Method Description
/v1/wallet/balance GET Get current balance
/v1/wallet/transactions GET List transactions
/v1/wallet/topup POST Create Stripe checkout

Developer Dashboard

Endpoint Method Description
/v1/developer/earnings GET View earnings
/v1/developer/payouts GET Payout history
/v1/developer/agents/:id/stats GET Per-agent analytics

Usage (Internal)

Endpoint Method Description
/internal/usage/log POST Log usage event
/internal/usage/check POST Check sufficient credits

Credit Economics

Pricing Guidelines

Agent Type Suggested Rate Rationale
Simple query 5-20 credits Low compute
API wrapper 10-50 credits External API cost
AI generation 50-200 credits LLM inference cost
Complex research 100-500 credits Multiple steps

Exchange Rate

1,000 CREDITS = $1.00 USD

This allows: - Minimum charge: 1 credit = $0.001 - Maximum flexibility for micro-pricing


Implementation Priority

Phase Component Sprint
1 Credit wallet schema Sprint 7
2 Usage event logging Sprint 7
3 Stripe checkout Sprint 7
4 Router credit check Sprint 8
5 Developer payouts Sprint 8
6 Analytics dashboard Sprint 9