DIM · Dagon Inference Marketplace

Price schedule

Each route in a seller's listing carries one price schedule. Buyers bind every request to it: the Hold and the receipt both carry its schedule_digest, so the seller cannot reprice a request after admitting it.

Document

Member Type Rule
v integer 1
currency string "USDC"
unit string "micro-USDC"
rates_per_mtok.input integer micro-USDC per million uncached input tokens
rates_per_mtok.cached_input integer micro-USDC per million cached input tokens
rates_per_mtok.output_visible integer micro-USDC per million visible output tokens
rates_per_mtok.output_hidden integer micro-USDC per million hidden (reasoning) output tokens
per_request_fee integer micro-USDC added once per billable request
w_req_micros integer smallest cap_micros the gateway accepts; a lower cap is refused with 402 cap_too_low (A5)
ack_timeout_ms integer 5000; informational in the MVP, which has no streaming acknowledgments
ttft_max_ms integer if no first token arrives within this many milliseconds, the gateway aborts and issues a failed receipt (charge 0)
failure_billing string "none"
effective_from integer Unix seconds; the gateway refuses Holds for this schedule before then (402 schedule_mismatch)

All integers follow the JSON rule: 0 to 2^53 − 1. The reference gateway rejects any other value of v, currency, unit, ack_timeout_ms or failure_billing at startup.

schedule_digest = SHA256(jcs(schedule)). The fixture schedule and its digest:

{
  "v": 1,
  "currency": "USDC",
  "unit": "micro-USDC",
  "rates_per_mtok": {
    "input": 1200001,
    "cached_input": 200003,
    "output_visible": 2500001,
    "output_hidden": 4000021
  },
  "per_request_fee": 7,
  "w_req_micros": 100,
  "ack_timeout_ms": 5000,
  "ttft_max_ms": 3000,
  "failure_billing": "none",
  "effective_from": 1700000000
}

schedule_digest of this document: aad28e30b14004cd01f3c9bc3ffa3b439e3cca202f19aa0c0ca8d7c10921063e.

<sub>Generated from crates/im-protocol/vectors/v1.json.</sub>

Charge

The charge is integer arithmetic with one rounding step. With in, cached, outv and outh the receipt's usage counts and r_* the schedule's rates:

cached  = min(cached, in)
charge  = ceil(((in − cached)·r_in + cached·r_cached + outv·r_outv + outh·r_outh) / 1_000_000) + per_request_fee

Intermediates are computed in 128 bits; a charge that does not fit in a u64 is an error, not a cap.

How the outcome changes the charge:

Receipt status Charged
ok the full formula
cancelled input terms and per_request_fee only; output tokens are not billed
failed, not_served, policy_unhonored 0

The gateway then writes charge_micros = min(charge, cap_micros) into the receipt: the seller absorbs anything above the buyer's cap. If the formula overflows, the reference gateway issues a failed receipt with charge 0 (A25′).

A gateway may also bill output tokens it actually forwarded before a cancel, but never tokens it did not forward (ADR 0003). The reference gateway bills cancelled requests input plus fee only.

Worked cases

These are the shared charge vectors; every implementation must produce the same results.

Case Status Usage in / cached / out visible / out hidden Rates per Mtok Fee Charge
ok_full ok 11 / 5 / 12 / 3 1200001 / 200003 / 2500001 / 4000021 7 58
cached_greater_than_input ok 3 / 100 / 2 / 0 1200001 / 200003 / 2500001 / 4000021 7 13
round_only_once ok 2 / 1 / 1 / 1 1 / 1 / 1 / 1 0 1
cancelled_input_and_fee_only cancelled 11 / 5 / 18446744073709551615 / 18446744073709551615 1200001 / 200003 / 2500001 / 4000021 7 16
failed_skips_fee_and_overflow failed 18446744073709551615 / 0 / 18446744073709551615 / 18446744073709551615 9007199254740991 / 9007199254740991 / 9007199254740991 / 9007199254740991 9007199254740991 0
not_served not_served 11 / 5 / 12 / 3 1200001 / 200003 / 2500001 / 4000021 7 0
policy_unhonored policy_unhonored 11 / 5 / 12 / 3 1200001 / 200003 / 2500001 / 4000021 7 0
u64_overflow ok 18446744073709551615 / 0 / 0 / 0 9007199254740991 / 0 / 0 / 0 0 rejected (ChargeOverflow)
u64_overflow_after_summing ok 18446744073709551615 / 0 / 18446744073709551615 / 0 1000000 / 0 / 1000000 / 0 0 rejected (ChargeOverflow)
fee_overflow ok 18446744073709551614 / 0 / 0 / 0 1000000 / 0 / 0 / 0 2 rejected (ChargeOverflow)
max_u64 ok 18446744073709551614 / 0 / 0 / 0 1000000 / 0 / 0 / 0 1 18446744073709551615
invalid_json_fee failed 0 / 0 / 0 / 0 0 / 0 / 0 / 0 9007199254740992 rejected (JsonNumber)

<sub>Generated from crates/im-protocol/vectors/v1.json.</sub>