"""One AI credit pool per organisation, one rate table, one ledger.

Every GalaxiQ product calls the same two things around a model call: may_spend before, record after. The
product sends what ran (model key, type of work, raw units); the platform prices it from ai_model_rates and
takes it off the organisation's pool for the billing period. No product ever computes a cost.

    credits = Credits(platform_dsn, tenant_dsn, product="EdgeIQ", tell_owners=...)
    decision = credits.may_spend(tenant_id, feature="popup_copy", type="text", model_key="gpt-4o",
                                 input_estimate=2000, output_estimate=400)
    ...call the model...
    charge = credits.record(decision.reservation_id, call_id, tenant_id, feature="popup_copy", type="text",
                            model_key="gpt-4o", input_units=1812, cached_input_units=300, output_units=463)

or, around a callable that returns something carrying `.usage`:

    resp = metered(credits, tenant_id, feature="popup_copy", type="text", model_key="gpt-4o",
                   call=lambda: client.chat.completions.create(...), input_estimate=2000, output_estimate=400)
"""
from .client import Credits, Refused, org_schema
from .metered import metered
from .schema import ensure_rates_table, ensure_tables, ensure_tenant_tables
from .types import Charge, Decision, Period, Rate

__all__ = ["Credits", "Refused", "metered", "ensure_tables", "ensure_rates_table", "ensure_tenant_tables", "org_schema", "Charge", "Decision", "Period", "Rate"]
