---
referrals: 3
kind: program
payer: domain:model.example
code: example_model
category: ai_native
status: open
at: 2026-10-30T00:00:00Z
net_of: tax
crit: accrual_scale
---
# Example model provider gateway share

Rates, amounts and names in this file are placeholders, not recommendations or market rates. Each party sets its own terms.

In plain words: a model gateway that routes calls here earns 7% of net revenue on those calls, for 12 months per customer. Amounts keep six decimal places, so tiny reports don't round to zero.

Change first: `payer`, `code`, the rate and the months. A statement rounds what can be paid down to the cent, and the rest stays in its closing balance.

## Rules

### routed_share

- on: usage
- basis: percent
- rate: 7%
- of: net
- recurring.months: 12

## Attribution

- model: last_touch
- window_days: 30
- allowed_kinds: model_route
- token.signed: signed

## Settlement

- holdback_days: 30
- clawback_days: 60
- cycle: monthly
- accrual_scale: 6
- payout_asset: USD
- rails: ach

## Example

Made-up lines. Three small daily rollups. Rounded to cents, the first would be 0.03, the second 0.01 and the third 0.08, which is 0.12 in all. Kept at six places, the total is exact, and the same on both sides. A gateway sends the token in a `Referrals-Token` header. Its signature uses the public test key in `/vectors.json`, so it says nothing.

To run it, save this file as `REFERRALS.md` and these lines as `referrals.jsonl`, then run `node referrals.mjs run REFERRALS.md referrals.jsonl --as-of 2027-01-15T00:00:00Z`.

As of: 2027-01-15T00:00:00Z

```jsonl
{"type":"agreement","code":"gateway","partner":"domain:gateway.example"}
{"type":"event","at":"2026-11-02T00:00:00Z","kind":"usage","source":"meter:day_1101","customer":"cu_e7f8091a2b3c4d5e","amount":"0.37","net":"0.37","asset":"USD","units":{"tokens":"48000"},"carrier":"http_header","token":"rf1.example_model.gateway.r7m2t.tnt7c0.dog.h.dDYrebTW-0QwpSK-JmSDYw"}
{"type":"event","at":"2026-11-03T00:00:00Z","kind":"usage","source":"meter:day_1102","customer":"cu_e7f8091a2b3c4d5e","amount":"0.19","net":"0.19","asset":"USD","units":{"tokens":"25000"}}
{"type":"event","at":"2026-11-04T00:00:00Z","kind":"usage","source":"meter:day_1103","customer":"cu_e7f8091a2b3c4d5e","amount":"1.13","net":"1.13","asset":"USD","units":{"tokens":"147000"}}
```

## Worked result

Computed by `run_ledger` as of 2027-01-15T00:00:00Z, on the made-up lines above. Computed amounts are arithmetic on the records and terms you sent. They do not say what anyone owes. Your contract decides that.

| Event | Who | Working | Computed | Note |
|---|---|---|---|---|
| usage, 2026-11-02 | gateway | 7% of 0.37 | 0.025900 |  |
| usage, 2026-11-03 | gateway | 7% of 0.19 | 0.013300 |  |
| usage, 2026-11-04 | gateway | 7% of 1.13 | 0.079100 |  |

| Payee | Asset | Earned | Reversed | Net | Held | Payable |
|---|---|---|---|---|---|---|
| gateway | USD | 0.118300 | 0.000000 | 0.118300 | 0.000000 | 0.110000 |


## Why these settings

`accrual_scale` is what makes a share of per-request revenue computable at all, and listing it in `crit` makes an engine without the feature refuse rather than round everything to zero.
