✦ Sprites 2 Docs

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:

FieldMeaning
cpu_time_secCPU time consumed, in seconds.
reserved_memory_byte_secReserved RAM in bytes, multiplied by time in seconds.
sprite_refCLUSTER/NAME, when you ask about one Sprite or group by Sprite.
start, endBucket boundaries in UTC. The last bucket may be shorter than the interval.
last_recorded_atLatest 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
Watch out

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"
Note

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

ParameterDetails
startRequired for HTTP. ISO 8601 with a timezone, inclusive. The SSH command defaults to one day before end.
endExclusive. Defaults to now. Must be after start and not in the future.
intervalOmit 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_bysprite on /usage for a per-Sprite breakdown.
cluster_idOn /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'
Tip

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:

  1. Set the base URL and allowed host to https://api.sprites.dev.
  2. Use Bearer token authentication with your usage.read token.
  3. Create a GET query with URL /v1/usage and these parameters:
    • start = ${__timeFrom:date:iso}
    • end = ${__timeTo:date:iso}
    • interval = auto
  4. Choose the JSON parser with the JQ backend and set the root selector to .usage.
  5. Add start as a Time column, and cpu_time_sec and reserved_memory_byte_sec as Number columns.
  6. To split by Sprite, add group_by=sprite and a sprite_ref String 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. Use interval=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_found for a Sprite with no history; 403 if the token lacks access.
  • 400 invalid_interval for an interval under one second; 400 invalid_time_range for a bad range or a timestamp without a timezone.
  • With group_by=sprite, Sprites with no usage in the period appear with zero values.