botanu-sdk-python icon indicating copy to clipboard operation
botanu-sdk-python copied to clipboard

Carry ISO 4217 currency with cost and value so multi-currency customers aren't silently priced in USD

Open dhyabi2 opened this issue 1 month ago • 0 comments

Carry ISO 4217 currency with cost and value so multi-currency customers aren't silently priced in USD

Problem statement

botanu's pitch is "the real cost of your AI features per customer" and outcome-based pricing, but the cost and value model is USD-only by naming convention, with no ISO 4217 currency carried anywhere.

  • Cost attributes are denominated by a _usd suffix: resource_enricher.py prices non-LLM spans into cost_infra_usd (and LLM pricing goes through pricing_model_tokens), so the cost worker's whole rate-card model is USD-denominated with no currency field.
  • RunOutcome.value_amount (the quantified business value of an outcome, e.g. tickets resolved) is a bare float with no currency — run_context.py emits it as botanu.outcome.value_amount with no denomination.
  • RunContext/RunOutcome carry cost_center and region but no currency, so a multi-currency customer (EU billing in EUR, JP in JPY) has no way to represent cost or value in their own currency.

The result: a customer whose provider bills in EUR or JPY gets cost and value figures that are silently treated as US dollars — wrong in denomination, which is exactly the kind of error that undermines "real cost per customer".

Proposed solution

Additive, no behavior change for USD-only users:

  1. Add an optional currency (ISO 4217, default "USD") to the cost/value model:
    • RunOutcome gains value_currency: str = "USD"; run_context.py emits botanu.outcome.value_currency alongside value_amount.
    • The cost worker's rate cards and the emitted cost attributes (cost_infra_usd, etc.) gain an optional companion currency attribute, defaulting to "USD".
  2. Keep the _usd names for backward compatibility (or add cost_infra_currency as the companion) so existing dashboards don't break.
  3. Document that cost/value are USD unless a *_currency attribute says otherwise.

Why it matters

botanu correlates every run to an event_id and customer_id to give per-event cost attribution and outcome tracking — the foundation for outcome-based pricing. If cost and value are USD-only by convention, a non-USD customer's numbers are wrong in denomination, which breaks the "real cost per customer" promise. Carrying the currency makes the number honest without requiring conversion.

Alternatives considered

  • Currency conversion to USD in the SDK: rejected — conversion is a backend/collector concern and would add drift; the ask is only to carry the currency so the denomination is explicit.
  • A global BOTANU_CURRENCY env var: insufficient — different customers/providers within one deployment can price in different currencies, so the currency belongs on the per-run cost/value attributes.

This is a small, additive change to run_context.py, span_helpers.py, and the resource enricher's cost attributes, plus tests in tests/unit/. Happy to open a PR if this direction is welcome.

dhyabi2 avatar Nov 02 '26 00:11 dhyabi2