Granular Billing
Read per-Sprite CPU and memory usage down to the second, and turn it into cost.
On this page
What it is
Sprites records how much CPU time and memory every Sprite uses, and lets you query it through the API at intervals as fine as one second. You get usage for each Sprite, not just one bill for your organization.
Why it matters:
- See exactly what each workload costs.
- Attribute spend to your own customers, for example one Sprite (or cluster) per customer.
- Bill your users on what they actually consumed.
Reading usage never wakes a Sprite, and Sprites you’ve since deleted are still included while their history is kept.
What gets measured
Each usage record contains:
| Field | Meaning |
|---|---|
cpu_time_sec | CPU time consumed, in seconds. |
reserved_memory_byte_sec | Reserved RAM in bytes, multiplied by time in seconds. |
sprite_ref | CLUSTER/NAME, when you ask about one Sprite or group by Sprite. |
start, end | Bucket boundaries in UTC. The last bucket may be shorter than the interval. |
last_recorded_at | Latest observation in the bucket, or null. |
Missing observations count as zero usage.
Step by step: per-Sprite usage
1. Create a usage-only token
Use a dedicated token with only the usage.read privilege for usage queries and dashboards. Use your full-access token just to create it:
curl -sS -X POST "https://api.sprites.dev/v1/tokens" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" -d '{
"description": "usage dashboard", "privileges": ["usage.read"]}'
Save the returned token in its own variable. The usage examples below send it as Authorization: Bearer $USAGE_TOKEN:
export USAGE_TOKEN=... # the token from the response
Don’t set Sprite restrictions such as name_prefix or label on this token, even if you only plan to query one Sprite.
2. Get your organization’s total
ssh my-org@sprites.dev usage --start 2026-10-01T00:00:00Z --interval 1d
# HTTP API
curl -sS -G "https://api.sprites.dev/v1/usage" -H "Authorization: Bearer $USAGE_TOKEN" \
--data-urlencode "start=2026-10-01T00:00:00Z" \
--data-urlencode "end=2026-10-02T00:00:00Z"
3. Break it down by Sprite
ssh my-org@sprites.dev usage --group-by sprite
# HTTP API: hourly usage for each Sprite.
curl -sS -G "https://api.sprites.dev/v1/usage" -H "Authorization: Bearer $USAGE_TOKEN" \
--data-urlencode "start=2026-10-01T00:00:00Z" \
--data-urlencode "end=2026-10-02T00:00:00Z" \
--data-urlencode "interval=1h" \
--data-urlencode "group_by=sprite"
4. Zoom in on one Sprite
ssh my-org@sprites.dev usage worker --interval auto
# HTTP API: a Sprite in the "builds" cluster.
curl -sS -G "https://api.sprites.dev/v1/usage/worker" -H "Authorization: Bearer $USAGE_TOKEN" \
--data-urlencode "cluster_id=builds" \
--data-urlencode "interval=auto" \
--data-urlencode "start=2026-10-01T00:00:00Z" \
--data-urlencode "end=2026-10-02T00:00:00Z"
For a Sprite outside the default cluster, pass cluster_id as a query parameter. Don’t put CLUSTER/NAME in the URL path.
5. Find which Sprites had usage
To list every Sprite (including deleted ones) that recorded usage in a period:
curl -sS -G "https://api.sprites.dev/v1/usage/filters/sprites" \
-H "Authorization: Bearer $USAGE_TOKEN" \
--data-urlencode "start=2026-10-01T00:00:00Z" \
--data-urlencode "end=2026-10-02T00:00:00Z"
It returns start, end, and a sorted sprite_refs list.
Query parameters
| Parameter | Details |
|---|---|
start | Required for HTTP. ISO 8601 with a timezone, inclusive. The SSH command defaults to one day before end. |
end | Exclusive. Defaults to now. Must be after start and not in the future. |
interval | Omit for one total. Otherwise a duration like 1s, 5m, 1h, 1d (at least one second), or auto to pick the finest interval that fits. |
group_by | sprite on /usage for a per-Sprite breakdown. |
cluster_id | On /usage/NAME; defaults to default. |
Turning usage into cost
Get the list prices (US dollars, as decimal strings):
ssh my-org@sprites.dev pricing
This returns cpu_price_per_hour, ram_price_per_gb_hour (a GB is 10⁹ bytes) and storage_price_per_gb_month. Estimated compute cost is:
cpu_time_sec / 3600 * cpu_price_per_hour
+ reserved_memory_byte_sec / 1e9 / 3600 * ram_price_per_gb_hour
This is an estimate before plan credits.
Example: cost per Sprite for yesterday
CPU=0.07 # fill in from `pricing`
RAM=0.04 # fill in from `pricing`
curl -sS -G "https://api.sprites.dev/v1/usage" -H "Authorization: Bearer $USAGE_TOKEN" \
--data-urlencode "start=$(date -u -d yesterday +%Y-%m-%dT00:00:00Z)" \
--data-urlencode "end=$(date -u +%Y-%m-%dT00:00:00Z)" \
--data-urlencode "group_by=sprite" |
jq -r --argjson cpu "$CPU" --argjson ram "$RAM" '
.usage[]
| [.sprite_ref,
((.cpu_time_sec / 3600 * $cpu)
+ (.reserved_memory_byte_sec / 1e9 / 3600 * $ram))]
| @tsv'
Attributing cost to customers: usage history is keyed by CLUSTER/NAME. Give each customer their own Sprite names (for example cust-42-worker) or their own cluster, and per-Sprite usage becomes per-customer usage. Reusing a name combines its history with the old Sprite’s, so avoid recycling names if you need clean per-customer records.
Live usage from a running Sprite
The queries above read recorded history. For a live sample from a running Sprite (or just its status if it’s stopped):
ssh -T my-org@sprites.dev sprite usage dev --follow | jq
Grafana dashboards
The usage API works with Grafana’s Infinity data source:
- Set the base URL and allowed host to
https://api.sprites.dev. - Use Bearer token authentication with your
usage.readtoken. - Create a GET query with URL
/v1/usageand these parameters:start=${__timeFrom:date:iso}end=${__timeTo:date:iso}interval=auto
- Choose the JSON parser with the JQ backend and set the root selector to
.usage. - Add
startas a Time column, andcpu_time_secandreserved_memory_byte_secas Number columns. - To split by Sprite, add
group_by=spriteand asprite_refString column.
Limits and errors
- At most 1,000 time buckets and 10,000 rows per query; beyond that you get
422 usage_query_too_large. Useinterval=auto, a larger interval, a shorter period, or a single Sprite. - 120 usage reads per minute and 8 concurrent per organization (HTTP and SSH combined), then
429. 404 sprite_not_foundfor a Sprite with no history;403if the token lacks access.400 invalid_intervalfor an interval under one second;400 invalid_time_rangefor a bad range or a timestamp without a timezone.- With
group_by=sprite, Sprites with no usage in the period appear with zero values.