Paid Experiences — Design Document

Status: Planned. The Echo economy underneath this feature has shipped; paid packages themselves have no implementation yet. See the Implementation State table for what's reusable and what still needs building. The first hosted model behind paid experiences is covered in Hosted Inference via Featherless.ai.

Overview

Creators turn packages into paid experiences. A creator configures a polished package — character, mode, prompts, lorebooks, model — and sets a per-message price in Echoes. The platform serves the LLM call using its own credentials and pays the creator a revenue share.

This addresses two distinct problems:

  1. Creator monetization — packages become products. A polished RPG, a tuned mystery, a creative-writing coach all become things creators can earn from.
  2. Provider access — users in regions where Anthropic, OpenAI, or OpenRouter are unavailable can still chat. They pay the creator in Echoes; the platform routes the inference through its own API keys.

Packages are already the container for curated experiences (character + mode + lorebooks + locks + model profiles). Paid experiences are a pricing layer on top — no new entity type.


Implementation State

Everything below the line is the target design. This table is the actual state of the code today (verified 2026-05-12). Read it before implementing anything.

Area State Notes
Echo ledger (echo_transactions, partitioned, ledger-only) Shipped database/v1/20d_tables_echo_ledger.sql. Has allocate/commit/release status, pool tagging, expiring credits. Reuse as-is.
Canonical Echo-spend primitives (fn_debit_spendable, fn_debit_persistent, fn_transfer_spendable, EchoSpendOutcome) Shipped functions/41i_echo_spend_helpers.sql. Paid-package debit + creator credit must use these — do not write new ad-hoc ledger writes.
monetary_purchases table + fn_credit_monetary_purchase Shipped Provider-agnostic purchase plumbing. The durable record + Echo credit path is built; the first user-facing purchase endpoint (PayU create-order + accountConsole checkout, 2026-09-28) is live (Beta) behind the Card rail switch (off / sandbox / production).
Subscription as recurring Echo grant Shipped fn_grant_subscription_echoes (functions/39a_subscription_refactor_functions.sql). Pro / Premium tiers fire subscription_grant ledger rows on cycle.
Gift codes (interim purchase rail) Shipped fn_redeem_gift* in functions/40_gift_code_functions.sql. Can grant tier and / or arbitrary Echo amounts.
Creator Tips (one-time + per-message engagement) Shipped EchoTipsEndpoints.cs, EngagementChargeStage.cs. This obsoletes the "Voluntary BYOK Support" future-extension that used to live in this doc — it shipped as engagement_tips + per-message tip_sent / tip_received.
verified_creators table Shipped 12_tables_moderation.sql. Currently only gates auto-publish. Re-used as the eligibility gate for paid mode (see Eligibility).
IPreLlmStage / IPostLlmStage interfaces Shipped Slots ready. New paid-package stages plug in here.
verified_creators paid-mode gate Not built Eligibility check has no caller yet.
packages paid columns (is_paid, echo_price_per_message, paid_model_identifier, free_trial_messages, paid_enabled_at, paid_disabled_at) Not built
platform_model_costs table Shipped database/v1/63_tables_platform_model_costs.sql (a1a1df8ae, 2026-05-18) — the priced platform-model catalog, edited in the admin console and over the admin MCP platform_models pack. Source of truth for the per-model Echo floor.
web_message_stats paid-experience columns (echo_cost, echo_creator_earned, package_id) Not built Attribution columns for per-message analytics.
package_free_trials table Not built Per-user, per-package free-message counter.
package_ratings table Not built — v2.
creator_deposits table Not built — v2.
Pre-LLM balance-check stage Not built
Post-LLM charge-and-credit stage Not built
Pricing API (PUT /api/packages/{id}/pricing, GET /api/packages/models, GET /api/echoes/earnings) Not built
Hosted checkout for Echo purchase Shipped (Beta) PayU Echo-bundle checkout on the account site, shown only where the Card rail is open to the account (4cf75f5a7 adds the shown-price check). Patreon subscription grants + gift codes cover everyone else.
Creator payout (withdraw cashable Echoes → USD) Not built — v2. Likely Wise manual until processor situation changes.
AWOL detection (30 / 60 / 90 / 180-day inactivity timeline) Not built — v2.
echo_wallets (deprecated concept) Does not exist. Ledger-only. Any reference in older docs is stale.

The "Not built" / v2 entries below are the design target. Everything else is a pointer at infrastructure to reuse, not to rebuild.


Virtual Currency: Echoes

Echoes are the platform's in-app currency. They're a ledger-only balance (no stored wallet row) computed from echo_transactions. Echoes are split at read time into pools — daily / locked-bundle / locked-subscription / cashable — and only the cashable pool is withdrawable to USD. Full economy model is in Daily Tasks & Echo Economy. The relevant rules for paid experiences:

Source Lands in Withdrawable?
Daily task reward Expiring / daily bucket No
Subscription monthly grant (Pro / Premium) Locked-subscription bucket No
Gift code grant Persistent (expiring_other or unrestricted, per code config) Depends
Direct purchase (when hosted checkout exists) Persistent / cashable Yes
Paid-message earnings (creator) Cashable Yes
Tip received Persistent (spendable, not cashable) No

Sending a tip and earning paid-message revenue land in different pools intentionally: tips are an appreciation channel, paid messages are a commercial channel. Only the commercial channel converts back to USD.

What users pay with

Users can spend any spendable Echoes on a paid message — daily, subscription, persistent, expiring — they're all valid for inference spend. The only pool that's not spendable is whatever is held in unconfirmed (allocated-but-not-committed) state from another in-flight charge.

Exchange rate

Set by the platform; not exposed in this doc as a hard number until hosted checkout exists. The principle: Echoes are decoupled from USD so we can adjust the rate without forcing creators to reprice. Creators always earn the same Echo amount per message regardless of what the buyer paid for those Echoes.


Pricing Model

Internal accounting is per-token. User-facing display is per-message. The platform computes the real cost of each message from input / output tokens (and any embedding work it triggered); the user sees a per-message estimate up front and an itemized "you paid N☆" after. How we get billed upstream (per-token for Anthropic / OpenAI, flat-subscription for Featherless) is not a user concern — the platform reconciles its margin internally.

Creators set a markup, not a total price. The markup is what the creator earns on top of the platform's computed cost.

platform_cost_estimate = est_input_tokens × input_rate
                       + est_output_tokens × output_rate
                       + est_embedding_calls × embedding_rate
                       × margin_multiplier
                       × echoes_per_dollar
                       (rounded up to whole Echoes)

creator_markup         = creator-set: flat Echoes/msg OR percent-of-cost (whichever is higher)
estimated_user_price   = platform_cost_estimate + creator_markup       ← shown in UI as "~N☆/msg"

# At commit time, real tokens replace estimates:
platform_cost_actual   = real_input_tokens × input_rate
                       + real_output_tokens × output_rate
                       + real_embedding_calls × embedding_rate
                       × margin_multiplier
                       × echoes_per_dollar

platform_fee_rate      = 0.30 default, 0.20 if parent project has an active Project Slot
creator_earns          = floor(creator_markup × (1 - platform_fee_rate))
platform_keeps         = platform_cost_actual + (creator_markup - creator_earns)
total_user_charge      = platform_cost_actual + creator_markup

The user sees one number per message ("≈ 8☆"). They opt in to that rate once on the paywall. The platform internally tracks per-token usage for cost accounting; the creator's earnings are independent of message length because they're tied to the markup, not the underlying cost.

Estimate vs actual

The user never sees a charge they didn't pre-agree to in concept, and never gets surprised by an after-the-fact price hike on a single message.

Worked example — per-token model (Anthropic Sonnet)

Sonnet rates: $3 / Mtok input, $15 / Mtok output. Margin multiplier 1.5×. Conversion 100 Echoes / $1.

A user sends a message to a Sonnet-backed paid package; real usage comes back 4,820 input / 312 output tokens; one embedding call happened during context build.

input_cost   = 4820  × $3/Mtok × 1.5  × 100☆/$ = 2.17☆
output_cost  = 312   × $15/Mtok × 1.5 × 100☆/$ = 0.70☆
embed_cost   = 1     × $0.02/call × 1.5 × 100☆/$ = 0.003☆
platform_cost_actual = ceil(2.17 + 0.70 + 0.003) = 3☆
creator_markup       = 5☆ (creator set "+5☆ flat")
total_user_charge    = 3 + 5 = 8☆

Default project:
  platform_fee = floor(5 × 0.30) = 1☆
  creator_earns = 5 - 1 = 4☆ (cashable)
  platform_keeps = 3 + 1 = 4☆

Slotted project:
  platform_fee = floor(5 × 0.20) = 1☆
  creator_earns = 5 - 1 = 4☆ (cashable)
  platform_keeps = 3 + 1 = 4☆

(Project Slot discount has rounding ties at small markups; the math gets meaningful at +10☆ and up. With +10☆ markup default fee 3☆ vs slotted 2☆ — the slot pays back at ~500 messages / month.)

Worked example — subscription-billed model (Featherless)

Featherless bills flat-rate subscription, not per-token. The platform synthesizes a per-token rate from the plan:

synthetic_rate_per_mtok = monthly_subscription_cost
                        × margin_multiplier
                        / expected_monthly_tokens
                        / 1_000_000

# e.g. $25 plan, 1.5× margin, expected 300M tokens / month:
# = $25 × 1.5 / 300M / 1M = $0.000125 / Mtok blended

This synthetic rate populates the same input_rate_usd_per_mtok and output_rate_usd_per_mtok columns in platform_model_costs. The pricing pipeline doesn't care that one came from a real-rate card and the other from a divided subscription — both consumers read the same columns and run the same math.

When Featherless's actual usage diverges from expected_monthly_tokens, the rate gets retuned quarterly. The creator's markup and the user's per-message price stay stable; only the platform-cost slice flexes.

Creator markup shape

Creators pick one of:

Markup shape Example When it makes sense
Flat "+5☆ per message" Casual character / setting. Predictable creator earnings.
Percent of cost "+50% of platform cost, minimum 3☆" Premium "studio" experience. Earnings scale with model expense.

Stored as markup_amount INTEGER and markup_percent SMALLINT on the package; commit-time math uses max(markup_amount, markup_percent × platform_cost_actual / 100) so the creator floor is honored even on short messages.

No price ceiling. The market regulates overpriced experiences via ratings (v2).

Why creator-set markup (not creator-set total price)

(An earlier revision of this doc adopted a flat-creator-price model with a per-model floor, then rejected markup-over-cost on the grounds that Featherless's subscription billing didn't have per-token math. The synthetic-rate trick above fixes that — same per-token consumer for both billing styles — so markup-over-cost is the better fit.)

Rate change mechanics

platform_model_costs.input_rate_* / output_rate_* / embedding_rate_* are updated when:

Rate changes apply to future messages in any conversation. Existing conversations are not retroactively repriced. The creator's markup is unchanged by rate updates; their per-message earnings stay flat. The user's displayed estimate refreshes on the next conversation start.

There's no "creator's price went below the floor" case to handle — the creator doesn't set a total price, only a markup, and markup-over-cost is always well-defined as long as the model has a non-negative cost. If the platform-cost portion becomes so large that the total exceeds a per-conversation guardrail (max_charge_per_message), the message is blocked with a "this model is over budget" error and the creator is nudged to pick a cheaper model.


How It Works

Creator setup

A creator configures a paid experience in the package workbench:

  1. Build the package — character, mode, lorebooks, trackers, locks (existing Packages system).
  2. Pick the model from the hosted catalog — GET /api/packages/models returns the available platform_model_costs rows.
  3. Set the price — Echoes per message. The UI shows the model floor and warns if the creator's price is too close to it (their margin would round to zero).
  4. Toggle paid mode — requires the package to be published and to meet the Eligibility bar.
┌─ Package Settings: "Crystal of Dawn RPG" ─────────────────────────────┐
│                                                                         │
│  ┌─ Paid Experience ───────────────────────────────────────────────┐   │
│  │                                                                  │   │
│  │  [✓] Enable paid experience                                      │   │
│  │                                                                  │   │
│  │  Model:        [Claude Sonnet — hosted ▾]                        │   │
│  │                Typical platform cost: ~3 ☆/msg                   │   │
│  │                                                                  │   │
│  │  Your markup:  ( ) Flat   [ 5 ] ☆/msg                            │   │
│  │                ( ) Percent  [   ] %  (min flat)                  │   │
│  │                                                                  │   │
│  │  Estimated user-facing price: ~8 ☆/msg                           │   │
│  │  Your earnings:               4 ☆/msg (default project)          │   │
│  │                                4 ☆/msg (with Project Slot)       │   │
│  │                                                                  │   │
│  │  Free trial: 3 messages (platform-set, not configurable)         │   │
│  │                                                                  │   │
│  │  ⚠ Character and Mode must be locked.                            │   │
│  │                                                                  │   │
│  └──────────────────────────────────────────────────────────────────┘   │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

The platform-cost number is a typical-message estimate (default estimated_output_tokens + a representative prompt size). The user-facing price shown on the package listing is the same estimate; actual per-message charges reconcile post-LLM with real tokens.

User experience

  1. Browse / discover — paid packages show the per-message estimate on the listing: "~8 Echoes / msg".
  2. Start a conversation — the first 3 messages are free; user gets the full experience.
  3. Paywall after trial — inline prompt blocks the next message until the user has enough Echoes:
┌────────────────────────────────────────────────────────────────┐
│  You've used your 3 free messages for this experience.         │
│                                                                │
│  This experience costs about 8 Echoes per message              │
│  (varies slightly with message length).                        │
│                                                                │
│  Your balance: 230 Echoes                                      │
│                                                                │
│  [ Continue ]    [ Buy Echoes ]    [ Use Your Own Key ]        │
└────────────────────────────────────────────────────────────────┘
  1. Continue chatting — each assistant message is charged at commit time based on real token usage. Balance shown in the chat header. Per-message transaction history shows the breakdown if the user expands it.
  2. Run out of Echoes — conversation pauses; user can top up (gift code today, hosted checkout when available) and resume. History is preserved.

BYOK escape hatch

Every paid package has a "Use Your Own Key" option that starts a regular free conversation using the user's own API key. The user gets the character / mode / lorebooks / locks but picks their own model. This preserves BYOK as a first-class path and stops paid mode from being a forced upgrade for technical users.


Eligibility

Paid mode requires trust. The eligibility check happens when the creator toggles is_paid = TRUE.

Requirement Implementation
Creator rights Existing users.rights >= Creator check.
Verified Creator (admin-granted trust flag) Existing verified_creators table — gate paid-mode toggle on is_active = TRUE.
Published package Existing package publication state.
Character + Mode locked Existing package lock system.

The creator_deposits "skin in the game" deposit for unverified creators is deferred to v2. v1 simply requires Verified Creator status. This is the cleaner UX (no surprise Echo deposit) at the cost of a slower onboarding ramp (admins must verify creators before they can monetize). Trade-off accepted.


Free Trial

The first 3 messages per user per package are free, regardless of how many conversations the user starts with that package. Tracked in package_free_trials.


Data Model

The shipped ledger and primitives are reused as-is. Only the additive schema is listed here.

packages — add columns

ALTER TABLE packages
    ADD COLUMN IF NOT EXISTS is_paid BOOLEAN NOT NULL DEFAULT FALSE,
    ADD COLUMN IF NOT EXISTS paid_model_identifier VARCHAR(255),
    ADD COLUMN IF NOT EXISTS creator_markup_amount INTEGER NOT NULL DEFAULT 0,
    ADD COLUMN IF NOT EXISTS creator_markup_percent SMALLINT NOT NULL DEFAULT 0,
    ADD COLUMN IF NOT EXISTS free_trial_messages SMALLINT NOT NULL DEFAULT 3,
    ADD COLUMN IF NOT EXISTS paid_enabled_at TIMESTAMPTZ,
    ADD COLUMN IF NOT EXISTS paid_disabled_at TIMESTAMPTZ;

COMMENT ON COLUMN packages.creator_markup_amount
    IS 'Flat Echo markup per assistant message. Commit-time charge uses max(markup_amount, markup_percent × platform_cost / 100).';
COMMENT ON COLUMN packages.creator_markup_percent
    IS 'Percent markup over computed platform cost. Commit-time charge uses max(markup_amount, markup_percent × platform_cost / 100). 0 = flat-only.';
COMMENT ON COLUMN packages.paid_model_identifier
    IS 'Hosted model identifier from platform_model_costs. Platform supplies the API key for this model.';

platform_model_costs — new table

CREATE TABLE IF NOT EXISTS platform_model_costs (
    id SERIAL PRIMARY KEY,
    model_identifier VARCHAR(255) NOT NULL UNIQUE,
    display_name VARCHAR(100) NOT NULL,
    provider VARCHAR(50) NOT NULL,              -- 'featherless', 'anthropic', 'openai', etc.
    pricing_model VARCHAR(20) NOT NULL,          -- 'per_token' | 'subscription' (informational; consumers always read the per-token columns)
    -- Per-token rates (Anthropic/OpenAI native; synthesized for subscription-billed providers)
    input_rate_usd_per_mtok NUMERIC(10,6) NOT NULL,
    output_rate_usd_per_mtok NUMERIC(10,6) NOT NULL,
    -- Embedding cost when this model triggers context-build embeddings (NULL = use platform default embedding cost)
    embedding_rate_usd_per_call NUMERIC(10,6),
    -- Margin and presentation
    margin_multiplier NUMERIC(4,2) NOT NULL DEFAULT 1.50,
    echoes_per_dollar INTEGER NOT NULL DEFAULT 100,  -- conversion at commit time
    -- Per-conversation safety guardrail. Real per-message charges above this are platform-eaten.
    max_charge_per_message INTEGER NOT NULL DEFAULT 50,
    -- Heuristic for the pre-LLM allocation (output tokens to budget when the request doesn't override)
    estimated_output_tokens INTEGER NOT NULL DEFAULT 512,
    -- Subscription providers (informational, for catalog sync / admin display)
    subscription_tier VARCHAR(20),
    concurrency_cost INTEGER,
    is_available BOOLEAN NOT NULL DEFAULT TRUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

COMMENT ON TABLE platform_model_costs IS 'Catalog of hosted models the platform exposes for paid experiences. Per-token rates drive commit-time cost computation; subscription-billed providers synthesize a blended per-token rate so the consumer math is uniform.';
COMMENT ON COLUMN platform_model_costs.input_rate_usd_per_mtok IS 'USD per million input tokens. For subscription-billed providers (Featherless), this is monthly_cost × margin / expected_monthly_tokens / 1M.';
COMMENT ON COLUMN platform_model_costs.max_charge_per_message IS 'Hard cap on per-message platform cost. Messages whose real cost would exceed this are charged the cap; the overrun is platform-eaten. Prevents a runaway long-output message from draining a user wallet.';

The pricing_model column is informational only — both row shapes populate the same per-token columns. Featherless rows get their rates synthesized from plan cost during catalog sync; Anthropic / OpenAI rows pull straight from the rate card.

package_free_trials — new table

CREATE TABLE IF NOT EXISTS package_free_trials (
    id SERIAL PRIMARY KEY,
    user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    package_id INTEGER NOT NULL REFERENCES packages(id) ON DELETE CASCADE,
    messages_used SMALLINT NOT NULL DEFAULT 0,
    started_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE(user_id, package_id)
);

COMMENT ON TABLE package_free_trials IS 'Per-user, per-package free-message counter. Incremented in the post-LLM stage for paid packages while the user is still in trial.';

web_message_stats — add columns

ALTER TABLE web_message_stats
    ADD COLUMN IF NOT EXISTS package_id INTEGER REFERENCES packages(id) ON DELETE SET NULL,
    ADD COLUMN IF NOT EXISTS paid_model_identifier VARCHAR(255),
    -- Token usage from the provider's `usage` object
    ADD COLUMN IF NOT EXISTS input_tokens INTEGER,
    ADD COLUMN IF NOT EXISTS output_tokens INTEGER,
    ADD COLUMN IF NOT EXISTS cached_tokens INTEGER,
    ADD COLUMN IF NOT EXISTS embedding_calls SMALLINT,
    -- Echo accounting for this message
    ADD COLUMN IF NOT EXISTS echo_total_charged INTEGER,        -- total debited from user (NULL = free / BYOK)
    ADD COLUMN IF NOT EXISTS echo_platform_cost INTEGER,        -- computed cost leg (model + embeddings)
    ADD COLUMN IF NOT EXISTS echo_creator_markup INTEGER,       -- gross markup before fee
    ADD COLUMN IF NOT EXISTS echo_creator_earned INTEGER,       -- creator's share of markup, credited to cashable
    ADD COLUMN IF NOT EXISTS echo_platform_fee INTEGER,         -- platform's share of markup
    ADD COLUMN IF NOT EXISTS echo_engagement_tip INTEGER,       -- engagement tip charged on this message (NULL = none active)
    ADD COLUMN IF NOT EXISTS echo_overrun_eaten INTEGER;        -- portion above max_charge_per_message that the platform absorbed

This row is the audit trail for the multi-leg charge. The five echo_* columns plus the engagement tip slot sum to the total platform + creator + tip flow.

echo_transactions — no schema change

Reuse the shipped ledger. The post-LLM charge is one batch (engagement-tip pattern) that writes multiple ledger rows atomically.

Row Direction Pool Notes
paid_message_charge Debit Spendable Single debit on the user's wallet equal to total_user_charge. Allocated pre-LLM, committed post-LLM.
paid_message_earnings Credit Cashable Creator's share (creator_markup × (1 - fee_rate)). Only credit type that lands in cashable.
paid_message_platform Credit Platform Platform's share — platform_cost_actual + (creator_markup - creator_earns). May be omitted in v1 if reconstructible from web_message_stats.
tip_sent / tip_received Debit / Credit Spendable / Persistent If the user has an active engagement standing order on this (character, mode), charged in the same batch. Existing types — engagement-tip pattern.

All ledger writes go through fn_debit_spendable / fn_transfer_spendable (functions/41i_echo_spend_helpers.sql). The orchestrator for paid messages is a new function fn_charge_paid_message modeled on fn_charge_engagement_tips — single call, multi-leg input, EchoSpendBatchOutcome result.

What does not need a schema change

What is not in v1


Pipeline Integration

Two new stages plug into IPreLlmStage / IPostLlmStage. The post-LLM stage uses a single multi-leg consolidated charge — same shape as fn_charge_engagement_tips, not a stack of separate ledger writes.

Pre-LLM: PaidPackageEstimateStage (IPreLlmStage)

1. Skip unless conversation is a paid-package conversation (package.is_paid) and the user
   has not switched this conversation to BYOK.
2. Resolve the model row from platform_model_costs by package.paid_model_identifier.
3. Check package_free_trials. If messages_used < free_trial_messages, mark trial=true; allocate 0☆.
4. Otherwise compute the estimate:
     est_input_tokens   = tokenize(prompt_so_far)           # context already built by an earlier stage
     est_output_tokens  = platform_model_costs.estimated_output_tokens
     est_embedding_cost = embedding_calls_made_during_context_build × embedding_rate
     est_platform_cost  = ceil((in_tok × in_rate + out_tok × out_rate + est_embedding_cost)
                              × margin × echoes_per_dollar)
     est_markup         = max(markup_amount, markup_percent × est_platform_cost / 100)
     est_engagement_tip = active engagement standing order amount (if any) on (character, mode)
     est_total          = min(est_platform_cost + est_markup, max_charge_per_message)
                        + est_engagement_tip
                        + overrun_buffer    # small safety margin, e.g. 20%

5. fn_debit_spendable(user_id, amount = est_total, intent = 'paid_message_charge',
                      status = 'allocated', reference = (package_id, message_id)).
   - On insufficient_balance → block with a paywall EchoSpendOutcome. Allocation never created.
6. Stash the allocation_id + the estimate breakdown on the pipeline context for the
   post-LLM commit.

The pre-LLM stage is purely about reservation. No commit, no creator credit, no audit row.

LLM call

Provider resolution routes the request to the hosted client (FeatherlessLlmClient with platform key for Featherless; equivalents for other hosted providers when added). See Hosted Inference via Featherless.ai for the routing logic. Embedding calls during context build (if any) are also counted on the pipeline context so the post-LLM stage knows the real number.

Post-LLM: PaidPackageChargeStage (IPostLlmStage)

1. If the LLM call failed:
     - Release the allocation via fn_release_allocation. No charge, no audit row.
     - Trial messages: nothing to release. Return.
2. If trial message:
     - Increment package_free_trials.messages_used. Return.
3. Compute real cost from the usage object:
     real_input_tokens  = usage.input_tokens
     real_output_tokens = usage.output_tokens
     real_cached_tokens = usage.cached_tokens (if provider returns it; cached rate optional)
     real_embed_cost    = total embedding cost from context build + post-LLM embeddings
     platform_cost      = ceil((tokens × rates + real_embed_cost) × margin × echoes_per_dollar)
     creator_markup     = max(markup_amount, markup_percent × platform_cost / 100)
     uncapped_total     = platform_cost + creator_markup
     capped_total       = min(uncapped_total, max_charge_per_message)
     overrun_eaten      = uncapped_total - capped_total       # platform absorbs

4. Look up active Project Slot on package's parent project → fee_rate (0.20 or 0.30).
   platform_fee_on_markup = floor(creator_markup × fee_rate)
   creator_earns          = creator_markup - platform_fee_on_markup
   platform_keeps         = platform_cost + platform_fee_on_markup - overrun_eaten

5. fn_charge_paid_message(allocation_id, legs = [
       { type: 'platform_cost',    amount: platform_cost },
       { type: 'creator_markup',   amount: creator_markup, recipient: package.owner_id },
       { type: 'engagement_tip',   amount: tip_amount, recipient: ... }   # if active
   ])
   This single function:
     - Commits the allocation up to capped_total + tip_amount (releases the rest of the buffer).
     - Writes the creator credit into cashable pool with type 'paid_message_earnings'.
     - Writes the platform credit (or omits, deriving from web_message_stats).
     - If engagement leg is present, fires the same fn_transfer_spendable path as fn_charge_engagement_tips.
     - All atomic; one EchoSpendBatchOutcome returned. Insufficient balance mid-batch raises
       SQLSTATE 40001 (the engagement-tip pattern) → caller translates to a clean batch error.

6. Write web_message_stats audit row with token counts, all echo_* legs, and overrun_eaten.

One charge per message, multiple legs. The user sees one transaction in their history ("8☆ for message X in Crystal of Dawn RPG"); drill-down on that transaction reveals the breakdown. The creator sees their earnings as one credit per message. The platform's audit table has the full per-leg accounting.

Why fn_charge_paid_message instead of separate functions

The engagement-tip implementation already proved the pattern: one orchestrator function, multi-leg input, atomic outcome, idempotency via partial unique index on the message_id before any ledger write. fn_charge_paid_message is the same pattern with different leg vocabulary. It also makes the "engagement tip on a paid message" case trivial — the engagement leg is just one entry in the legs array, processed by the same code path.

Stages are still two (estimate vs commit) because the allocation has to span the LLM call, but the commit-side primitive is one function, not three.

Failure modes

Failure Behavior
Insufficient balance pre-LLM Allocation never created. Message blocked. EchoSpendOutcome with insufficient_balance shown as paywall.
LLM call fails post-allocation fn_release_allocation returns Echoes to spendable. No charge, no creator credit, no audit row.
Real cost exceeds buffered allocation Possible only if the response massively overshot estimated_output_tokens. Capped at max_charge_per_message; overage is platform-eaten (echo_overrun_eaten on the audit row). User never charged more than the cap.
Mid-batch insufficient balance during multi-leg commit fn_charge_paid_message raises SQLSTATE 40001 (same as fn_send_tip_batch). Caller catches, releases allocation, returns clean batch error. No partial commit.
Engagement-tip leg auto-pause condition Engagement leg is skipped (recorded in skipped array), main paid charge still commits. Engagement preference moves to paused per existing engagement-tip semantics.
Post-LLM commit fails (e.g., DB error after success) Retry with idempotency key; if retries exhausted, the allocation drops to expired on the snapshot run and the user is held harmless. Operational alert.
Model became unavailable mid-conversation New messages blocked with a "model unavailable" error and a prompt to switch to BYOK. Existing in-flight allocations release cleanly.
Rate card update mid-conversation Existing in-flight messages commit at the rates loaded into the pipeline context for that message; subsequent messages use the new rates. No retroactive repricing.
Embedding cost spikes (e.g., reindex job during message) Capped by the max_charge_per_message ceiling — same overrun handling. The embedding leg is computed from the embedding-calls counter on the pipeline context, so platform observability sees the spike.

API

All endpoints return JSON; response shapes use camelCase (JsonNamingPolicy.CamelCase, not the .NET 10 default — see CLAUDE.md).

Echo balance (shipped — shape reference)

GET /api/echoes/balance
→ { available, spendingFirst, resetsAt, claimableTaskCount }

This is what shipped. Earlier drafts of this doc showed a different shape — disregard.

Package pricing (new)

PUT /api/packages/{id}/pricing
Body: {
  "isPaid": true,
  "modelIdentifier": "featherless/mistral-nemo-rp",
  "creatorMarkupAmount": 5,           // flat ☆/msg (optional if percent set)
  "creatorMarkupPercent": 0           // percent of platform_cost (optional; min still enforced via amount)
}

Validates:
- Caller owns the package or has can_manage on the parent project
- Caller is a Verified Creator
- Package is published
- Character + mode are locked
- modelIdentifier exists in platform_model_costs with is_available = TRUE
- creatorMarkupAmount >= 0 AND creatorMarkupPercent >= 0
- At least one of (markupAmount, markupPercent) > 0

Returns: {
  packageId,
  isPaid,
  modelIdentifier,
  creatorMarkupAmount,
  creatorMarkupPercent,
  estimatedPlatformCost,          // typical-message platform-cost in ☆
  estimatedUserPrice,             // typical-message total in ☆ (what listings will show)
  projectedCreatorEarnings,       // typical-message creator share in ☆
  paidEnabledAt
}

Uses the surgical-update convention — omitting a field means "don't change."

Hosted-model catalog (new)

GET /api/packages/models
→ [
    {
      "identifier": "featherless/mistral-nemo-rp",
      "displayName": "Mistral Nemo RP (hosted)",
      "provider": "featherless",
      "tier": "medium",
      "typicalPlatformCost": 3,        // Echoes for a representative message (catalog UI hint)
      "maxChargePerMessage": 30,
      "isAvailable": true
    },
    ...
  ]

typicalPlatformCost is ceil((typical_input_tokens × in_rate + estimated_output_tokens × out_rate) × margin × echoes_per_dollar) — a stable representative number for the picker UI, not the actual commit charge. Refreshed when rates change.

Cached server-side (15-min TTL, conservative — tighten after production verification per project's caching policy).

Creator earnings (new)

GET /api/echoes/earnings
→ {
    "cashableBalance": 8420,
    "lifetimeEarned": 42000,
    "lifetimeWithdrawn": 32380,
    "byPackage": [
      { "packageId": 12, "name": "Crystal of Dawn RPG", "earned": 28000, "paidMessages": 4000 },
      { "packageId": 34, "name": "Detective Noir",       "earned": 14000, "paidMessages": 1400 }
    ]
  }

cashableBalance is the cashable-pool slice of the creator's ledger. lifetimeWithdrawn requires the payout / withdraw flow (v2).

Echo purchase (still blocked)

POST /api/billing/echoes/purchase — design preserved for whichever processor accepts us. The webhook → fn_credit_monetary_purchase path is already wired; only the front-of-house checkout step is missing. Interim: gift codes.

Creator withdraw (v2)

POST /api/billing/echoes/withdraw — defers until both (a) a meaningful number of creators have non-trivial cashable balances and (b) a payout rail is feasible. Wise manual is the realistic v2 starting point.


Interaction with Existing Systems

Packages

Pricing is an additive layer — the same package entity, six new columns, no new entity type. All existing package features (components, locks, chapters, events, model profiles) work unchanged. For paid mode the paid_model_identifier overrides any BYOK model profile when the user is not on the BYOK path; profiles remain authoritative for BYOK conversations.

Subscriptions

Subscriptions are orthogonal to paid experiences. Pro and Premium are recurring Echo grants (see Tiers & Limits) — they make Echoes cheaper to acquire, not free. A Premium user pays Echoes for paid messages the same as a free user. This shipped exactly as designed; see fn_grant_subscription_echoes.

Project Slots

The active Project Slot system already underlies the 30% → 20% fee discount. Lookup happens at commit time, not at package-publish time — if a creator assigns a slot to a project mid-month, every subsequent message charges at the discounted rate.

Creator Tips integration

Creator Tips (one-time + per-message engagement, internal design at docs-internal/architecture/billing/CREATOR_TIPS.md) shipped and superseded the "Voluntary BYOK Support" section that used to live here. Concretely:

Paid messages and engagement tips can coexist on the same message: a user in a paid conversation can also have an active engagement-tip standing order, and both fire (paid charge first, then engagement charge). The two land in different pools (cashable vs spendable), which is fine — they're conceptually separate channels.

Feature Commitments

Feature Commitments (slice 2E) are orthogonal — they're about users committing Echoes to platform feature tiers (gallery retention, etc.), not creator-to-user transfer. They share the fn_debit_spendable primitive; that primitive is the right tool for paid-message debits too.

Hosted inference (Featherless and successors)

Paid experiences depend on hosted models being available. See Hosted Inference via Featherless.ai for the first provider integration. Both per-token and flat-subscription providers feed the same per-token columns in platform_model_costs — subscription rates are synthesized from monthly_cost × margin / expected_tokens / 1M during catalog sync.

Embeddings

Embeddings are billed two ways depending on context:

Both paths read the embedding rate from the same place — either the per-model row's embedding_rate_usd_per_call or a platform-default embedding cost in settings — so the rate is consistent regardless of where embeddings get triggered.


Implementation Order

Reuse-first. Each step ships independently.

v1 — minimum paid experience

  1. Schema — platform_model_costs, package_free_trials, packages paid columns, web_message_stats paid columns. All idempotent ALTERs through v1_run_all.sql.
  2. Seed platform_model_costs — start with one hosted Featherless model in tier medium with a hand-picked echo_floor. Per-token providers added later.
  3. Pricing API — PUT /api/packages/{id}/pricing, GET /api/packages/models. Validation + Verified Creator gate.
  4. Pipeline stages — PaidPackageBalanceCheckStage, PaidPackageChargeStage. Allocation / commit / release on the existing ledger.
  5. Client UI — paid toggle + pricing form in the package workbench; paywall card in chat; balance pill in chat header; gift-code redemption is the buy-Echoes path until hosted checkout exists.
  6. Free trial — package_free_trials write path in the charge stage.
  7. Earnings read — GET /api/echoes/earnings for the creator dashboard.

v2 — quality & trust

  1. Ratings — package_ratings, eligibility (10+ paid messages), auto-delist threshold.
  2. AWOL detection — inactivity timeline + auto-suspend.
  3. Creator deposit — if Verified-Creator-only proves too restrictive at scale, add the deposit alternative for unverified creators.
  4. Creator payout — Wise manual to start, hosted rail when available.
  5. Pricing model expansion — add per-token providers (Anthropic / OpenAI / OpenRouter) once Featherless has proven the floor mechanic at production volume.

Blocked / external dependency


Mid-Conversation Scenarios

User runs out of Echoes

Conversation pauses on the next paid message. History preserved. User tops up (gift code today; purchase rail later) or switches to BYOK for that conversation.

Creator changes price mid-package

Existing conversations keep the price active when they started — locked at conversation-start time so a user mid-RPG doesn't get repriced. New conversations use the new price. The "active at conversation start" snapshot lives on the conversation row (or, simpler, the first paid-message stats row is the source of truth).

Creator disables paid mode

Existing paid conversations become free. Users keep their history and continue without charge. Creator earns nothing on future messages in those conversations.

Model becomes unavailable

Two cases:

Floor raised above creator price

Paid mode auto-suspends on the next message. Existing in-flight conversations grace-period out. Creator notified to raise their price.


Future Extensions

Ratings (v2)

package_ratings (1-5 star, eligibility after 10+ paid messages, one rating per (user, package), auto-delist at <2.5 stars with 50+ ratings). Detailed mechanics preserved from the previous revision of this doc — call out to the future-extensions ticket when v1 ships.

Creator deposit (v2)

For unverified creators who want to monetize without the admin verification queue. Refundable on verification, forfeited on ban. Skipped in v1 because the Verified Creator gate is simpler and we don't have evidence yet that the verification queue is a bottleneck.

AWOL detection (v2)

30 / 60 / 90 / 180-day inactivity timeline with auto-suspend at 60d and earnings forfeiture at 180d. Out of scope for v1 — small creator population, problem hasn't materialized yet.

Per-token hosted providers (v2)

Anthropic, OpenAI, OpenRouter via platform-held keys. platform_model_costs.pricing_model = 'per_token' already distinguishes them. The floor is computed from per-token rates × expected message length × margin. Same flat echo_floor ends up on the row — the calculation differs but the consumer doesn't care.

Hosted checkout for Echo purchase

Blocked on processor acceptance. The monetary_purchases + fn_credit_monetary_purchase rail is built and provider-agnostic.

Volume discounts, bundles, dynamic pricing, referral Echoes

Future explorations. None of them belong in v1.

Discovery & marketing

Featured paid experiences, category rankings, creator discount codes, hub algorithm tuning — all live in the Hub docs, not here. Paid experiences plug into whatever those systems become.

Suggested engagement-tip amount per package

A small packages.suggested_engagement_tip column that pre-fills the engagement-tip slider in the tip modal when a user is in a paid (or BYOK) conversation on that package. Cheap to add, not urgent.