Skip to content

pricing

pricing

Cost computation for agentic eval runs — wraps engine/cloud.py pricing.

Functions:

estimate_cost

estimate_cost(
    model: str, prompt_tokens: int, completion_tokens: int
) -> float

Estimate USD cost based on the hardcoded pricing table.

Source code in src/diapason/engine/cloud.py
def estimate_cost(model: str, prompt_tokens: int, completion_tokens: int) -> float:
    """Estimate USD cost based on the hardcoded pricing table."""
    prices = resolve_pricing(model)
    if prices is None:
        # 0.0 is what the callers' ``cost_usd`` field has always carried for
        # an unpriced model, and it is indistinguishable from a free local
        # run. Keep the value — a dozen call sites and the telemetry schema
        # depend on the float — but stop it being silent.
        logger.warning(
            "No pricing entry for model %r: reporting $0.00, which is not the "
            "same as free. Add it to PRICING to bill it.",
            model,
        )
        return 0.0
    input_cost = (prompt_tokens / 1_000_000) * prices[0]
    output_cost = (completion_tokens / 1_000_000) * prices[1]
    return input_cost + output_cost

compute_turn_cost

compute_turn_cost(
    model: str, input_tokens: int, output_tokens: int
) -> float

Compute USD cost for a single agent turn.

Delegates to the canonical estimate_cost() from engine/cloud.py. Returns 0.0 for models not in the pricing table (e.g. local models).

Source code in src/diapason/evals/core/pricing.py
def compute_turn_cost(model: str, input_tokens: int, output_tokens: int) -> float:
    """Compute USD cost for a single agent turn.

    Delegates to the canonical ``estimate_cost()`` from ``engine/cloud.py``.
    Returns 0.0 for models not in the pricing table (e.g. local models).
    """
    return estimate_cost(model, input_tokens, output_tokens)