Usage and Cost

Usage

http
GET https://modelgo-web-api.modelgo.ai/api/openapi/v1/usage?from=2026-10-01&to=2026-10-23&granularity=day&group_by=model
Authorization: Bearer mgpat_xxxxxxxx
ParameterMeaning
from / toRFC3339 or YYYY-MM-DD; defaults to the current UTC month
granularityhour / day / month
group_bynone / model / workspace / member / api_key
model / api_key_id / workspace_idFilters
timezoneUTC only

summary: requests, successes, errors, input/output/cached/reasoning tokens, charged_amount, currency.

Media usage is a dictionary, e.g. "media_units": {"image_count": 2, "video_seconds": 5}; text-only calls omit it. series: per bucket request_count, success_count, error_count, tokens, input_tokens, output_tokens, cached_tokens, cache_write_tokens, reasoning_tokens, charged_amount. Empty windows return the complete zero-filled calendar.

data_as_of is the global log watermark (newest event time, not the request time); billing_as_of is the settlement closed-through time — every session created before it is terminal, and it is the current time when none are open. is_final=true means the window ended at least five minutes before both watermarks, so late logs or settlements can no longer change it.

Cost

http
GET https://modelgo-web-api.modelgo.ai/api/openapi/v1/cost?from=2026-10-01&to=2026-10-23
Authorization: Bearer mgpat_xxxxxxxx

By default returns total_amount (authoritative) plus input_amount / output_amount / cache_amount / other_amount.

The response also carries the reserved media_amount / request_amount / discount_amount fields. The pricing pipeline has no source for them yet, so they are null and do not reconcile against total_amount.

Settlement status

Pass status=estimated|settled|pending|reversed to read that state from the billing ledger:

statusMeaning
estimatedSum of preauthorization quotes for every call in the window
settledActual charge of settled calls
pendingHolds still in flight
reversedPreauthorization amounts that were reversed/released

A status read returns only total_amount (no component split). model / api_key_id / workspace_id filters apply to status reads too.

Without X-Tenant-Id, usage and cost also return the per-tenant list; with it, a single object.