Check your predicted cost against usage.cost when a Sume video ends

Compare your own price prediction with the usage.cost on a completed Sume job and flag drift. A 20-line Python check, tested on three sample polls.

3 min readSume
All posts

A completed GET /v1/videos/{id} response carries usage.cost. Comparing it with what you predicted before submitting catches a stale rate table, a wrong resolution mapping or a changed price on the day it happens, instead of at month end.

Only compare on completed. A job in pending or in_progress has no final cost, and a failed or cancelled one is a different question. The check returns a plain string, and a tolerance of 0.0005 dollars absorbs rounding in how the amount is printed.

The check

It predicts a Seedance 2.5 clip with the same token formula as the estimator, then compares. Run on a sample 720p 5 s poll, it printed match; with usage.cost set to 3.1 it printed DRIFT predicted 2.889 billed 3.1; with an in-progress poll it printed not completed yet. These are sample payloads, not live ones.

import math
DIMS = {"480p": (496, 864), "720p": (720, 1280), "1080p": (1080, 1920)}

def predict_usd(res, secs):
    w, h = DIMS[res]
    rate = 23400 if res == "1080p" else 21400
    tokens = math.ceil(w * h * secs * 24 / 1024)
    return math.ceil(math.ceil(tokens * rate / 1000) * 1.25) / 1e6

def check(poll, res, secs, tolerance=0.0005):
    if poll["status"] != "completed":
        return "not completed yet"
    actual = poll["usage"]["cost"]
    want = predict_usd(res, secs)
    return "match" if abs(actual - want) <= tolerance else f"DRIFT predicted {want} billed {actual}"

done = {"status": "completed", "usage": {"cost": 2.889}}
print(check(done, "720p", 5))
print(check({**done, "usage": {"cost": 3.1}}, "720p", 5))
print(check({"status": "in_progress"}, "720p", 5))

What to do on drift

Log the model, resolution, duration, predicted and billed numbers, stop showing the old estimate, and read the current pricing doc before changing the table. Do not auto-correct your estimator from the billed number, because that hides the change you wanted to see.

Sources

Related posts

More in Pricing

All Pricing posts

Written by Sume