Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

449 B
Raw Blame
from decimal import Decimal

SIGNALS_CREDITS_PER_DOLLAR = 100


def cost_to_spend(token_cost_microusd: int, *, task_count: int = 0) -> Decimal:
    """Customer spend in USD cents: token cost plus four cents per task run."""
    if token_cost_microusd < 0 or task_count < 0:
        raise ValueError("Cost and task count must be nonnegative")
    return Decimal(token_cost_microusd) * SIGNALS_CREDITS_PER_DOLLAR / 1_000_000 + Decimal(4) * task_count