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/openjarvis/engine/cloud.py
def estimate_cost(model: str, prompt_tokens: int, completion_tokens: int) -> float:
    """Estimate USD cost based on the hardcoded pricing table."""
    # Try exact match first, then prefix match
    prices = PRICING.get(model)
    if prices is None:
        for key, val in PRICING.items():
            if model.startswith(key):
                prices = val
                break
    if prices is None:
        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/openjarvis/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)