Alert when a pricing_skus rate moves: a nightly diff of the model list

Save GET /v1/videos/models rates each night and diff them. A one-cent-per-second move costs $0.30 on a 30 s clip and $300 over 1,000 of them. Python, 25 lines.

4 min readSume
All posts

A rate change in pricing_skus is invisible until the invoice, unless a nightly job compares today's GET /v1/videos/models with yesterday's file. A one-cent-per-second move costs $0.30 on a 30 s clip and $300 across 1,000 of them, which is enough to notice.

What a move is worth

The table is arithmetic on a hypothetical $0.01 per second move, to size the alert threshold. It is not a statement that any price is changing.

Compare per-second rates as Decimal strings, and report a new or missing key the same way as a changed one.

Impact of a $0.01 per second rate move (read 2026-10-09)
Clip lengthPer clip1,000 clips10,000 clips
5 s$0.05$50$500
10 s$0.10$100$1,000
15 s$0.15$150$1,500
30 s$0.30$300$3,000

The diff

Run it from cron or a scheduled workflow. The first run writes the baseline and exits.

import json, os, pathlib
import requests

FILE = pathlib.Path("rates.json")
r = requests.get(
    "https://api.sume.com/v1/videos/models",
    headers={"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"},
    timeout=30,
)
r.raise_for_status()
now = {
    f"{m['id']}/{k}": v
    for m in r.json()["data"]
    for k, v in m["pricing_skus"].items()
}
old = json.loads(FILE.read_text()) if FILE.exists() else None
FILE.write_text(json.dumps(now, indent=1, sort_keys=True))
if old is not None:
    for key in sorted(set(old) | set(now)):
        if old.get(key) != now.get(key):
            print(f"{key}: {old.get(key)} -> {now.get(key)}")

Gotchas

A model that disappears from the list may only mean its provider is not configured, not that it was retired, so alert on it at a lower severity. The catalog's created field is the same constant for every model, so do not use it to spot new releases.

Commit rates.json to a private repo or an artifact store, so the history of changes is kept.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume