gleamunison/llm_settlement

One settlement boundary for LLM budget bookkeeping.

Admission happens before the provider call; this module owns everything after it. Both the ambient completion path and handler middleware release the slot once, then record the same success/failure sequence. Backend refusals are values, never assertions that crash a completed provider call.

Values

pub fn failure(provider: String) -> Result(Nil, String)
pub fn release(provider: String) -> Result(Nil, String)
pub fn report(outcome: Result(Nil, String)) -> Nil

Reporting for callers that already hold a result they must not discard. A handler that returns a real completion cannot also return a bookkeeping error, so the failure goes to stderr: visible, never a crash, never a silently dropped value.

pub fn success(
  provider: String,
  tokens: Int,
  cost_micro_usd: Int,
) -> Result(Nil, String)
✨ Search Document